Skip to content

Commit

Permalink
Merge pull request #1149 from givepraise/add/hide-recipient
Browse files Browse the repository at this point in the history
Hide receipient in Discord feed when
  • Loading branch information
kristoferlund committed Dec 15, 2023
2 parents e6727f2 + a491266 commit e179970
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
14 changes: 10 additions & 4 deletions packages/discord-bot/src/utils/embeds/praiseSuccessEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ export const praiseSuccessEmbed = async (
user: User,
receivers: string[],
reason: string,
host: string
host: string,
praiseNotificationsEnabled = true
): Promise<EmbedBuilder> => {
const msg = ((await getSetting('PRAISE_SUCCESS_MESSAGE', host)) as string)
.replace('{@receivers}', `${receivers.join(', ')}`)
.replace('{reason}', reason);
let msg = (await getSetting('PRAISE_SUCCESS_MESSAGE', host)) as string;

if (!praiseNotificationsEnabled) {
msg = msg.replace('{@receivers}', '[HIDDEN]');
} else {
msg = msg.replace('{@receivers}', `${receivers.join(', ')}`);
}
msg = msg.replace('{reason}', reason);

const embed = new EmbedBuilder().setColor(0xe6007e).setDescription(msg);
return embed;
Expand Down
13 changes: 7 additions & 6 deletions packages/discord-bot/src/utils/givePraise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ export const givePraise = async (
})
);

const praiseNotificationsEnabled = (await getSetting(
'DISCORD_BOT_PRAISE_NOTIFICATIONS_ENABLED',
host
)) as boolean;

let praiseItems: Praise[] = [];
if (receivers.length !== 0) {
await interaction.editReply({
Expand All @@ -78,7 +83,8 @@ export const givePraise = async (
interaction.user,
validReceiverIds.map((id) => `<@!${id}>`),
reason,
host
host,
praiseNotificationsEnabled
),
],
components: [],
Expand All @@ -105,11 +111,6 @@ export const givePraise = async (
? process.env?.FRONTEND_URL || 'undefined:/'
: `https://${host}`;

const praiseNotificationsEnabled = (await getSetting(
'DISCORD_BOT_PRAISE_NOTIFICATIONS_ENABLED',
host
)) as boolean;

if (praiseNotificationsEnabled) {
await Promise.all(
praiseItems.map(async (praise) => {
Expand Down

0 comments on commit e179970

Please sign in to comment.