Esempio n. 1
0
        internal static FB_NicknameSet _parse(Session session, JToken data)
        {
            (FB_User author, FB_Thread thread, long at) = FB_NicknameSet._parse_metadata(session, data);
            var subject  = new FB_User(data?.get("untypedData")?.get("participant_id")?.Value <string>(), session);
            var nickname = data?.get("untypedData")?.get("nickname")?.Value <string>();

            return(new FB_NicknameSet()
            {
                author = author,
                thread = thread,
                subject = subject,
                nickname = nickname,
                at = at
            });
        }
Esempio n. 2
0
        internal static FB_NicknameSet _from_fetch(FB_Thread thread, JToken data)
        {
            (FB_User author, long at) = FB_NicknameSet._parse_fetch(thread.session, data);
            var extra    = data?.get("extensible_message_admin_text");
            var subject  = new FB_User(extra?.get("participant_id")?.Value <string>(), thread.session);
            var nickname = extra?.get("nickname")?.Value <string>();

            return(new FB_NicknameSet()
            {
                author = author,
                thread = thread,
                subject = subject,
                nickname = nickname,
                at = at
            });
        }
Esempio n. 3
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
            });
        }