Changed sender parameter to channel.

This commit is contained in:
Tom
2024-12-27 23:31:36 +00:00
parent 06bfe110bb
commit 8277ea0154
27 changed files with 113 additions and 134 deletions

View File

@ -1,4 +1,5 @@
using HermesSocketLibrary.Requests.Messages;
using HermesSocketServer.Models;
using HermesSocketServer.Services;
using ILogger = Serilog.ILogger;
@ -17,7 +18,7 @@ namespace HermesSocketServer.Requests
_logger = logger;
}
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
{
var id = data["id"].ToString()!;
string search = data["search"].ToString()!;
@ -26,17 +27,16 @@ namespace HermesSocketServer.Requests
var filter = new TTSWordFilter()
{
Id = id,
UserId = sender,
UserId = channel.Id,
Search = search,
Replace = replace,
};
var channel = _channels.Get(sender);
bool result = channel.Filters.Set(id, filter);
if (result)
{
_logger.Information($"Updated filter to channel [filter id: {id}][search: {search}][replace: {replace}][channel: {sender}]");
_logger.Information($"Updated filter to channel [filter id: {id}][search: {search}][replace: {replace}][channel: {channel.Id}]");
return RequestResult.Successful(filter);
}
return RequestResult.Failed("Something went wrong when updating the cache.");