Skip to content

Commit b103641

Browse files
committed
Feature(self-hosted): Hide any integration which does not have required env variables setup
1 parent 8314cc5 commit b103641

22 files changed

+61
-14
lines changed

libraries/nestjs-libraries/src/integrations/integration.manager.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ export class IntegrationManager {
6464
async getAllIntegrations() {
6565
return {
6666
social: await Promise.all(
67-
socialIntegrationList.map(async (p) => ({
68-
name: p.name,
69-
identifier: p.identifier,
70-
toolTip: p.toolTip,
71-
isExternal: !!p.externalUrl,
72-
isWeb3: !!p.isWeb3,
73-
...(p.customFields ? { customFields: await p.customFields() } : {}),
74-
}))
67+
socialIntegrationList
68+
.filter((p) => p.available !== false)
69+
.map(async (p) => ({
70+
name: p.name,
71+
identifier: p.identifier,
72+
toolTip: p.toolTip,
73+
isExternal: !!p.externalUrl,
74+
isWeb3: !!p.isWeb3,
75+
...(p.customFields ? { customFields: await p.customFields() } : {}),
76+
}))
7577
),
7678
article: articleIntegrationList.map((p) => ({
7779
name: p.name,
@@ -82,6 +84,7 @@ export class IntegrationManager {
8284

8385
getAllPlugs() {
8486
return socialIntegrationList
87+
.filter((p) => p.available !== false)
8588
.map((p) => {
8689
return {
8790
name: p.name,

libraries/nestjs-libraries/src/integrations/social/bluesky.provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ async function reduceImageBySize(url: string, maxSizeKB = 976) {
5252
}
5353

5454
export class BlueskyProvider extends SocialAbstract implements SocialProvider {
55+
available = true;
5556
identifier = 'bluesky';
5657
name = 'Bluesky';
5758
isBetweenSteps = false;

libraries/nestjs-libraries/src/integrations/social/discord.provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
88
import { SocialAbstract } from '@gitroom/nestjs-libraries/integrations/social.abstract';
99

1010
export class DiscordProvider extends SocialAbstract implements SocialProvider {
11+
available = !!(
12+
process.env.DISCORD_CLIENT_ID && process.env.DISCORD_CLIENT_SECRET
13+
);
1114
identifier = 'discord';
1215
name = 'Discord';
1316
isBetweenSteps = false;

libraries/nestjs-libraries/src/integrations/social/dribbble.provider.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import { DribbbleDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-sett
1313
import mime from 'mime-types';
1414

1515
export class DribbbleProvider extends SocialAbstract implements SocialProvider {
16+
available = !!(
17+
process.env.PINTEREST_CLIENT_ID &&
18+
process.env.PINTEREST_CLIENT_SECRET &&
19+
process.env.DRIBBBLE_CLIENT_ID &&
20+
process.env.DRIBBBLE_CLIENT_SECRET
21+
);
1622
identifier = 'dribbble';
1723
name = 'Dribbble';
1824
isBetweenSteps = false;

libraries/nestjs-libraries/src/integrations/social/facebook.provider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import dayjs from 'dayjs';
1010
import { SocialAbstract } from '@gitroom/nestjs-libraries/integrations/social.abstract';
1111

1212
export class FacebookProvider extends SocialAbstract implements SocialProvider {
13+
available = !!(
14+
process.env.FACEBOOK_APP_ID && process.env.FACEBOOK_APP_SECRET
15+
);
1316
identifier = 'facebook';
1417
name = 'Facebook Page';
1518
isBetweenSteps = true;
@@ -297,7 +300,7 @@ export class FacebookProvider extends SocialAbstract implements SocialProvider {
297300
accessToken: string,
298301
date: number
299302
): Promise<AnalyticsData[]> {
300-
const until = dayjs().endOf('day').unix()
303+
const until = dayjs().endOf('day').unix();
301304
const since = dayjs().subtract(date, 'day').unix();
302305

303306
const { data } = await (

libraries/nestjs-libraries/src/integrations/social/farcaster.provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class FarcasterProvider
2020
extends SocialAbstract
2121
implements SocialProvider
2222
{
23+
available = !!(process.env.NEYNAR_CLIENT_ID && process.env.NEYNAR_SECRET_KEY);
2324
identifier = 'wrapcast';
2425
name = 'Warpcast';
2526
isBetweenSteps = false;

libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export class InstagramProvider
1616
extends SocialAbstract
1717
implements SocialProvider
1818
{
19+
available = !!(
20+
process.env.FACEBOOK_APP_ID && process.env.FACEBOOK_APP_SECRET
21+
);
1922
identifier = 'instagram';
2023
name = 'Instagram\n(Facebook Business)';
2124
isBetweenSteps = true;

libraries/nestjs-libraries/src/integrations/social/instagram.standalone.provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export class InstagramStandaloneProvider
1717
extends SocialAbstract
1818
implements SocialProvider
1919
{
20+
available = !!(
21+
process.env.INSTAGRAM_APP_ID && process.env.INSTAGRAM_APP_SECRET
22+
);
2023
identifier = 'instagram-standalone';
2124
name = 'Instagram\n(Standalone)';
2225
isBetweenSteps = false;

libraries/nestjs-libraries/src/integrations/social/lemmy.provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { LemmySettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/lemmy.dto
1313
import { groupBy } from 'lodash';
1414

1515
export class LemmyProvider extends SocialAbstract implements SocialProvider {
16+
available = true;
1617
identifier = 'lemmy';
1718
name = 'Lemmy';
1819
isBetweenSteps = false;

libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { Integration } from '@prisma/client';
1313
import { PostPlug } from '@gitroom/helpers/decorators/post.plug';
1414

1515
export class LinkedinProvider extends SocialAbstract implements SocialProvider {
16+
available = !!(
17+
process.env.LINKEDIN_CLIENT_ID && process.env.LINKEDIN_CLIENT_SECRET
18+
);
1619
identifier = 'linkedin';
1720
name = 'LinkedIn';
1821
oneTimeToken = true;

0 commit comments

Comments
 (0)