From aee2cca0d141137567a0fcd18e85f53f7b9ed98e Mon Sep 17 00:00:00 2001 From: Le Dien Phuc Date: Mon, 2 Oct 2023 15:25:54 +0700 Subject: [PATCH 1/2] chore(sentry): add app version to sentry context (#1506) --- src/types/api.ts | 15 ++++++++++++--- src/utils/wrap-error.ts | 10 ++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/types/api.ts b/src/types/api.ts index a457716a3..e483a6c0a 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -765,6 +765,7 @@ export interface RequestOffchainTransferRequest { platform?: string recipients?: string[] sender?: string + /** AmountString string `json:"amount_string"` */ token?: string transfer_type?: string @@ -1062,9 +1063,7 @@ export interface ResponseCoinMarketItemData { price_change_percentage_24h?: number price_change_percentage_24h_in_currency?: number price_change_percentage_7d_in_currency?: number - sparkline_in_7d?: { - price?: number[] - } + sparkline_in_7d?: { price?: number[] } symbol?: string } @@ -1148,8 +1147,10 @@ export interface ResponseCreateUserTokenSupportRequest { export interface ResponseDataFilterConfigByReaction { data?: ResponseRoleReactionResponse + /** page index */ page?: number + /** page size */ size?: number total?: number @@ -1157,8 +1158,10 @@ export interface ResponseDataFilterConfigByReaction { export interface ResponseDataListRoleReactionResponse { data?: ResponseListRoleReactionResponse + /** page index */ page?: number + /** page size */ size?: number total?: number @@ -1217,6 +1220,7 @@ export interface ResponseDiscordGuildResponse { id?: string name?: string owner?: boolean + /** @example 0 */ permissions?: string } @@ -1437,8 +1441,10 @@ export interface ResponseGetInvestListResponse { export interface ResponseGetLevelRoleConfigsResponse { data?: ModelGuildConfigLevelRole[] + /** page index */ page?: number + /** page size */ size?: number total?: number @@ -1556,6 +1562,7 @@ export interface ResponseGetTrackingWalletsResponse { export interface ResponseGetTrendingSearch { coins?: ResponseGetTrendingSearchCoin[] + /** this field coingecko return empty */ exchanges?: any } @@ -2074,6 +2081,7 @@ export interface ResponseOnchainInvestDataResponse { export interface ResponsePaginationResponse { /** page index */ page?: number + /** page size */ size?: number total?: number @@ -2321,6 +2329,7 @@ export interface UtilPagination { export interface UuidNullUUID { uuid?: string + /** Valid is true if UUID is not NULL */ valid?: boolean } diff --git a/src/utils/wrap-error.ts b/src/utils/wrap-error.ts index 07b18bc87..ec868b038 100644 --- a/src/utils/wrap-error.ts +++ b/src/utils/wrap-error.ts @@ -7,6 +7,7 @@ import ChannelLogger from "../logger/channel" import { getCommandMetadata } from "./commands" import { kafkaQueue } from "queue/kafka/queue" import { Sentry } from "sentry" +import { version } from "../../package.json" function catchAll(e: any) { logger.error(e) @@ -72,6 +73,9 @@ export async function wrapError( raw: commandStr, args, }, + app: { + app_version: `v${version}`, + }, }, }) } @@ -104,6 +108,9 @@ export async function wrapError( .map((option) => option.value) .join(" "), }, + app: { + app_version: `v${version}`, + }, }, }) } @@ -122,6 +129,9 @@ export async function wrapError( raw: commandStr, args, }, + app: { + app_version: `v${version}`, + }, }, }) } From a871d25c56270cb6ae5cf5b571c4374e3a249242 Mon Sep 17 00:00:00 2001 From: Le Dien Phuc Date: Tue, 3 Oct 2023 09:56:31 +0700 Subject: [PATCH 2/2] fix(gm): brings gm back (#1508) --- src/listeners/discord/messageCreate.ts | 42 +++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/listeners/discord/messageCreate.ts b/src/listeners/discord/messageCreate.ts index 803a12bc5..b9323bbc2 100644 --- a/src/listeners/discord/messageCreate.ts +++ b/src/listeners/discord/messageCreate.ts @@ -1,9 +1,48 @@ +import webhook from "adapters/webhook" import { handlePrefixedCommand } from "commands" +import { Message } from "discord.js" import tagme from "handlers/tagme" import { textCommandAsyncStore } from "utils/async-storages" -import { PREFIX } from "utils/constants" +import { + MOCHI_PROFILE_API_BASE_URL, + PREFIX, + VALID_BOOST_MESSAGE_TYPES, +} from "utils/constants" import { wrapError } from "utils/wrap-error" import { DiscordEvent } from "./index" +import fetch from "node-fetch" + +export const handleNormalMessage = async (message: Message) => { + try { + if (message.channel.type === "DM") return + + const messageType = VALID_BOOST_MESSAGE_TYPES.includes(message.type) ? 9 : 1 + + const stickers = Array.from(message.stickers.values()) + + const profileRes = await fetch( + `${MOCHI_PROFILE_API_BASE_URL}/profiles/get-by-discord/${message.author.id}?no_fetch_amount=true`, + ) + const profileId = (await profileRes.json())?.id + const body = { + author: { + id: message.author.id, + avatar: message.author.avatarURL(), + username: message.author.username, + }, + guild_id: message.guildId, + channel_id: message.channelId, + timestamp: message.createdAt.toISOString(), + content: message.content, + sticker_items: stickers, + type: messageType, + } + + await webhook.pushDiscordWebhook("messageCreate", body, profileId) + } catch (e) { + // swallow, intentional + } +} const events: DiscordEvent<"messageCreate"> = { name: "messageCreate", @@ -34,6 +73,7 @@ const events: DiscordEvent<"messageCreate"> = { return } tagme.handle(message) + await handleNormalMessage(message) }) }, )