internal static FB_MessagesDelivered _parse(Session session, JToken data) { var thread = FB_MessagesDelivered._get_thread(session, data); var author = thread; if (data?.get("actorFbId")?.Value <string>() != null) { author = new FB_User(data?.get("actorFbId")?.Value <string>(), session); } var messages = data?.get("messageIds")?.Select(x => new FB_Message(session, thread_id: thread.uid, uid: x?.Value <string>())); var at = long.Parse(data?.get("deliveredWatermarkTimestampMs")?.Value <string>()); return(new FB_MessagesDelivered() { author = author as FB_User, thread = thread, messages = messages.ToList(), at = at }); }
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 }); }