Skip to content

Commit

Permalink
- Manually assigning roles when actions dictate role changing
Browse files Browse the repository at this point in the history
  • Loading branch information
SaviorXTanren committed Sep 21, 2023
1 parent f030a8a commit f3a9bd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
2 changes: 2 additions & 0 deletions MixItUp.Base/Model/Actions/ModerationActionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ protected override async Task PerformInternal(CommandParametersModel parameters)
}
else if (this.ActionType == ModerationActionTypeEnum.ModUser)
{
targetUser.Roles.Add(User.UserRoleEnum.Moderator);
await ServiceManager.Get<ChatService>().ModUser(targetUser);
}
else if (this.ActionType == ModerationActionTypeEnum.UnmodUser)
{
targetUser.Roles.Remove(User.UserRoleEnum.Moderator);
await ServiceManager.Get<ChatService>().UnmodUser(targetUser);
}
else if (this.ActionType == ModerationActionTypeEnum.AddModerationStrike)
Expand Down
30 changes: 16 additions & 14 deletions MixItUp.Base/Model/Actions/TwitchActionModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using MixItUp.Base.Model.Commands;
using MixItUp.Base.Model.User.Platform;
using MixItUp.Base.Services;
using MixItUp.Base.Services.Twitch;
using MixItUp.Base.Util;
using MixItUp.Base.ViewModel.User;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -315,29 +317,29 @@ protected override async Task PerformInternal(CommandParametersModel parameters)
}
else if (this.ActionType == TwitchActionType.VIPUser || this.ActionType == TwitchActionType.UnVIPUser)
{
string targetUsername = null;
UserV2ViewModel targetUser = null;
if (!string.IsNullOrEmpty(this.Username))
{
targetUsername = await ReplaceStringWithSpecialModifiers(this.Username, parameters);
string targetUsername = await ReplaceStringWithSpecialModifiers(this.Username, parameters);
targetUser = await ServiceManager.Get<UserService>().GetUserByPlatformUsername(StreamingPlatformTypeEnum.Twitch, targetUsername, performPlatformSearch: true);
}
else
{
targetUsername = parameters.User.Username;
targetUser = parameters.User;
}

if (!string.IsNullOrEmpty(targetUsername))
if (targetUser != null)
{
UserModel targetUser = await ServiceManager.Get<TwitchSessionService>().UserConnection.GetNewAPIUserByLogin(targetUsername);
if (targetUser != null)
UserModel twitchUser = targetUser.GetPlatformData<TwitchUserPlatformV2Model>(StreamingPlatformTypeEnum.Twitch).GetTwitchNewAPIUserModel();
if (this.ActionType == TwitchActionType.VIPUser)
{
if (this.ActionType == TwitchActionType.VIPUser)
{
await ServiceManager.Get<TwitchSessionService>().UserConnection.VIPUser(ServiceManager.Get<TwitchSessionService>().User, targetUser);
}
else if (this.ActionType == TwitchActionType.UnVIPUser)
{
await ServiceManager.Get<TwitchSessionService>().UserConnection.UnVIPUser(ServiceManager.Get<TwitchSessionService>().User, targetUser);
}
targetUser.Roles.Add(User.UserRoleEnum.TwitchVIP);
await ServiceManager.Get<TwitchSessionService>().UserConnection.VIPUser(ServiceManager.Get<TwitchSessionService>().User, twitchUser);
}
else if (this.ActionType == TwitchActionType.UnVIPUser)
{
targetUser.Roles.Remove(User.UserRoleEnum.TwitchVIP);
await ServiceManager.Get<TwitchSessionService>().UserConnection.UnVIPUser(ServiceManager.Get<TwitchSessionService>().User, twitchUser);
}
}
}
Expand Down

0 comments on commit f3a9bd4

Please sign in to comment.