예제 #1
0
        public RESTReplyData user_get(RESTRequestData pReq, List <string> pArgs)
        {
            RESTReplyData replyData = new RESTReplyData();  // The HTTP response info
            ResponseBody  respBody  = new ResponseBody();   // The request's "data" response info

            SessionEntity aSession = Sessions.Instance.GetSession(pReq.SenderKey);

            PaginationInfo pagination = new PaginationInfo(pReq);

            if (Accounts.Instance.TryGetAccountWithAuthToken(pReq.AuthToken, out AccountEntity aAccount))
            {
                AccountFilterInfo  acctFilter  = new AccountFilterInfo(pReq);
                AccountScopeFilter scopeFilter = new AccountScopeFilter(pReq, aAccount);

                respBody.Data = new bodyUsersReply()
                {
                    users = Accounts.Instance.Enumerate(pagination, acctFilter, scopeFilter).Select(acct =>
                    {
                        bodyUser ret = new bodyUser()
                        {
                            username  = acct.Username,
                            accountid = acct.AccountID,
                            images    = acct.Images,
                        };
                        ret.location = BuildLocationInfo(acct);
                        return(ret);
                    }).ToArray()
                };
            }

            // Pagination fills the top level of the reply with paging info
            pagination.AddReplyFields(respBody);

            replyData.SetBody(respBody, pReq);
            return(replyData);
        }