Added stores for connections. Added requests for groups, group chatters, group permissions & connections. Using TTS Voice State store.
This commit is contained in:
37
Requests/GetGroups.cs
Normal file
37
Requests/GetGroups.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using HermesSocketLibrary.Requests.Messages;
|
||||
using HermesSocketServer.Models;
|
||||
using ILogger = Serilog.ILogger;
|
||||
|
||||
namespace HermesSocketServer.Requests
|
||||
{
|
||||
public class GetGroups : IRequest
|
||||
{
|
||||
public string Name => "get_groups";
|
||||
public string[] RequiredKeys => [];
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public GetGroups(ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var groups = channel.Groups.Get().Values;
|
||||
var chatters = channel.Groups.Chatters;
|
||||
var all = groups.Select(g => new GroupDetails()
|
||||
{
|
||||
Group = g,
|
||||
Chatters = chatters[g.Id].Get().Values,
|
||||
});
|
||||
_logger.Information($"Fetched all groups for channel [channel: {channel.Id}]");
|
||||
return Task.FromResult(RequestResult.Successful(all, notifyClientsOnAccount: false));
|
||||
}
|
||||
|
||||
private class GroupDetails
|
||||
{
|
||||
public required Group Group;
|
||||
public required IEnumerable<GroupChatter> Chatters;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user