Added support for StreamElements' Overlay Key for TTS. Added emote support for stores. Reduced emotes sent to users.
This commit is contained in:
@@ -14,54 +14,53 @@ namespace HermesSocketServer.Requests
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
|
||||
{
|
||||
var groupId = data["id"].ToString()!;
|
||||
var groupIdString = data["id"].ToString()!;
|
||||
var groupId = new Guid(groupIdString);
|
||||
|
||||
var result = channel.Groups.Remove(groupId);
|
||||
var result = channel.Groups.Remove(groupIdString);
|
||||
if (result)
|
||||
{
|
||||
var permissions = channel.GroupPermissions.Get().Values
|
||||
.Where(p => p.GroupId.ToString() == groupId);
|
||||
|
||||
Task? chattersSave = null;
|
||||
if (channel.Groups.Chatters.TryGetValue(groupId, out var chatters))
|
||||
if (channel.Groups.Chatters.TryGetValue(groupId.ToString(), out var chatters))
|
||||
{
|
||||
var filteredChatters = chatters.Get().Values.Where(c => c.GroupId == groupId).ToArray();
|
||||
if (filteredChatters.Any())
|
||||
var filteredChatters = chatters.Get().Values;
|
||||
foreach (var chatter in filteredChatters)
|
||||
{
|
||||
foreach (var chatter in filteredChatters)
|
||||
{
|
||||
var res = chatters.Remove(chatter.ChatterId.ToString(), fromCascade: true);
|
||||
if (!res)
|
||||
_logger.Warning($"Failed to delete group chatter by id [group chatter id: {chatter.ChatterId}]");
|
||||
}
|
||||
|
||||
chattersSave = chatters.Save();
|
||||
var res = chatters.Remove(chatter.ChatterId.ToString(), fromCascade: true);
|
||||
if (!res)
|
||||
_logger.Warning($"Failed to delete group chatter by id from cascade [group chatter id: {chatter.ChatterId}]");
|
||||
}
|
||||
}
|
||||
|
||||
var permissions = channel.GroupPermissions.Get().Values
|
||||
.Where(p => p.GroupId == groupId);
|
||||
|
||||
foreach (var permission in permissions)
|
||||
{
|
||||
var res = channel.GroupPermissions.Remove(permission.Id, fromCascade: true);
|
||||
if (!res)
|
||||
_logger.Warning($"Failed to delete group permission by id [group chatter id: {permission.Id}]");
|
||||
_logger.Warning($"Failed to delete group permission by id from cascade [group permission id: {permission.Id}]");
|
||||
}
|
||||
|
||||
if (chattersSave != null)
|
||||
await Task.WhenAll(chattersSave, channel.GroupPermissions.Save());
|
||||
else
|
||||
await channel.GroupPermissions.Save();
|
||||
|
||||
if (!channel.Groups.Chatters.Remove(groupId))
|
||||
var policies = channel.Policies.Get().Values
|
||||
.Where(c => c.GroupId == groupId).ToArray();
|
||||
foreach (var policy in policies)
|
||||
{
|
||||
var res = channel.Policies.Remove(policy.Id.ToString(), fromCascade: true);
|
||||
if (!res)
|
||||
_logger.Warning($"Failed to delete group policy by id from cascade [group policy id: {policy.Id}]");
|
||||
}
|
||||
|
||||
if (!channel.Groups.Chatters.Remove(groupIdString))
|
||||
_logger.Warning($"Failed to delete group chatters from inner store [group id: {groupId}]");
|
||||
|
||||
_logger.Information($"Deleted a group by id [group id: {groupId}]");
|
||||
return RequestResult.Successful(null);
|
||||
return Task.FromResult(RequestResult.Successful(null));
|
||||
}
|
||||
|
||||
_logger.Warning($"Group Id does not exist [group id: {groupId}]");
|
||||
return RequestResult.Failed("Something went wrong when updating the cache.");
|
||||
return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache."));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user