Skip to content

Commit

Permalink
fix(util/index): fix arg type & fn calls
Browse files Browse the repository at this point in the history
On one of my old commits, I chose the wrong type for
an arg function.
  • Loading branch information
Mersho committed Oct 26, 2023
1 parent 032e1d8 commit d26f530
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { IOrder } from "../models/order";
import { UserDocument } from "../models/user";
import { IFiatCurrencies, IFiat } from "./fiatModel";
import { ILanguage, ILanguages } from "./languagesModel";
import { Telegram } from "telegraf/typings/core/types/typegram";
import axios from "axios";
import fiatJson from './fiat.json';
import languagesJson from './languages.json';
Expand Down Expand Up @@ -230,9 +229,9 @@ const secondsToTime = (secs: number) => {
};
};

const isGroupAdmin = async (groupId: string, user: UserDocument, telegram: Telegram) => {
const isGroupAdmin = async (groupId: string, user: UserDocument, telegram: MainContext['telegram']) => {
try {
const member = await telegram.getChatMember({chat_id: groupId, user_id: Number(user.tg_id)});
const member = await telegram.getChatMember(groupId, Number(user.tg_id));
if (
member &&
(member.status === 'creator' || member.status === 'administrator')
Expand Down Expand Up @@ -261,9 +260,11 @@ const isGroupAdmin = async (groupId: string, user: UserDocument, telegram: Teleg
}
};

const deleteOrderFromChannel = async (order: IOrder, telegram: Telegram) => {
const deleteOrderFromChannel = async (order: IOrder, telegram: MainContext['telegram']) => {
try {
let channel = process.env.CHANNEL;
if (channel === undefined) throw Error("CHANNEL not found, please check .env file")
if (order.tg_channel_message1 === undefined) throw Error("order.tg_channel_message1 was not found in DB")
if (order.community_id) {
const community = await Community.findOne({ _id: order.community_id });
if (!community) {
Expand All @@ -279,7 +280,7 @@ const deleteOrderFromChannel = async (order: IOrder, telegram: Telegram) => {
}
}
}
await telegram.deleteMessage({chat_id: channel!, message_id: Number(order.tg_channel_message1!)});
await telegram.deleteMessage(channel, Number(order.tg_channel_message1));
} catch (error) {
logger.error(error);
}
Expand Down Expand Up @@ -381,7 +382,7 @@ const getDetailedOrder = (i18n: I18nContext, order: IOrder, buyer: UserDocument,
};

// We need to know if this user is a dispute solver for this community
const isDisputeSolver = (community: ICommunity, user: UserDocument) => {
const isDisputeSolver = (community: ICommunity | null, user: UserDocument) => {
if (!community || !user) {
return false;
}
Expand Down

0 comments on commit d26f530

Please sign in to comment.