Exemple #1
0
        internal static FB_TitleSet _from_fetch(FB_Thread thread, JToken data)
        {
            (FB_User author, long at) = FB_TitleSet._parse_fetch(thread.session, data);

            return(new FB_TitleSet()
            {
                author = author,
                thread = thread as FB_Group,
                title = data?.get("thread_name")?.Value <string>(),
                at = at
            });
        }
Exemple #2
0
        internal static FB_TitleSet _parse(Session session, JToken data)
        {
            (FB_User author, FB_Thread thread, long at) = FB_TitleSet._parse_metadata(session, data);

            return(new FB_TitleSet()
            {
                author = author,
                thread = thread as FB_Group,
                title = data?.get("name")?.Value <string>(),
                at = at
            });
        }
Exemple #3
0
        public static FB_Event parse_delta(Session session, JToken data)
        {
            var class_ = data?.get("class")?.Value <string>();

            if (class_ == "ParticipantsAddedToGroupThread")
            {
                return(FB_ParticipantsAdded._parse(session, data));
            }
            else if (class_ == "ParticipantLeftGroupThread")
            {
                return(FB_ParticipantRemoved._parse(session, data));
            }
            else if (class_ == "MarkFolderSeen")
            {
                // TODO: Finish this
                var folders = data.get("folders")?.Select(folder =>
                                                          folder?.Value <string>().Replace("FOLDER_", ""));
                var at = long.Parse(data?.get("timestamp")?.Value <string>());
                return(null);
            }
            else if (class_ == "ThreadName")
            {
                return(FB_TitleSet._parse(session, data));
            }
            else if (class_ == "ForcedFetch")
            {
                return(FB_UnfetchedThreadEvent._parse(session, data));
            }
            else if (class_ == "DeliveryReceipt")
            {
                return(FB_MessagesDelivered._parse(session, data));
            }
            else if (class_ == "ReadReceipt")
            {
                return(FB_ThreadsRead._parse_read_receipt(session, data));
            }
            else if (class_ == "MarkRead")
            {
                return(FB_ThreadsRead._parse(session, data));
            }
            else if (class_ == "NoOp")
            {
                // Skip "no operation" events
                return(null);
            }
            else if (class_ == "ClientPayload")
            {
                throw new FBchatParseError("This is implemented in `parse_events`");
            }
            else if (class_ == "NewMessage")
            {
                return(FB_MessageEvent._parse(session, data));
            }
            else if (class_ == "ThreadFolder")
            {
                return(FB_ThreadFolder._parse(session, data));
            }
            return(new FB_UnknownEvent()
            {
                source = "Delta class", data = data
            });
        }