Пример #1
0
        public async Task <ApiResult <PagedResponse <Quote> > > GetUnapprovedQuotes([FromQuery] string?guildsFilter, [FromQuery] PagingFilter pagingFilter)
        {
            ValidatePagingFilter(pagingFilter);
            var userGuilds = await _natsDiscordService.GetMutualGuildsFor(UserDiscordId);

            var filteredUserGuilds = new List <string>();

            foreach (var guild in userGuilds)
            {
                var isMod = await _natsDiscordService.IsModeratorInGuild(UserDiscordId, guild.Id);

                if (isMod)
                {
                    filteredUserGuilds.Add(guild.Id.ToString());
                }
            }

            var filter = guildsFilter?.Split(",").Where(x => filteredUserGuilds.Contains(x)) ?? filteredUserGuilds;

            return(Ok(await _natsQuoteService.FindUnapproved(filter, pagingFilter)));
        }
Пример #2
0
        public async Task <ApiResult <IEnumerable <Guild> > > GetGuilds()
        {
            var mutualGuilds = await _natsDiscordService.GetMutualGuildsFor(UserDiscordId);

            var guilds = new List <Guild>();

            foreach (var guild in mutualGuilds)
            {
                var isMod = await _natsDiscordService.IsModeratorInGuild(UserDiscordId, guild.Id);

                guilds.Add(new Guild
                {
                    Id              = guild.Id.ToString(),
                    Description     = guild.Description,
                    Name            = guild.Name,
                    IsModerator     = isMod,
                    SystemChannelId = guild.SystemChannelId.ToString(),
                    IconUrl         = guild.IconUrl,
                });
            }

            return(Ok(guilds));
        }