Skip to content

Commit

Permalink
Made a lot of methods internal
Browse files Browse the repository at this point in the history
  • Loading branch information
gave92 committed Feb 10, 2020
1 parent 15eb7ca commit f1f8eb3
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 87 deletions.
18 changes: 5 additions & 13 deletions fbchat-sharp/API/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace fbchat_sharp.API
/// <summary>
///
/// </summary>
public class Client_Constants
internal class Client_Constants
{
public static readonly Dictionary<string, object> ACONTEXT = new Dictionary<string, object>()
{
Expand Down Expand Up @@ -785,8 +785,7 @@ public async Task<List<string>> fetchActiveUsers()
/// </summary>
/// <param name="thread_id">User/Group ID to which the message belongs.See :ref:`intro_threads`</param>
/// <param name="message_id">Message ID to set as delivered.See :ref:`intro_threads`</param>
/// <returns>true</returns>
public async Task<bool> markAsDelivered(string thread_id, string message_id)
public async Task markAsDelivered(string thread_id, string message_id)
{
/*
* Mark a message as delivered
Expand All @@ -800,7 +799,6 @@ public async Task<bool> 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<string> thread_ids, long? timestamp = null)
Expand Down Expand Up @@ -868,8 +866,7 @@ public async Task markAsSeen()
/// </summary>
/// <param name="location">ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER</param>
/// <param name="thread_ids">Thread IDs to move.See :ref:`intro_threads`</param>
/// <returns>true</returns>
public async Task<bool> moveThreads(string location, List<string> thread_ids)
public async Task moveThreads(string location, List<string> thread_ids)
{
/*
* Moves threads to specifed location
Expand Down Expand Up @@ -906,15 +903,13 @@ public async Task<bool> moveThreads(string location, List<string> 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;
}

/// <summary>
/// Deletes threads
/// </summary>
/// <param name="thread_ids">Thread IDs to delete. See :ref:`intro_threads`</param>
/// <returns>true</returns>
public async Task<bool> deleteThreads(List<string> thread_ids)
public async Task deleteThreads(List<string> thread_ids)
{
/*
* Deletes threads
Expand All @@ -937,15 +932,13 @@ public async Task<bool> deleteThreads(List<string> thread_ids)
var j_delete = this._session._payload_post(
"/ajax/mercury/delete_thread.php?dpr=1", data_delete
);
return true;
}

/// <summary>
/// Deletes specifed messages
/// </summary>
/// <param name="message_ids">Message IDs to delete</param>
/// <returns>true</returns>
public async Task<bool> deleteMessages(List<string> message_ids)
public async Task deleteMessages(List<string> message_ids)
{
/*
* Deletes specifed messages
Expand All @@ -958,7 +951,6 @@ public async Task<bool> deleteMessages(List<string> 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

Expand Down
4 changes: 2 additions & 2 deletions fbchat-sharp/API/Events/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>());
Expand All @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions fbchat-sharp/API/Exception.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public FBchatParseError(string message, JToken data = null) : base(message)
this.Data.Add("data", data);
}

/// <summary>
/// Returns a string representation of the current exception.
/// </summary>
/// <returns></returns>
public override string ToString()
{
var msg = "{0}. Please report this, along with the data below!\n{1}";
Expand Down
2 changes: 1 addition & 1 deletion fbchat-sharp/API/GraphQl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace fbchat_sharp.API
{
public class GraphQL : Dictionary<string, object>
internal class GraphQL : Dictionary<string, object>
{
public static string queries_to_json(List<GraphQL> queries)
{
Expand Down
11 changes: 7 additions & 4 deletions fbchat-sharp/API/Models/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace fbchat_sharp.API
/// </summary>
public class FB_Attachment
{
/// <summary>
/// Unique id of the attachmnt.
/// </summary>
public string uid { get; set; }

/// <summary>
Expand All @@ -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<string>();
if (new string[] { "MessageImage", "MessageAnimatedImage" }.Contains(_type))
Expand All @@ -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<string>() : null;
Expand All @@ -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)
Expand Down Expand Up @@ -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<string>();
FB_ShareAttachment rtn = new FB_ShareAttachment(
Expand Down
20 changes: 13 additions & 7 deletions fbchat-sharp/API/Models/File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public class FB_File
/// Local or remote file type
public string mimetype { get; set; }

/// <summary>
/// Facebook messenger file class
/// </summary>
/// <param name="data"></param>
/// <param name="path"></param>
/// <param name="mimetype"></param>
public FB_File(Stream data = null, string path = null, string mimetype = null)
{
this.data = data;
Expand Down Expand Up @@ -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<string>(),
Expand Down Expand Up @@ -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<string>(),
Expand Down Expand Up @@ -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<string>() ?? data.get("filename")?.Value<string>()?.Split('-')[0],
Expand All @@ -170,7 +176,7 @@ public static FB_ImageAttachment _from_graphql(JToken data)
uid: data.get("legacy_attachment_id")?.Value<string>());
}

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<int>() ?? 0,
Expand Down Expand Up @@ -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<int>() ?? 0,
Expand All @@ -243,7 +249,7 @@ public static FB_VideoAttachment _from_graphql(JToken data)
uid: data.get("legacy_attachment_id")?.Value<string>());
}

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<int>() ?? 0,
Expand All @@ -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(
Expand Down
11 changes: 7 additions & 4 deletions fbchat-sharp/API/Models/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace fbchat_sharp.API
{
/// <summary>
/// Represents a facebook image.
/// </summary>
public class FB_Image
{
/// URL to the image
Expand All @@ -21,28 +24,28 @@ 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<int>() ?? 0,
image_height: data?.get("height")?.Value<int>() ?? 0,
url: data?.get("uri")?.Value<string>());
}

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<int>() ?? 0,
image_height: data?.get("height")?.Value<int>() ?? 0,
url: data?.get("url")?.Value<string>());
}

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;
}
Expand Down
6 changes: 3 additions & 3 deletions fbchat-sharp/API/Models/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
var address = Utils.get_url_parameter(Utils.get_url_parameter(url, "u"), "where1");
Expand Down Expand Up @@ -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<string>(),
Expand All @@ -116,7 +116,7 @@ public static FB_LiveLocationAttachment _from_pull(JToken data)
is_expired: data.get("stopReason")?.Value<bool>() ?? 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(
Expand Down
Loading

0 comments on commit f1f8eb3

Please sign in to comment.