Skip to content

Commit

Permalink
Merge pull request #97 from mvdicarlo/develop
Browse files Browse the repository at this point in the history
v2.3.36
  • Loading branch information
mvdicarlo authored Aug 14, 2021
2 parents 684b84c + 2b4c3d3 commit 56a2324
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb",
"version": "2.3.35",
"version": "2.3.36",
"description": "PostyBirb is an application that helps artists post art and other multimedia to multiple websites more quickly.",
"main": "main.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb",
"version": "2.3.35",
"version": "2.3.36",
"scripts": {
"ng": "ng",
"compile": "ng build --vendor-chunk=false",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@ export class FurAffinity extends BaseWebsiteService implements WebsiteService {
}
}

private processForError(body: string): string | undefined {
if (body.includes('redirect-message')) {
const body$ = $.parseHTML(body);
const msg = $(body$).find('.redirect-message').first().text();
return msg;
}

return undefined;
}

private async postSubmission(
submission: Submission,
postData: SubmissionPostData
Expand All @@ -307,13 +317,10 @@ export class FurAffinity extends BaseWebsiteService implements WebsiteService {
);

const part1Body = part1Response.body;
if (part1Body.includes('Flood protection')) {
return Promise.reject(
this.createPostResponse(
'Encountered flood protection',
`Flood Protection\n\n${part1Body.body}`
)
);
let err = this.processForError(part1Body);

if (err) {
return Promise.reject(this.createPostResponse(err, part1Body));
}

const part2Data = {
Expand All @@ -339,12 +346,10 @@ export class FurAffinity extends BaseWebsiteService implements WebsiteService {
return Promise.reject(this.createPostResponse('Unknown error', uploadResponse.error));
} else {
const uploadBody = uploadResponse.success.body;
if (uploadBody.includes('Flood protection')) {
return Promise.reject(this.createPostResponse('Encountered flood protection', {}));
}
err = this.processForError(uploadBody);

if (uploadBody.includes('pageid-error') || !uploadBody.includes('pageid-submit-finalize')) {
return Promise.reject(this.createPostResponse('Unknown error', uploadBody));
if (err) {
return Promise.reject(this.createPostResponse(err, uploadBody));
}

const options = postData.options || {};
Expand All @@ -362,8 +367,7 @@ export class FurAffinity extends BaseWebsiteService implements WebsiteService {
};

if (postData.typeOfSubmission !== TypeOfSubmission.ART) {
delete finalizeData.cat;
finalizeData.cat_duplicate = this.getContentCategory(postData.typeOfSubmission);
finalizeData.cat = this.getContentCategory(postData.typeOfSubmission);
}

if (options.disableComments) finalizeData.lock_comments = 'on';
Expand All @@ -389,19 +393,13 @@ export class FurAffinity extends BaseWebsiteService implements WebsiteService {
const body = postResponse.success.body;

if (!postResponse.success.response.request.uri.href.includes('?upload-successful')) {
if (body.includes('CAPTCHA verification error')) {
return Promise.reject(
this.createPostResponse('You must have 10+ posts on your account first', body)
);
}

if (body.includes('pageid-submit-finalize')) {
return Promise.reject(this.createPostResponse('Unknown error', body));
}

if (postResponse.success.response.request.uri.href.includes('/submit')) {
return Promise.reject(this.createPostResponse('Something went wrong', body));
err = this.processForError(body);

if (err) {
return Promise.reject(this.createPostResponse(err, body));
}

return Promise.reject(this.createPostResponse('Unknown error', body));
}

try {
Expand All @@ -423,7 +421,10 @@ export class FurAffinity extends BaseWebsiteService implements WebsiteService {
console.error(e);
} finally {
const res = this.createPostResponse(null);
res.srcURL = postResponse.success.response.request.uri.href.replace('?upload-successful', '');
res.srcURL = postResponse.success.response.request.uri.href.replace(
'?upload-successful',
''
);
return res;
}
}
Expand Down

0 comments on commit 56a2324

Please sign in to comment.