Fixed multiple issues.
This commit is contained in:
@ -19,9 +19,17 @@ namespace HermesSocketServer.Requests
|
||||
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
|
||||
{
|
||||
var channel = _channels.Get(sender);
|
||||
channel.Policies.Remove(data!["id"].ToString());
|
||||
_logger.Information($"Deleted a policy by id [policy id: {data["id"]}]");
|
||||
return RequestResult.Successful(null);
|
||||
|
||||
string policyId = data!["id"].ToString()!;
|
||||
var policy = channel.Policies.Get(policyId);
|
||||
if (policy != null) {
|
||||
channel.Policies.Remove(policyId);
|
||||
_logger.Information($"Deleted a policy by id [policy id: {data["id"]}]");
|
||||
return RequestResult.Successful(policy.GroupId + "/" + policy.Path);
|
||||
}
|
||||
|
||||
_logger.Warning("Failed to find policy by id ");
|
||||
return RequestResult.Failed("Cannot find the policy by id.");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user