feat: fix refresh token

This commit is contained in:
Nevo David 2026-01-05 18:38:17 +07:00
parent 0144e39841
commit 204739f049
3 changed files with 18 additions and 2 deletions

View File

@ -194,7 +194,7 @@ export async function postWorkflow({
`Error posting on ${post.integration?.providerIdentifier} for ${post?.integration?.name}`,
`An error occurred while posting on ${
post.integration?.providerIdentifier
}${err?.message ? `: ${err?.message}` : ``}`,
}${err?.cause?.message ? `: ${err?.cause?.message}` : ``}`,
true,
false,
'fail'

View File

@ -63,10 +63,18 @@ export abstract class SocialAbstract {
value = await func();
} catch (err) {
const handle = this.handleErrors(JSON.stringify(err));
value = { err: true, ...(handle || {}) };
value = { err: true, value: 'Unknown Error', ...(handle || {}) };
}
if (value && value?.err && value?.value) {
if (value.type === 'refresh-token') {
throw new RefreshToken(
'',
JSON.stringify({}),
{} as any,
value.value || ''
);
}
throw new BadBody('', JSON.stringify({}), {} as any, value.value || '');
}

View File

@ -117,6 +117,14 @@ export class YoutubeProvider extends SocialAbstract implements SocialProvider {
};
}
if (body.includes('Unauthorized')) {
return {
type: 'refresh-token',
value:
'Token expired or invalid, please reconnect your YouTube account.',
};
}
return undefined;
}