Example #1
0
        private async Task <MogmogOperationResult> IfOpThroughBot(UserActionBotRequest req, Func <User, Task <MogmogOperationResult> > ifIsOp)
        {
            if (req == null)
            {
                throw new ArgumentNullException(nameof(req));
            }
            var(isOp, result) = await _userManager.IsOp(req.StateKey);

            if (isOp)
            {
                User user;
                (user, result) = await _userManager.GetUser(req.Id);

                if (result == MogmogOperationResult.Success)
                {
                    result = await ifIsOp(user);
                }
            }
            return(result);
        }
Example #2
0
 public override async Task <GeneralResult> BotUnmuteUser(UserActionBotRequest req, ServerCallContext context)
 => BuildResult(await IfOpThroughBot(req, _userManager.UnmuteUser));