mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 05:17:35 +00:00
@@ -14,7 +14,7 @@ import {sendTelegramMessage} from './telegram';
|
|||||||
import {sendTweet} from './twitter';
|
import {sendTweet} from './twitter';
|
||||||
import {sendTwilioMessage} from './twilio';
|
import {sendTwilioMessage} from './twilio';
|
||||||
import {sendTwitchMessage} from './twitch';
|
import {sendTwitchMessage} from './twitch';
|
||||||
import updateRedis from './redis';
|
import {updateRedis} from './redis';
|
||||||
|
|
||||||
export function sendNotification(link: Link, store: Store) {
|
export function sendNotification(link: Link, store: Store) {
|
||||||
// Priority
|
// Priority
|
||||||
|
|||||||
@@ -4,19 +4,18 @@ import {config} from '../config';
|
|||||||
import {logger} from '../logger';
|
import {logger} from '../logger';
|
||||||
|
|
||||||
const {url} = config.notifications.redis;
|
const {url} = config.notifications.redis;
|
||||||
|
let client: RedisClient;
|
||||||
|
|
||||||
function initRedis(): RedisClient | null {
|
function initRedis(): RedisClient | null {
|
||||||
if (url) {
|
if (url) {
|
||||||
return redis.createClient({url});
|
client = redis.createClient({url});
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateRedis(link: Link, store: Store) {
|
export function updateRedis(link: Link, store: Store) {
|
||||||
try {
|
try {
|
||||||
const client = initRedis();
|
|
||||||
|
|
||||||
if (client) {
|
if (client) {
|
||||||
const key = `${store.name}:${link.brand}:${link.model}`
|
const key = `${store.name}:${link.brand}:${link.model}`
|
||||||
.split(' ')
|
.split(' ')
|
||||||
@@ -43,4 +42,4 @@ function updateRedis(link: Link, store: Store) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default updateRedis;
|
initRedis();
|
||||||
|
|||||||
Reference in New Issue
Block a user