Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow paging on GetConversationsHistoryAsync #319

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions SlackAPI/SlackTaskClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public Task<ConversationsListResponse> GetConversationsListAsync(string cursor =

return APIRequestWithTokenAsync<ConversationsListResponse>(parameters.ToArray());
}

public Task<ConversationsMembersResponse> GetConversationsMembersAsync(string channelId, string cursor = "", int limit = 100)
{
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>
Expand Down Expand Up @@ -227,12 +227,16 @@ public Task<FileListResponse> GetFilesAsync(string userId = null, DateTime? from
return APIRequestWithTokenAsync<FileListResponse>(parameters.ToArray());
}

private Task<K> GetHistoryAsync<K>(string channel, DateTime? latest = null, DateTime? oldest = null, int? count = null, bool? unreads = false)
private Task<K> GetHistoryAsync<K>(string channel, DateTime? latest = null, DateTime? oldest = null, int? count = null, bool? unreads = false, string cursor = null, int? limit = null)
where K : MessageHistory
{
List<Tuple<string,string>> parameters = new List<Tuple<string,string>>();
parameters.Add(new Tuple<string, string>("channel", channel));

if(cursor != null)
parameters.Add(new Tuple<string, string>("cursor", cursor));
if(limit.HasValue)
parameters.Add(new Tuple<string, string>("limit", limit.ToString()));
if(latest.HasValue)
parameters.Add(new Tuple<string, string>("latest", latest.Value.ToProperTimeStamp()));
if(oldest.HasValue)
Expand Down Expand Up @@ -260,9 +264,9 @@ public Task<GroupMessageHistory> GetGroupHistoryAsync(Channel groupInfo, DateTim
return GetHistoryAsync<GroupMessageHistory>(groupInfo.id, latest, oldest, count, unreads);
}

public Task<ConversationsMessageHistory> GetConversationsHistoryAsync(Channel conversationInfo, DateTime? latest = null, DateTime? oldest = null, int? count = null, bool? unreads = false)
public Task<ConversationsMessageHistory> GetConversationsHistoryAsync(Channel conversationInfo, DateTime? latest = null, DateTime? oldest = null, int? count = null, bool? unreads = false, string cursor = null, int? limit = null)
{
return GetHistoryAsync<ConversationsMessageHistory>(conversationInfo.id, latest, oldest, count, unreads);
return GetHistoryAsync<ConversationsMessageHistory>(conversationInfo.id, latest, oldest, count, unreads, cursor, limit);
}

public Task<MarkResponse> MarkChannelAsync(string channelId, DateTime ts)
Expand Down