Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I've added a few useful lines #202

Merged
merged 5 commits into from
Oct 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions InstaSharper/API/InstaApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,9 @@ public async Task<IResult<InstaResetChallenge>> SendVerifyCode(string securityCo
}
var sendVerifyCodeResponse = JsonConvert.DeserializeObject<InstaResetChallenge>(json);
IsUserAuthenticated = sendVerifyCodeResponse.LoggedInUser?.UserName.ToLower() == _user.UserName.ToLower();
var converter = ConvertersFabric.Instance.GetUserShortConverter(sendVerifyCodeResponse.LoggedInUser);
_user.LoggedInUder = converter.Convert();
_user.RankToken = $"{_user.LoggedInUder.Pk}_{_httpRequestProcessor.RequestMessage.phone_id}";
return Result.Success(sendVerifyCodeResponse);
}

Expand Down
8 changes: 7 additions & 1 deletion InstaSharper/Classes/ResponseType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ public enum ResponseType
SomePagesSkipped = 7,
UnExpectedResponse = 8,
InternalException = 9,
CheckPointChallengeRequired = 10
CheckPointChallengeRequired = 10,
Spam = 11,
ActionBlocked = 12,
DeletedPost = 13,
TemporarilyBlocked = 14,
CantLikeMedia = 15,
InvalidChallengeCode = 16,
}
}
15 changes: 13 additions & 2 deletions InstaSharper/Classes/ResponseWrappers/BadStatusResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ public class BadStatusResponse : BaseStatusResponse
{
[JsonProperty("message")] public string Message { get; set; }

[JsonProperty("error_type")]
public string ErrorType { get; set; } = "unknown";
[JsonProperty("error_type")] public string ErrorType { get; set; } = "unknown";

[JsonProperty("checkpoint_url")] public string CheckPointUrl { get; set; }

[JsonProperty("spam")] public bool Spam { get; set; }

[JsonProperty("feedback_title")] public string FeedbackTitle { get; set; }

[JsonProperty("feedback_message")] public string FeedbackMessage { get; set; }

[JsonProperty("feedback_appeal_label")] public string FeedbackAppealLabel { get; set; }

[JsonProperty("feedback_action")] public string FeedbackAction { get; set; }

[JsonProperty("feedback_ignore_label")] public string FeedbackIgnoreLabel { get; set; }
}
}
34 changes: 34 additions & 0 deletions InstaSharper/Classes/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,40 @@ public static IResult<T> UnExpectedResponse<T>(HttpResponseMessage response, str
break;
}

if (status.Spam) responseType = ResponseType.Spam;
switch (status.FeedbackTitle)
{
// feedback_message: This action was blocked. Please try again later.
// We restrict certain content and actions to protect our community.
// Tell us if you think we made a mistake.
case "Action Blocked":
responseType = ResponseType.ActionBlocked;
break;
// feedback_message: It looks like you were misusing this feature by going too fast.
// You’ve been temporarily blocked from using it. We restrict certain content and actions
// to protect our community. Tell us if you think we made a mistake.
case "You’re Temporarily Blocked":
responseType = ResponseType.TemporarilyBlocked;
break;
}

switch (status.FeedbackMessage)
{
case "The post you were viewing has been deleted.":
responseType = ResponseType.DeletedPost;
break;
}

switch (status.Message)
{
case "Sorry, you cannot like this media":
responseType = ResponseType.CantLikeMedia;
break;
case "Please check the code we sent you and try again.":
responseType = ResponseType.InvalidChallengeCode;
break;
}

if (!status.IsOk() && status.Message.Contains("wait a few minutes"))
responseType = ResponseType.RequestsLimit;

Expand Down