示例#1
0
        public override void ExecuteCall(string callName)
        {
            switch (callName)
            {
                case "settings/me":
                        core.Response.WriteObject(core.Session.LoggedInMember.UserSettings);
                    break;
                case "info/me":
                        core.Response.WriteObject(core.Session.LoggedInMember.UserInfo);
                    break;
                case "profile":
                    {
                        long userId = core.Functions.RequestLong("id", core.Session.LoggedInMember.Id);

                        User user = new User(core, userId);
                        UserProfile up = user.Profile;

                        if (user.Access.Can("VIEW"))
                        {
                            core.Response.WriteObject(user);
                        }
                        else
                        {
                        }
                    }
                    break;
                case "friends":
                    {
                        long userId = core.Functions.RequestLong("id", core.Session.LoggedInMember.Id);
                        int page = core.Functions.RequestInt("page", 1);
                        int perPage = Math.Max(Math.Min(20, core.Functions.RequestInt("per_page", 18)), 1);
                        string filter = core.Http["filter"];

                        User user = new User(core, userId);

                        if (user.Access.Can("VIEW_FRIENDS"))
                        {
                            List<Friend> friends = user.GetFriends(page, perPage, filter);

                            core.Response.WriteObject(friends);
                        }
                    }
                    break;
                case "status_post":
                    string message = core.Http.Form["message"];
                    StatusMessage newMessage = StatusFeed.SaveMessage(core, message);

                    core.Response.WriteObject(newMessage);
                    break;
                case "status":
                    {
                        long statusId = core.Functions.RequestLong("id", 0);

                        if (statusId > 0)
                        {
                            try
                            {
                                StatusMessage status = new StatusMessage(core, statusId);

                                core.Response.WriteObject(status);
                            }
                            catch (InvalidStatusMessageException)
                            {
                            }
                        }
                    }
                    break;
                case "feed":
                    {
                        long ownerId = core.Functions.RequestLong("owner_id", core.Session.LoggedInMember.Id);
                        long ownerTypeId = core.Functions.RequestLong("owner_type_id", core.Session.LoggedInMember.ItemKey.TypeId);
                        User user = new User(core, ownerId);

                        CombinedFeed.ShowMore(core, user);
                    }
                    break;
            }
        }