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

@@ -17,7 +17,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 = Guid.Parse(data["id"].ToString()!);
string groupId = data["groupId"].ToString()!;
@@ -25,11 +25,10 @@ namespace HermesSocketServer.Requests
int count = int.Parse(data["count"].ToString()!);
int span = int.Parse(data["span"].ToString()!);
var channel = _channels.Get(sender)!;
bool result = channel.Policies.Set(id.ToString(), new PolicyMessage()
{
Id = id,
UserId = sender,
UserId = channel.Id,
GroupId = Guid.Parse(groupId),
Path = path,
Usage = count,
@@ -39,7 +38,7 @@ namespace HermesSocketServer.Requests
if (result)
{
var policy = channel.Policies.Get(id.ToString());
_logger.Information($"Updated policy to channel [policy id: {id}][group id: {groupId}][path: {path}][count: {count}][span: {span}][channel: {sender}]");
_logger.Information($"Updated policy to channel [policy id: {id}][group id: {groupId}][path: {path}][count: {count}][span: {span}][channel: {channel.Id}]");
return RequestResult.Successful(policy);
}
return RequestResult.Failed("Something went wrong when updating the cache.");