Skip to content

Commit

Permalink
Added ability to fetch single messages from history
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig O'Shannessy committed Feb 11, 2017
1 parent c59a60e commit 911537a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public interface ChannelHistoryModule {

List<SlackMessagePosted> fetchHistoryOfChannel(String channelName, LocalDate day, int numberOfMessages);

SlackMessagePosted fetchSingleMessage(String channelId, String messageId);

List<SlackMessagePosted> fetchUpdatingHistoryOfChannel(String channelId);

List<SlackMessagePosted> fetchUpdatingHistoryOfChannel(String channelId, LocalDate day);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ public List<SlackMessagePosted> fetchHistoryOfChannel(String channelId, LocalDat
}
}

@Override
public SlackMessagePosted fetchSingleMessage(String channelId, String messageId) {
Map<String, String> params = new HashMap<>();
params.put("channel", channelId);
params.put("latest", messageId);
params.put("inclusive", String.valueOf(true));
params.put("count", String.valueOf(1));
List<SlackMessagePosted> messages = fetchHistoryOfChannel(params, FETCH_CHANNEL_HISTORY_COMMAND);
if ( messages.size() == 1 ) return messages.get(0);
return null;
}

private List<SlackMessagePosted> fetchHistoryOfChannel(Map<String, String> params, String command) {
SlackMessageHandle<GenericSlackReply> handle = session.postGenericSlackCommand(params, command);
GenericSlackReply replyEv = handle.getReply();
Expand Down

0 comments on commit 911537a

Please # to comment.