Added stores for connections. Added requests for groups, group chatters, group permissions & connections. Using TTS Voice State store.

This commit is contained in:
Tom
2025-01-17 04:32:31 +00:00
parent 422cd91db2
commit 6d955f245a
29 changed files with 759 additions and 67 deletions

42
Requests/UpdateGroup.cs Normal file
View 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."));
}
}
}