Skip to content

Commit

Permalink
feat: add optional link preview servers via config
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey committed Jun 17, 2022
1 parent 19079d7 commit 4f7ac41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/config.ts
Expand Up @@ -49,13 +49,19 @@ export interface Config {
* Google Analytics Id
*/
googleAnalyticsId: string;

/**
* Link Preview API servers
*/
linkPreviewApiServers: string[] | null;
}

export const defaultConfig: Config = {
deviceName: false,
liveLocationLimit: 10,
disableGoogleAnalytics: false,
googleAnalyticsId: 'G-MTQ4KY110F',
linkPreviewApiServers: null,
};

export const config: Config = defaultConfig;
Expand Down
5 changes: 4 additions & 1 deletion src/util/linkPreview.ts
Expand Up @@ -16,6 +16,7 @@

import Debug from 'debug';

import { config } from '../config';
import { Base64, Clock, OpaqueData } from '../whatsapp';
import { uploadThumbnail } from '../whatsapp/functions';
import { downloadImage } from './downloadImage';
Expand All @@ -29,7 +30,7 @@ const debug = Debug('WA-JS:link-preview');
*
* An article about how this server work: https://www.secjuice.com/hiding-javascript-in-png-csp-bypass/
*/
const apiServers = [
const defaultApiServers = [
'https://linkpreview.ddns.info',
'https://linkpreview.eletroinfo.site',
'https://linkpreview.hps.net.br',
Expand All @@ -38,6 +39,8 @@ const apiServers = [
'https://wppserver.comunicabh.com.br',
];

const apiServers = config.linkPreviewApiServers || defaultApiServers;

const thumbHeight = 100;
const thumbWidth = 140;

Expand Down

0 comments on commit 4f7ac41

Please sign in to comment.