feat: wait integration
This commit is contained in:
parent
c6c1c10912
commit
63ebcad3bd
|
|
@ -17,6 +17,7 @@ import { IntegrationService } from '@gitroom/nestjs-libraries/database/prisma/in
|
|||
import { IntegrationManager } from '@gitroom/nestjs-libraries/integrations/integration.manager';
|
||||
import { ioRedis } from '@gitroom/nestjs-libraries/redis/redis.service';
|
||||
import { RefreshToken } from '@gitroom/nestjs-libraries/integrations/social.abstract';
|
||||
import { timer } from '@gitroom/helpers/utils/timer';
|
||||
|
||||
@ApiTags('Analytics')
|
||||
@Controller('/analytics')
|
||||
|
|
@ -96,6 +97,10 @@ export class AnalyticsController {
|
|||
);
|
||||
|
||||
getIntegration.token = accessToken;
|
||||
|
||||
if (integrationProvider.refreshWait) {
|
||||
await timer(10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,12 @@ import { OpenaiService } from '@gitroom/nestjs-libraries/openai/openai.service';
|
|||
import { CreateGeneratedPostsDto } from '@gitroom/nestjs-libraries/dtos/generator/create.generated.posts.dto';
|
||||
import { IntegrationService } from '@gitroom/nestjs-libraries/database/prisma/integrations/integration.service';
|
||||
import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
|
||||
import { BadBody, RefreshToken } from '@gitroom/nestjs-libraries/integrations/social.abstract';
|
||||
import {
|
||||
BadBody,
|
||||
RefreshToken,
|
||||
} from '@gitroom/nestjs-libraries/integrations/social.abstract';
|
||||
import { BullMqClient } from '@gitroom/nestjs-libraries/bull-mq-transport-new/client';
|
||||
import { timer } from '@gitroom/helpers/utils/timer';
|
||||
|
||||
type PostWithConditionals = Post & {
|
||||
integration?: Integration;
|
||||
|
|
@ -224,6 +228,10 @@ export class PostsService {
|
|||
);
|
||||
|
||||
integration.token = accessToken;
|
||||
|
||||
if (getIntegration.refreshWait) {
|
||||
await timer(10000);
|
||||
}
|
||||
}
|
||||
|
||||
const newPosts = await this.updateTags(integration.organizationId, posts);
|
||||
|
|
@ -279,8 +287,15 @@ export class PostsService {
|
|||
return this.postSocial(integration, posts, true);
|
||||
}
|
||||
|
||||
if (err instanceof BadBody && process.env.EMAIL_FROM_ADDRESS === 'nevo@postiz.com') {
|
||||
await this._notificationService.sendEmail('nevo@positz.com', 'Bad body', JSON.stringify(err.body));
|
||||
if (
|
||||
err instanceof BadBody &&
|
||||
process.env.EMAIL_FROM_ADDRESS === 'nevo@postiz.com'
|
||||
) {
|
||||
await this._notificationService.sendEmail(
|
||||
'nevo@positz.com',
|
||||
'Bad body',
|
||||
JSON.stringify(err.body)
|
||||
);
|
||||
}
|
||||
|
||||
throw err;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export class LinkedinPageProvider
|
|||
override identifier = 'linkedin-page';
|
||||
override name = 'LinkedIn Page';
|
||||
override isBetweenSteps = true;
|
||||
override refreshWait = true;
|
||||
override scopes = [
|
||||
'openid',
|
||||
'profile',
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
|
|||
name = 'LinkedIn';
|
||||
isBetweenSteps = false;
|
||||
scopes = ['openid', 'profile', 'w_member_social', 'r_basicprofile'];
|
||||
refreshWait = true;
|
||||
|
||||
async refreshToken(refresh_token: string): Promise<AuthTokenDetails> {
|
||||
const { access_token: accessToken, refresh_token: refreshToken, expires_in } = await (
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ export interface SocialProvider
|
|||
extends IAuthenticator,
|
||||
ISocialMediaIntegration {
|
||||
identifier: string;
|
||||
refreshWait?: boolean;
|
||||
name: string;
|
||||
isBetweenSteps: boolean;
|
||||
scopes: string[];
|
||||
|
|
|
|||
Loading…
Reference in New Issue