Skip to content

Commit

Permalink
using a better method to retrieve start message for thread (Together-…
Browse files Browse the repository at this point in the history
…Java#1106)

* using a better method to retrieve start message for thread

* replace retrieveMessageById with getStartMessage on threadChannel channel type
  • Loading branch information
ankitsmt211 authored May 13, 2024
1 parent f045ccf commit f8c91a9
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ private static boolean isPostedBySelfUser(Message message) {
}

private RestAction<Message> createAIResponse(ThreadChannel threadChannel) {
RestAction<Message> originalQuestion =
threadChannel.retrieveMessageById(threadChannel.getIdLong());
RestAction<Message> originalQuestion = threadChannel.retrieveStartMessage();
return originalQuestion.flatMap(HelpThreadCreatedListener::isContextSufficient,
message -> helper.constructChatGptAttempt(threadChannel, getMessageContent(message),
componentIdInteractor));
Expand All @@ -110,7 +109,7 @@ private static boolean isContextSufficient(Message message) {
}

private RestAction<Void> pinOriginalQuestion(ThreadChannel threadChannel) {
return threadChannel.retrieveMessageById(threadChannel.getIdLong()).flatMap(Message::pin);
return threadChannel.retrieveStartMessage().flatMap(Message::pin);
}

private RestAction<Message> generateAutomatedResponse(ThreadChannel threadChannel) {
Expand Down Expand Up @@ -172,7 +171,7 @@ public void onButtonClick(ButtonInteractionEvent event, List<String> args) {
ThreadChannel channel = event.getChannel().asThreadChannel();
Member interactionUser = Objects.requireNonNull(event.getMember());

channel.retrieveMessageById(channel.getId())
channel.retrieveStartMessage()
.queue(forumPostMessage -> handleDismiss(interactionUser, channel, forumPostMessage,
event, args));

Expand Down

0 comments on commit f8c91a9

Please sign in to comment.