Added stores for connections. Added requests for groups, group chatters, group permissions & connections. Using TTS Voice State store.
This commit is contained in:
42
Requests/UpdateGroup.cs
Normal file
42
Requests/UpdateGroup.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using HermesSocketLibrary.Requests.Messages;
|
||||
using HermesSocketServer.Models;
|
||||
using ILogger = Serilog.ILogger;
|
||||
|
||||
namespace HermesSocketServer.Requests
|
||||
{
|
||||
public class UpdateGroup : IRequest
|
||||
{
|
||||
public string Name => "update_group";
|
||||
public string[] RequiredKeys => ["id", "name", "priority"];
|
||||
private ILogger _logger;
|
||||
|
||||
public UpdateGroup(ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var id = data["id"].ToString()!;
|
||||
string name = data["name"].ToString()!;
|
||||
if (!int.TryParse(data["priority"].ToString()!, out var priority))
|
||||
return Task.FromResult(RequestResult.Failed("Priority needs to be an integer."));
|
||||
|
||||
var group = new Group()
|
||||
{
|
||||
Id = id,
|
||||
UserId = channel.Id,
|
||||
Name = name,
|
||||
Priority = priority,
|
||||
};
|
||||
|
||||
bool result = channel.Groups.Modify(id, group);
|
||||
if (result)
|
||||
{
|
||||
_logger.Information($"Updated group on channel [group id: {id}][name: {name}][priority: {priority}][channel: {channel.Id}]");
|
||||
return Task.FromResult(RequestResult.Successful(group));
|
||||
}
|
||||
return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache."));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user