예제 #1
0
        internal static FB_AdminsAdded _parse(Session session, JToken data)
        {
            (FB_User author, FB_Thread thread, long at) = FB_AdminsAdded._parse_metadata(session, data);
            var target = new FB_User(data?.get("untypedData")?.get("TARGET_ID")?.Value <string>(), session);

            return(new FB_AdminsAdded()
            {
                author = author,
                thread = thread,
                added = new List <FB_User>()
                {
                    target
                },
                at = at
            });
        }
예제 #2
0
        public static FB_Event parse_delta(Session session, JToken data)
        {
            var type_ = data?.get("type")?.Value <string>();

            if (type_ == "change_thread_theme")
            {
                return(FB_ColorSet._parse(session, data));
            }
            else if (type_ == "change_thread_icon")
            {
                return(FB_EmojiSet._parse(session, data));
            }
            else if (type_ == "change_thread_nickname")
            {
                return(FB_NicknameSet._parse(session, data));
            }
            else if (type_ == "change_thread_admins")
            {
                var event_type = data?.get("untypedData")?.get("ADMIN_EVENT")?.Value <string>();
                if (event_type == "add_admin")
                {
                    return(FB_AdminsAdded._parse(session, data));
                }
                else if (event_type == "remove_admin")
                {
                    return(FB_AdminsRemoved._parse(session, data));
                }
            }
            else if (type_ == "change_thread_approval_mode")
            {
                return(FB_ApprovalModeSet._parse(session, data));
            }
            else if (type_ == "instant_game_update")
            {
                // TODO: This
            }
            else if (type_ == "messenger_call_log")  // Previously "rtc_call_log"
            {
                var event_type = data?.get("untypedData")?.get("event")?.Value <string>();
                if (event_type == "group_call_started")
                {
                    return(FB_CallStarted._parse(session, data));
                }
                else if (new string[] { "group_call_ended", "one_on_one_call_ended" }.Contains(event_type))
                {
                    return(FB_CallEnded._parse(session, data));
                }
            }
            else if (type_ == "participant_joined_group_call")
            {
                return(FB_CallJoined._parse(session, data));
            }
            else if (type_ == "group_poll")
            {
                var event_type = data?.get("untypedData")?.get("event_type")?.Value <string>();
                if (event_type == "question_creation")
                {
                    return(FB_PollCreated._parse(session, data));
                }
                else if (event_type == "update_vote")
                {
                    return(FB_PollVoted._parse(session, data));
                }
            }
            else if (type_ == "lightweight_event_create")
            {
                return(FB_PlanCreated._parse(session, data));
            }
            else if (type_ == "lightweight_event_notify")
            {
                return(FB_PlanEnded._parse(session, data));
            }
            else if (type_ == "lightweight_event_update")
            {
                return(FB_PlanEdited._parse(session, data));
            }
            else if (type_ == "lightweight_event_delete")
            {
                return(FB_PlanDeleted._parse(session, data));
            }
            else if (type_ == "lightweight_event_rsvp")
            {
                return(FB_PlanResponded._parse(session, data));
            }
            return(new FB_UnknownEvent()
            {
                source = "Delta type", data = data
            });
        }