Skip to content

Commit

Permalink
fix feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Proladge committed Apr 22, 2020
1 parent 84d90cc commit 2a3191c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions server/src/bots/telegram/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { unsubscribeStrategyResponse } from './botResponse/unsubscribeResponse';
import { trendsByCountryResponse } from './botResponse/trendResponse';
import { CountrySituationInfo } from '../../models/covid19.models';
import { catchAsyncError } from '../../utils/catchError';
// import {sendReleaseNotificationToUsers} from '../../services/infrastructure/scheduler';
import { RunSendScheduledNotificationToUsersJob } from '../../services/infrastructure/scheduler';

export function runTelegramBot(
app: Express,
Expand Down Expand Up @@ -170,6 +170,5 @@ export function runTelegramBot(
logger.log(LogLevel.Error, err, LogCategory.TelegramError)
);

// Will come up enabled. Next release
// sendReleaseNotificationToUsers(bot);
RunSendScheduledNotificationToUsersJob(bot);
}
3 changes: 2 additions & 1 deletion server/src/models/user.model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export type User = {
type User = {
chatId: number;
userName: string;
firstName: string;
lastName: string;
startedOn: number;
};
export default User;
2 changes: 1 addition & 1 deletion server/src/services/domain/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '../../models/subscription.models';
import { SubscriptionStorage } from '../../models/storage.models';
import * as TelegramBot from 'node-telegram-bot-api';
import { User } from '../../models/user.model';
import User from '../../models/user.model';
import DataSnapshot = firebase.database.DataSnapshot;

export const getFllStorage = async <T>(): Promise<T> => {
Expand Down
8 changes: 2 additions & 6 deletions server/src/services/infrastructure/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { catchAsyncError } from '../../utils/catchError';
import TelegramBot = require('node-telegram-bot-api');
import environments from '../../environments/environment';
import { User } from '../../models/user.model';
import { getUserName } from '../../utils/user.utils';

export const checkCovid19Updates = () => {
// Check covid19 info every hour (at hh:30 mins, e.g. 1:30, 2:30 ...)
Expand All @@ -23,7 +23,7 @@ export const checkCovid19Updates = () => {
});
};

export const sendReleaseNotificationToUsers = async (
export const RunSendScheduledNotificationToUsersJob = async (
bot: TelegramBot
): Promise<void> => {
// At 08:00 PM, every day
Expand Down Expand Up @@ -73,7 +73,3 @@ export const sendReleaseNotificationToUsers = async (
}
);
};

function getUserName(user: User): string {
return user.firstName ?? user.lastName ?? user.userName ?? 'friend';
}
4 changes: 4 additions & 0 deletions server/src/utils/user.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import User from '../models/user.model';
export const getUserName = (user: User): string => {
return user.firstName ?? user.lastName ?? user.userName ?? 'friend';
};

0 comments on commit 2a3191c

Please sign in to comment.