Beispiel #1
0
        private async Task <IList <MastodonUser> > GetUsers(SearchMastodonUsersCommand searchMastodonUsersCommand, PageInformation refPageInformtation)
        {
            var users = null as Dictionary <string, MastodonUser>;

            if (!string.IsNullOrWhiteSpace(searchMastodonUsersCommand.UserID))
            {
                users = await FilterByUserID(users, searchMastodonUsersCommand.UserID);
            }
            if (!string.IsNullOrWhiteSpace(searchMastodonUsersCommand.FollowedByUserID))
            {
                users = await FilterByFollowedByUserID(users, searchMastodonUsersCommand.FollowedByUserID, searchMastodonUsersCommand.PagingOptions, refPageInformtation);
            }
            if (!string.IsNullOrWhiteSpace(searchMastodonUsersCommand.FollowsUserID))
            {
                users = await FilterByFollowsByUserID(users, searchMastodonUsersCommand.FollowsUserID, searchMastodonUsersCommand.PagingOptions, refPageInformtation);
            }
            if (!string.IsNullOrWhiteSpace(searchMastodonUsersCommand.Name))
            {
                users = await FilterByName(users, searchMastodonUsersCommand.Name, searchMastodonUsersCommand.PagingOptions);
            }

            await _mastodonApiWrapper.AddContextToMastodonUsers
            (
                users.Values,
                new MastodonUserContextOptions
            {
                IncludeFollowers = searchMastodonUsersCommand.IncludeFollowers,
                IncludeFollowing = searchMastodonUsersCommand.IncludeFollowing,
                IncludeIsFollowedByActiveUser = searchMastodonUsersCommand.IncludeFollowedByActiveUser,
                IncludeFollowsActiveUser      = searchMastodonUsersCommand.IncludeFollowsActiveUser
            }
            );

            return(users.Values.ToArray());
        }
Beispiel #2
0
        public CommandResult <SearchMastodonUsersCommandResultData> SearchUsers(SearchMastodonUsersCommand searchMastodonUsersCommand)
        {
            return(ProcessCommand <SearchMastodonUsersCommandResultData>(result =>
            {
                if (searchMastodonUsersCommand.IsGlobalSearch)
                {
                    throw new UserErrorException("Please specify at least one search criterion");
                }

                var refPagedList = new PageInformation();
                result.Data = new SearchMastodonUsersCommandResultData
                {
                    Users = GetUsers(searchMastodonUsersCommand, refPagedList).Synchronously(),
                    PageInformation = refPagedList
                };
            }));
        }