Exemplo n.º 1
0
        public async Task RemoveModeratorFromSpace(string username, string spaceName, User user)
        {
            User oldMod = await GetUserOrThrow(username);

            Space space = await GetSpaceOrThrow(spaceName);

            Role?modRole = await roleRepo.FindModeratorRole(user, spaceName);

            if (modRole == null)
            {
                throw new InvalidOperationException($"User {oldMod.Username} was not a mod of space {space}.");
            }

            await roleRepo.Delete(modRole);

            await eventBus.Dispatch(new ModeratorRemovedFromSpaceEvent(space, user));
        }