diff --git a/fbchat-sharp/API/Client.cs b/fbchat-sharp/API/Client.cs index 9170ec9..83e299a 100644 --- a/fbchat-sharp/API/Client.cs +++ b/fbchat-sharp/API/Client.cs @@ -12,7 +12,7 @@ namespace fbchat_sharp.API /// /// /// - public class Client_Constants + internal class Client_Constants { public static readonly Dictionary ACONTEXT = new Dictionary() { @@ -785,8 +785,7 @@ public async Task> fetchActiveUsers() /// /// User/Group ID to which the message belongs.See :ref:`intro_threads` /// Message ID to set as delivered.See :ref:`intro_threads` - /// true - public async Task markAsDelivered(string thread_id, string message_id) + public async Task markAsDelivered(string thread_id, string message_id) { /* * Mark a message as delivered @@ -800,7 +799,6 @@ public async Task markAsDelivered(string thread_id, string message_id) {string.Format("thread_ids[{0}][0]",thread_id), message_id}}; var j = await this._session._payload_post("/ajax/mercury/delivery_receipts.php", data); - return true; } private async Task _readStatus(bool read, List thread_ids, long? timestamp = null) @@ -868,8 +866,7 @@ public async Task markAsSeen() /// /// ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER /// Thread IDs to move.See :ref:`intro_threads` - /// true - public async Task moveThreads(string location, List thread_ids) + public async Task moveThreads(string location, List thread_ids) { /* * Moves threads to specifed location @@ -906,15 +903,13 @@ public async Task moveThreads(string location, List thread_ids) data[string.Format("{0}[{1}]", location.ToLower(), obj.i)] = obj.thread_id; var j = await this._session._payload_post("/ajax/mercury/move_thread.php", data); } - return true; } /// /// Deletes threads /// /// Thread IDs to delete. See :ref:`intro_threads` - /// true - public async Task deleteThreads(List thread_ids) + public async Task deleteThreads(List thread_ids) { /* * Deletes threads @@ -937,15 +932,13 @@ public async Task deleteThreads(List thread_ids) var j_delete = this._session._payload_post( "/ajax/mercury/delete_thread.php?dpr=1", data_delete ); - return true; } /// /// Deletes specifed messages /// /// Message IDs to delete - /// true - public async Task deleteMessages(List message_ids) + public async Task deleteMessages(List message_ids) { /* * Deletes specifed messages @@ -958,7 +951,6 @@ public async Task deleteMessages(List message_ids) foreach (var obj in umessage_ids.Select((x, index) => new { message_id = x, i = index })) data[string.Format("message_ids[{0}]", obj.i)] = obj.message_id; var j = await this._session._payload_post("/ajax/mercury/delete_messages.php?dpr=1", data); - return true; } #endregion diff --git a/fbchat-sharp/API/Events/Event.cs b/fbchat-sharp/API/Events/Event.cs index c5e6c40..c857d95 100644 --- a/fbchat-sharp/API/Events/Event.cs +++ b/fbchat-sharp/API/Events/Event.cs @@ -102,7 +102,7 @@ public class FB_ThreadEvent : FB_Event /// Thread that the action was done in public FB_Thread thread { get; set; } - public static (FB_User author, FB_Thread thread, long at) _parse_metadata(Session session, JToken data) + internal static (FB_User author, FB_Thread thread, long at) _parse_metadata(Session session, JToken data) { var metadata = data?.get("messageMetadata"); var author = new FB_User(session: session, uid: metadata?.get("actorFbId")?.Value()); @@ -111,7 +111,7 @@ public static (FB_User author, FB_Thread thread, long at) _parse_metadata(Sessio return (author, thread, at); } - public static FB_Thread _get_thread(Session session, JToken data) + internal static FB_Thread _get_thread(Session session, JToken data) { // TODO: Handle pages? Is it even possible? var key = data?.get("threadKey"); diff --git a/fbchat-sharp/API/Exception.cs b/fbchat-sharp/API/Exception.cs index dbf5627..d9592fd 100644 --- a/fbchat-sharp/API/Exception.cs +++ b/fbchat-sharp/API/Exception.cs @@ -34,6 +34,10 @@ public FBchatParseError(string message, JToken data = null) : base(message) this.Data.Add("data", data); } + /// + /// Returns a string representation of the current exception. + /// + /// public override string ToString() { var msg = "{0}. Please report this, along with the data below!\n{1}"; diff --git a/fbchat-sharp/API/GraphQl.cs b/fbchat-sharp/API/GraphQl.cs index 9422769..75ce68f 100644 --- a/fbchat-sharp/API/GraphQl.cs +++ b/fbchat-sharp/API/GraphQl.cs @@ -7,7 +7,7 @@ namespace fbchat_sharp.API { - public class GraphQL : Dictionary + internal class GraphQL : Dictionary { public static string queries_to_json(List queries) { diff --git a/fbchat-sharp/API/Models/Attachment.cs b/fbchat-sharp/API/Models/Attachment.cs index e00c652..b3e99ae 100644 --- a/fbchat-sharp/API/Models/Attachment.cs +++ b/fbchat-sharp/API/Models/Attachment.cs @@ -9,6 +9,9 @@ namespace fbchat_sharp.API /// public class FB_Attachment { + /// + /// Unique id of the attachmnt. + /// public string uid { get; set; } /// @@ -20,7 +23,7 @@ public FB_Attachment(string uid = null) this.uid = uid; } - public static FB_Attachment graphql_to_attachment(JToken data) + internal static FB_Attachment graphql_to_attachment(JToken data) { var _type = data.get("__typename")?.Value(); if (new string[] { "MessageImage", "MessageAnimatedImage" }.Contains(_type)) @@ -45,7 +48,7 @@ public static FB_Attachment graphql_to_attachment(JToken data) } } - public static FB_Attachment graphql_to_subattachment(JToken data) + internal static FB_Attachment graphql_to_subattachment(JToken data) { JToken target = data.get("target"); string type = target != null ? target.get("__typename")?.Value() : null; @@ -54,7 +57,7 @@ public static FB_Attachment graphql_to_subattachment(JToken data) return null; } - public static FB_Attachment graphql_to_extensible_attachment(JToken data) + internal static FB_Attachment graphql_to_extensible_attachment(JToken data) { var story = data.get("story_attachment"); if (story == null) @@ -141,7 +144,7 @@ public FB_ShareAttachment(string uid = null, string author = null, string url = this.attachments = attachments; } - public static FB_ShareAttachment _from_graphql(JToken data) + internal static FB_ShareAttachment _from_graphql(JToken data) { string url = data.get("url")?.Value(); FB_ShareAttachment rtn = new FB_ShareAttachment( diff --git a/fbchat-sharp/API/Models/File.cs b/fbchat-sharp/API/Models/File.cs index 4f29a1d..8d9b896 100644 --- a/fbchat-sharp/API/Models/File.cs +++ b/fbchat-sharp/API/Models/File.cs @@ -16,6 +16,12 @@ public class FB_File /// Local or remote file type public string mimetype { get; set; } + /// + /// Facebook messenger file class + /// + /// + /// + /// public FB_File(Stream data = null, string path = null, string mimetype = null) { this.data = data; @@ -54,7 +60,7 @@ public FB_FileAttachment(string uid = null, string url = null, int size = 0, str this.is_malicious = is_malicious; } - public static FB_FileAttachment _from_graphql(JToken data) + internal static FB_FileAttachment _from_graphql(JToken data) { return new FB_FileAttachment( url: data.get("url")?.Value(), @@ -96,7 +102,7 @@ public FB_AudioAttachment(string uid = null, string filename = null, string url this.audio_type = audio_type; } - public static FB_AudioAttachment _from_graphql(JToken data) + internal static FB_AudioAttachment _from_graphql(JToken data) { return new FB_AudioAttachment( filename: data.get("filename")?.Value(), @@ -156,7 +162,7 @@ public FB_ImageAttachment(string uid = null, string original_extension = null, i this.animated_preview = animated_preview; } - public static FB_ImageAttachment _from_graphql(JToken data) + internal static FB_ImageAttachment _from_graphql(JToken data) { return new FB_ImageAttachment( original_extension: data.get("original_extension")?.Value() ?? data.get("filename")?.Value()?.Split('-')[0], @@ -170,7 +176,7 @@ public static FB_ImageAttachment _from_graphql(JToken data) uid: data.get("legacy_attachment_id")?.Value()); } - public static FB_ImageAttachment _from_list(JToken data) + internal static FB_ImageAttachment _from_list(JToken data) { return new FB_ImageAttachment( width: data?.get("original_dimensions")?.get("x")?.Value() ?? 0, @@ -230,7 +236,7 @@ public FB_VideoAttachment(string uid = null, int size = 0, int width = 0, int he this.large_image = large_image; } - public static FB_VideoAttachment _from_graphql(JToken data) + internal static FB_VideoAttachment _from_graphql(JToken data) { return new FB_VideoAttachment( width: data.get("original_dimensions")?.get("width")?.Value() ?? 0, @@ -243,7 +249,7 @@ public static FB_VideoAttachment _from_graphql(JToken data) uid: data.get("legacy_attachment_id")?.Value()); } - public static FB_VideoAttachment _from_list(JToken data) + internal static FB_VideoAttachment _from_list(JToken data) { return new FB_VideoAttachment( width: data?.get("original_dimensions")?.get("x")?.Value() ?? 0, @@ -255,7 +261,7 @@ public static FB_VideoAttachment _from_list(JToken data) ); } - public static FB_VideoAttachment _from_subattachment(JToken data) + internal static FB_VideoAttachment _from_subattachment(JToken data) { JToken media = data.get("media"); return new FB_VideoAttachment( diff --git a/fbchat-sharp/API/Models/Image.cs b/fbchat-sharp/API/Models/Image.cs index 8bb3d1d..a41bfec 100644 --- a/fbchat-sharp/API/Models/Image.cs +++ b/fbchat-sharp/API/Models/Image.cs @@ -2,6 +2,9 @@ namespace fbchat_sharp.API { + /// + /// Represents a facebook image. + /// public class FB_Image { /// URL to the image @@ -21,7 +24,7 @@ public FB_Image(string url = null, int image_width = 0, int image_height = 0) this.image_height = image_height; } - public static FB_Image _from_uri(JToken data) + internal static FB_Image _from_uri(JToken data) { return new FB_Image( image_width: data?.get("width")?.Value() ?? 0, @@ -29,7 +32,7 @@ public static FB_Image _from_uri(JToken data) url: data?.get("uri")?.Value()); } - public static FB_Image _from_url(JToken data) + internal static FB_Image _from_url(JToken data) { return new FB_Image( image_width: data?.get("width")?.Value() ?? 0, @@ -37,12 +40,12 @@ public static FB_Image _from_url(JToken data) url: data?.get("url")?.Value()); } - public static FB_Image _from_uri_or_none(JToken data) + internal static FB_Image _from_uri_or_none(JToken data) { return (data?.get("uri") != null) ? FB_Image._from_uri(data) : null; } - public static FB_Image _from_url_or_none(JToken data) + internal static FB_Image _from_url_or_none(JToken data) { return (data?.get("url") != null) ? FB_Image._from_url(data) : null; } diff --git a/fbchat-sharp/API/Models/Location.cs b/fbchat-sharp/API/Models/Location.cs index 443c318..be3eb14 100644 --- a/fbchat-sharp/API/Models/Location.cs +++ b/fbchat-sharp/API/Models/Location.cs @@ -40,7 +40,7 @@ public FB_LocationAttachment(string uid = null, double latitude = 0, double long this.address = address; } - public static FB_LocationAttachment _from_graphql(JToken data) + internal static FB_LocationAttachment _from_graphql(JToken data) { var url = data.get("url")?.Value(); var address = Utils.get_url_parameter(Utils.get_url_parameter(url, "u"), "where1"); @@ -105,7 +105,7 @@ public FB_LiveLocationAttachment(string uid = null, double latitude = 0, double this.is_expired = is_expired; } - public static FB_LiveLocationAttachment _from_pull(JToken data) + internal static FB_LiveLocationAttachment _from_pull(JToken data) { return new FB_LiveLocationAttachment( uid: data.get("id")?.Value(), @@ -116,7 +116,7 @@ public static FB_LiveLocationAttachment _from_pull(JToken data) is_expired: data.get("stopReason")?.Value() ?? false); } - public static new FB_LiveLocationAttachment _from_graphql(JToken data) + internal static new FB_LiveLocationAttachment _from_graphql(JToken data) { var target = data.get("target"); var rtn = new FB_LiveLocationAttachment( diff --git a/fbchat-sharp/API/Models/Message.cs b/fbchat-sharp/API/Models/Message.cs index 94e4ea1..65e9b33 100644 --- a/fbchat-sharp/API/Models/Message.cs +++ b/fbchat-sharp/API/Models/Message.cs @@ -23,7 +23,7 @@ public enum EmojiSize SMALL } - public class EmojiSizeMethods + internal class EmojiSizeMethods { public static EmojiSize? _from_tags(List tags) { @@ -43,7 +43,7 @@ public class EmojiSizeMethods /// public class FB_Message_Constants { - public static readonly Dictionary LIKES = new Dictionary() { + internal static readonly Dictionary LIKES = new Dictionary() { { "large", EmojiSize.LARGE }, { "medium", EmojiSize.MEDIUM }, { "small", EmojiSize.SMALL }, @@ -52,6 +52,9 @@ public class FB_Message_Constants { "s", EmojiSize.SMALL } }; + /// + /// Possible reactions to send. See FB_Message.react + /// public static readonly List SENDABLE_REACTIONS = new List() { "❤", "😍", "😆", "😮", "😢", "😠", "👍", "👎" }; @@ -93,7 +96,7 @@ private string __unicode__() return string.Format("", this.thread_id, this.offset, this.length); } - public static FB_Mention _from_range(JToken data) + internal static FB_Mention _from_range(JToken data) { return new FB_Mention( thread_id: data?.get("entity")?.get("id")?.Value(), @@ -102,7 +105,7 @@ public static FB_Mention _from_range(JToken data) ); } - public static FB_Mention _from_prng(JToken data) + internal static FB_Mention _from_prng(JToken data) { return new FB_Mention( thread_id: data?.get("i")?.Value(), @@ -111,7 +114,7 @@ public static FB_Mention _from_prng(JToken data) ); } - public Dictionary _to_send_data(int i) + internal Dictionary _to_send_data(int i) { var data = new Dictionary(); data[string.Format("profile_xmd[{0}][id]", i)] = this.thread_id; @@ -232,14 +235,14 @@ public static FB_Message formatMentions(string text) throw new NotImplementedException(); } - public static bool _get_forwarded_from_tags(List tags) + internal static bool _get_forwarded_from_tags(List tags) { if (tags == null) return false; return tags.Any((tag) => tag.Contains("forward") || tag.Contains("copy")); } - public Dictionary _to_send_data() + internal Dictionary _to_send_data() { var data = new Dictionary(); @@ -319,7 +322,7 @@ public static async Task _from_fetch(FB_Thread thread, string mid) return FB_Message._from_graphql(message_info, thread); } - public static FB_Message _from_graphql(JToken data, FB_Thread thread, JToken read_receipts = null) + internal static FB_Message _from_graphql(JToken data, FB_Thread thread, JToken read_receipts = null) { if (data["message_sender"] == null) data["message_sender"] = new JObject(new JProperty("id", 0)); @@ -397,7 +400,7 @@ public static FB_Message _from_graphql(JToken data, FB_Thread thread, JToken rea return rtn; } - public static FB_Message _from_reply(JToken data, FB_Thread thread) + internal static FB_Message _from_reply(JToken data, FB_Thread thread) { var tags = data.get("messageMetadata")?.get("tags")?.ToObject>(); @@ -450,7 +453,7 @@ public static FB_Message _from_reply(JToken data, FB_Thread thread) return rtn; } - public static FB_Message _from_pull(JToken data, FB_Thread thread, string author = null, string timestamp = null) + internal static FB_Message _from_pull(JToken data, FB_Thread thread, string author = null, string timestamp = null) { var metadata = data?.get("messageMetadata"); var tags = metadata?.get("tags")?.ToObject>(); @@ -618,7 +621,7 @@ public FB_Message_Snippet(Session session, string uid = null, string text = null this.matched_keywords = matched_keywords; } - public static FB_Message_Snippet _parse(JToken data, FB_Thread thread) + internal static FB_Message_Snippet _parse(JToken data, FB_Thread thread) { return new FB_Message_Snippet( session: thread.session, diff --git a/fbchat-sharp/API/Models/Plan.cs b/fbchat-sharp/API/Models/Plan.cs index 50f4845..a0abb59 100644 --- a/fbchat-sharp/API/Models/Plan.cs +++ b/fbchat-sharp/API/Models/Plan.cs @@ -12,10 +12,7 @@ public enum GuestStatus DECLINED = 3 } - /// - /// - /// - public class FB_Plan_Constants + internal class FB_Plan_Constants { public static readonly Dictionary GUESTS = new Dictionary() { { "INVITED", GuestStatus.INVITED }, @@ -96,7 +93,7 @@ public List invited } } - public static FB_Plan _from_pull(JToken data, Session session) + internal static FB_Plan _from_pull(JToken data, Session session) { FB_Plan rtn = new FB_Plan( session: session, @@ -113,7 +110,7 @@ public static FB_Plan _from_pull(JToken data, Session session) return rtn; } - public static FB_Plan _from_fetch(JToken data, Session session) + internal static FB_Plan _from_fetch(JToken data, Session session) { FB_Plan rtn = new FB_Plan( session: session, @@ -130,7 +127,7 @@ public static FB_Plan _from_fetch(JToken data, Session session) return rtn; } - public static FB_Plan _from_graphql(JToken data, Session session) + internal static FB_Plan _from_graphql(JToken data, Session session) { FB_Plan rtn = new FB_Plan( session: session, diff --git a/fbchat-sharp/API/Models/Poll.cs b/fbchat-sharp/API/Models/Poll.cs index 2ceeb10..3aa7ba1 100644 --- a/fbchat-sharp/API/Models/Poll.cs +++ b/fbchat-sharp/API/Models/Poll.cs @@ -38,7 +38,7 @@ public FB_Poll(Session session, string uid = null, string title = null, List voters this.uid = uid; } - public static FB_PollOption _from_graphql(JToken data) + internal static FB_PollOption _from_graphql(JToken data) { bool vote = false; if (data.get("viewer_has_voted") == null) diff --git a/fbchat-sharp/API/Models/QuickReply.cs b/fbchat-sharp/API/Models/QuickReply.cs index a931084..bbcff47 100644 --- a/fbchat-sharp/API/Models/QuickReply.cs +++ b/fbchat-sharp/API/Models/QuickReply.cs @@ -44,7 +44,7 @@ public FB_QuickReply(QuickReplyType? _type = null, JToken payload = null, JToken this.is_response = is_response; } - public static FB_QuickReply graphql_to_quick_reply(JToken q, bool is_response= false) + internal static FB_QuickReply graphql_to_quick_reply(JToken q, bool is_response= false) { FB_QuickReply rtn = null; var data = new Dictionary(); diff --git a/fbchat-sharp/API/Models/Sticker.cs b/fbchat-sharp/API/Models/Sticker.cs index 25342f9..ce30f01 100644 --- a/fbchat-sharp/API/Models/Sticker.cs +++ b/fbchat-sharp/API/Models/Sticker.cs @@ -29,11 +29,15 @@ public class FB_Sticker : FB_Attachment /// The sticker's label/name public string label { get; set; } + /// + /// Represents a Facebook sticker that has been sent to a Facebook thread as an attachment + /// + /// public FB_Sticker(string uid = null) : base(uid) { } - public static FB_Sticker _from_graphql(JToken data) + internal static FB_Sticker _from_graphql(JToken data) { if (data == null) { diff --git a/fbchat-sharp/API/Session.cs b/fbchat-sharp/API/Session.cs index 3b08021..a79a5f9 100644 --- a/fbchat-sharp/API/Session.cs +++ b/fbchat-sharp/API/Session.cs @@ -269,6 +269,10 @@ private async Task _do_refresh() } } + /// + /// Get session coookies + /// + /// public Dictionary> get_cookies() { return this._session.GetAllCookies(); @@ -345,6 +349,14 @@ private Dictionary get_params() return payload; } + /// + /// Logins using username and password + /// + /// + /// + /// + /// + /// public async static Task login(string email, string password, Func> on_2fa_callback, string user_agent = null) { var session = new Session(user_agent); @@ -394,6 +406,10 @@ public async static Task login(string email, string password, Func + /// Returns logged in status + /// + /// public async Task is_logged_in() { // Send a request to the login url, to see if we're directed to the home page @@ -402,6 +418,10 @@ public async Task is_logged_in() || (r.Headers.Contains("Location") && is_home(r.Headers.Location.ToString())); } + /// + /// Logouts current user + /// + /// public async Task logout() { var url = Utils.prefix_url("/bluebar/modern_settings_menu/"); @@ -423,6 +443,12 @@ public async Task logout() return r.IsSuccessStatusCode; } + /// + /// Build session from saved cookies + /// + /// + /// + /// public async static Task from_cookies(Dictionary> session_cookies, string user_agent) { var session = new Session(user_agent: user_agent); diff --git a/fbchat-sharp/API/Threads/Group.cs b/fbchat-sharp/API/Threads/Group.cs index 2b0387f..08d5ad2 100644 --- a/fbchat-sharp/API/Threads/Group.cs +++ b/fbchat-sharp/API/Threads/Group.cs @@ -70,7 +70,7 @@ public FB_Group(string uid, Session session) : } - public static FB_Group _from_graphql(Session session, JToken data) + internal static FB_Group _from_graphql(Session session, JToken data) { if (data.get("image") == null) data["image"] = new JObject(new JProperty("uri", "")); @@ -96,7 +96,7 @@ public static FB_Group _from_graphql(Session session, JToken data) plan: plan); } - public override Dictionary _to_send_data() + internal override Dictionary _to_send_data() { return new Dictionary() { { "thread_fbid", this.uid } }; } diff --git a/fbchat-sharp/API/Threads/Marketplace.cs b/fbchat-sharp/API/Threads/Marketplace.cs index 169123d..bd10823 100644 --- a/fbchat-sharp/API/Threads/Marketplace.cs +++ b/fbchat-sharp/API/Threads/Marketplace.cs @@ -68,7 +68,7 @@ public FB_Marketplace(string uid, Session session) : } - public static FB_Marketplace _from_graphql(Session session, JToken data) + internal static FB_Marketplace _from_graphql(Session session, JToken data) { if (data.get("image") == null) data["image"] = new JObject(new JProperty("uri", "")); @@ -94,7 +94,7 @@ public static FB_Marketplace _from_graphql(Session session, JToken data) plan: plan); } - public override Dictionary _to_send_data() + internal override Dictionary _to_send_data() { return new Dictionary() { { "thread_fbid", this.uid } }; } diff --git a/fbchat-sharp/API/Threads/Page.cs b/fbchat-sharp/API/Threads/Page.cs index 3559363..575a56b 100644 --- a/fbchat-sharp/API/Threads/Page.cs +++ b/fbchat-sharp/API/Threads/Page.cs @@ -53,7 +53,7 @@ public FB_Page(string uid, Session session) : } - public static FB_Page _from_graphql(Session session, JToken data) + internal static FB_Page _from_graphql(Session session, JToken data) { if (data.get("profile_picture") == null) data["profile_picture"] = new JObject(new JProperty("uri", "")); diff --git a/fbchat-sharp/API/Threads/Thread.cs b/fbchat-sharp/API/Threads/Thread.cs index a15e2d4..286ea60 100644 --- a/fbchat-sharp/API/Threads/Thread.cs +++ b/fbchat-sharp/API/Threads/Thread.cs @@ -46,7 +46,7 @@ public class ThreadColor public const string DARK_TANGERINE = "#ff9c19"; public const string BRIGHT_TURQUOISE = "#0edcde"; - public static string _from_graphql(JToken data) + internal static string _from_graphql(JToken data) { if (data == null) return null; @@ -105,7 +105,7 @@ public FB_Thread(string uid, Session session, FB_Image photo = null, string name this.plan = plan; } - public static FB_Thread _from_metadata(JToken msg_metadata, Session session) + internal static FB_Thread _from_metadata(JToken msg_metadata, Session session) { /*Returns a tuple consisting of thread ID and thread type*/ string id_thread = null; @@ -122,7 +122,7 @@ public static FB_Thread _from_metadata(JToken msg_metadata, Session session) return new FB_User(id_thread, session); } - public static IEnumerable _parse_participants(JToken data, Session session) + internal static IEnumerable _parse_participants(JToken data, Session session) { foreach (var node in data?.get("nodes")) { @@ -145,7 +145,7 @@ public static IEnumerable _parse_participants(JToken data, Session se } } - public static Dictionary _parse_customization_info(JToken data) + internal static Dictionary _parse_customization_info(JToken data) { var rtn = new Dictionary(); if (data == null || data.get("customization_info") == null) @@ -186,13 +186,13 @@ public static Dictionary _parse_customization_info(JToken data) return rtn; } - public virtual Dictionary _to_send_data() + internal virtual Dictionary _to_send_data() { // TODO: Only implement this in subclasses return new Dictionary() { { "other_user_fbid", this.uid } }; } - public async Task _forcedFetch(string mid) + internal async Task _forcedFetch(string mid) { var param = new Dictionary() { { "thread_and_message_id", new Dictionary() { { "thread_id", this.uid }, { "message_id", mid } } } }; return await this.session.graphql_request(GraphQL.from_doc_id("1768656253222505", param)); @@ -388,7 +388,7 @@ private async Task _sendFiles( return await this.session._do_send_request(data); } - public async Task<(int count, IEnumerable snippets)> _search_messages(string query, int offset = 0, int limit = 5) + private async Task<(int count, IEnumerable snippets)> _search_messages(string query, int offset = 0, int limit = 5) { var data = new Dictionary() { { "query", query }, @@ -902,8 +902,7 @@ public async Task setTypingStatus(bool status) /// /// Mark a thread as spam and delete it /// - /// true - public async Task markAsSpam() + public async Task markAsSpam() { /* * Mark a thread as spam and delete it @@ -911,7 +910,6 @@ public async Task markAsSpam() * :raises: FBchatException if request failed * */ var j = await this.session._payload_post("/ajax/mercury/mark_spam.php?dpr=1", new Dictionary() { { "id", this.uid } }); - return true; } /// diff --git a/fbchat-sharp/API/Threads/User.cs b/fbchat-sharp/API/Threads/User.cs index 2f8e243..a7f407a 100644 --- a/fbchat-sharp/API/Threads/User.cs +++ b/fbchat-sharp/API/Threads/User.cs @@ -123,7 +123,7 @@ private string __unicode__() return string.Format("<{0} {1} {2} ({3})>", this.GetType().Name, this.first_name, this.last_name, this.uid); } - public static FB_User _from_graphql(Session session, JToken data) + internal static FB_User _from_graphql(Session session, JToken data) { var c_info = FB_User._parse_customization_info(data); @@ -167,7 +167,7 @@ public static FB_User _from_graphql(Session session, JToken data) plan: plan); } - public static FB_User _from_thread_fetch(Session session, JToken data) + internal static FB_User _from_thread_fetch(Session session, JToken data) { var c_info = FB_User._parse_customization_info(data); var participants = data.get("all_participants")?.get("nodes")?.Select(node => node.get("messaging_actor")); @@ -215,7 +215,7 @@ public static FB_User _from_thread_fetch(Session session, JToken data) plan: plan); } - public static FB_User _from_all_fetch(Session session, JToken data) + internal static FB_User _from_all_fetch(Session session, JToken data) { var gender = GENDER.graphql_GENDERS["UNKNOWN"]; if (data.get("gender")?.Type == JTokenType.Integer) @@ -257,8 +257,7 @@ public async Task confirmFriendRequest() /// /// Removes a specifed friend from your friend list /// - /// true - public async Task removeFriend() + public async Task removeFriend() { /* * Removes a specifed friend from your friend list @@ -268,14 +267,12 @@ public async Task removeFriend() * */ var data = new Dictionary { { "uid", this.uid } }; var j = await this.session._payload_post("/ajax/profile/removefriendconfirm.php", data); - return true; } /// /// Blocks messages from a specifed user /// - /// true - public async Task block() + public async Task block() { /* * Blocks messages from a specifed user @@ -285,14 +282,13 @@ public async Task block() * */ var data = new Dictionary { { "fbid", this.uid } }; var j = await this.session._payload_post("/messaging/block_messages/?dpr=1", data); - return true; } /// /// The ID of the user that you want to block /// /// Whether the request was successful - public async Task unblock() + public async Task unblock() { /* * Unblocks messages from a blocked user @@ -302,7 +298,6 @@ public async Task unblock() * */ var data = new Dictionary { { "fbid", this.uid } }; var j = await this.session._payload_post("/messaging/unblock_messages/?dpr=1", data); - return true; } } @@ -324,14 +319,14 @@ public class FB_ActiveStatus /// /// /// - public FB_ActiveStatus(bool active = false, string last_active = null, bool in_game = false) + internal FB_ActiveStatus(bool active = false, string last_active = null, bool in_game = false) { this.active = active; this.last_active = last_active; this.in_game = in_game; } - public static FB_ActiveStatus _from_chatproxy_presence(string id_, JToken data) + internal static FB_ActiveStatus _from_chatproxy_presence(string id_, JToken data) { return new FB_ActiveStatus( active: new int[] { 2, 3 }.Contains(data.get("p")?.Value() ?? 0), @@ -339,7 +334,7 @@ public static FB_ActiveStatus _from_chatproxy_presence(string id_, JToken data) in_game: data.get("gamers")?.ToObject>()?.Contains(id_) ?? false); } - public static FB_ActiveStatus _from_buddylist_overlay(JToken data, bool in_game = false) + internal static FB_ActiveStatus _from_buddylist_overlay(JToken data, bool in_game = false) { return new FB_ActiveStatus( active: new int[] { 2, 3 }.Contains(data.get("a")?.Value() ?? 0), @@ -347,7 +342,7 @@ public static FB_ActiveStatus _from_buddylist_overlay(JToken data, bool in_game in_game: in_game); } - public static FB_ActiveStatus _from_buddylist_update(JToken data) + internal static FB_ActiveStatus _from_buddylist_update(JToken data) { return new FB_ActiveStatus( active: new int[] { 0 }.Contains(data.get("status")?.Value() ?? -1), @@ -355,7 +350,7 @@ public static FB_ActiveStatus _from_buddylist_update(JToken data) in_game: false); } - public static FB_ActiveStatus _from_orca_presence(JToken data, bool in_game = false) + internal static FB_ActiveStatus _from_orca_presence(JToken data, bool in_game = false) { return new FB_ActiveStatus( active: new int[] { 2, 3 }.Contains(data.get("p")?.Value() ?? 0),