commit
cdc38419a2
|
|
@ -63,7 +63,7 @@ export class IntegrationRepository {
|
|||
createOrUpdateIntegration(
|
||||
org: string,
|
||||
name: string,
|
||||
picture: string,
|
||||
picture: string | undefined,
|
||||
type: 'article' | 'social',
|
||||
internalId: string,
|
||||
provider: string,
|
||||
|
|
@ -98,7 +98,7 @@ export class IntegrationRepository {
|
|||
providerIdentifier: provider,
|
||||
token,
|
||||
profile: username,
|
||||
picture,
|
||||
...(picture ? { picture } : {}),
|
||||
inBetweenSteps: isBetweenSteps,
|
||||
refreshToken,
|
||||
...(expiresIn
|
||||
|
|
@ -117,7 +117,7 @@ export class IntegrationRepository {
|
|||
inBetweenSteps: isBetweenSteps,
|
||||
}
|
||||
: {}),
|
||||
picture,
|
||||
...(picture ? { picture } : {}),
|
||||
profile: username,
|
||||
providerIdentifier: provider,
|
||||
token,
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import {
|
|||
HttpException,
|
||||
HttpStatus,
|
||||
Injectable,
|
||||
Param,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { IntegrationRepository } from '@gitroom/nestjs-libraries/database/prisma/integrations/integration.repository';
|
||||
import { IntegrationManager } from '@gitroom/nestjs-libraries/integrations/integration.manager';
|
||||
|
|
@ -13,9 +11,6 @@ import { AnalyticsData, SocialProvider } from '@gitroom/nestjs-libraries/integra
|
|||
import { Integration, Organization } from '@prisma/client';
|
||||
import { NotificationService } from '@gitroom/nestjs-libraries/database/prisma/notifications/notification.service';
|
||||
import { LinkedinPageProvider } from '@gitroom/nestjs-libraries/integrations/social/linkedin.page.provider';
|
||||
import { simpleUpload } from '@gitroom/nestjs-libraries/upload/r2.uploader';
|
||||
import axios from 'axios';
|
||||
import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
|
||||
import dayjs from 'dayjs';
|
||||
import { timer } from '@gitroom/helpers/utils/timer';
|
||||
import { ioRedis } from '@gitroom/nestjs-libraries/redis/redis.service';
|
||||
|
|
@ -39,7 +34,7 @@ export class IntegrationService {
|
|||
async createOrUpdateIntegration(
|
||||
org: string,
|
||||
name: string,
|
||||
picture: string,
|
||||
picture: string | undefined,
|
||||
type: 'article' | 'social',
|
||||
internalId: string,
|
||||
provider: string,
|
||||
|
|
@ -52,7 +47,7 @@ export class IntegrationService {
|
|||
timezone?: number,
|
||||
customInstanceDetails?: string
|
||||
) {
|
||||
const uploadedPicture = await this.storage.uploadSimple(picture);
|
||||
const uploadedPicture = picture ? await this.storage.uploadSimple(picture) : undefined;
|
||||
return this._integrationRepository.createOrUpdateIntegration(
|
||||
org,
|
||||
name,
|
||||
|
|
@ -151,7 +146,7 @@ export class IntegrationService {
|
|||
await this.createOrUpdateIntegration(
|
||||
integration.organizationId,
|
||||
integration.name,
|
||||
integration.picture!,
|
||||
undefined,
|
||||
'social',
|
||||
integration.internalId,
|
||||
integration.providerIdentifier,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
|
|||
},
|
||||
} = await (
|
||||
await fetch(
|
||||
'https://open.tiktokapis.com/v2/user/info/?fields=open_id,avatar_url,display_name,username',
|
||||
'https://open.tiktokapis.com/v2/user/info/?fields=open_id,avatar_url,display_name,union_id,username',
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
|
|
@ -102,10 +102,11 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
|
|||
code: params.code,
|
||||
grant_type: 'authorization_code',
|
||||
code_verifier: params.codeVerifier,
|
||||
redirect_uri:
|
||||
process.env.NODE_ENV === 'development' || !process.env.NODE_ENV
|
||||
? `https://integration.git.sn/integrations/social/tiktok`
|
||||
: `${process.env.FRONTEND_URL}/integrations/social/tiktok`,
|
||||
redirect_uri: `${
|
||||
process?.env?.FRONTEND_URL?.indexOf('https') === -1
|
||||
? 'https://redirectmeto.com/'
|
||||
: ''
|
||||
}${process?.env?.FRONTEND_URL}/integrations/social/tiktok`
|
||||
};
|
||||
|
||||
const { access_token, refresh_token, scope } = await (
|
||||
|
|
@ -118,6 +119,7 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
|
|||
})
|
||||
).json();
|
||||
|
||||
console.log(this.scopes, scope);
|
||||
this.checkScopes(this.scopes, scope);
|
||||
|
||||
const {
|
||||
|
|
|
|||
Loading…
Reference in New Issue