Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SupertigerDev committed Dec 25, 2024
1 parent 232b6cf commit d77eecb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/fcm/pushNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@ export async function sendServerPushMessageNotification(
channel: ChannelCache,
server: ServerCache
) {
if (message.silent) return;
if (!credentials) return;
// if (message.silent) return;
// if (!credentials) return;

const channelPermissions = await prisma.serverChannelPermissions.findMany({
where: { channelId: message.channelId, serverId },
});

const defaultChannelPermission = channelPermissions.find((cp) => cp.roleId === server.defaultRoleId);
const isPrivateChannel = hasBit(defaultChannelPermission?.permissions || 0, CHANNEL_PERMISSIONS.PUBLIC_CHANNEL.bit);
const isPrivateChannel = !hasBit(defaultChannelPermission?.permissions || 0, CHANNEL_PERMISSIONS.PUBLIC_CHANNEL.bit);

const roles = isPrivateChannel ? await prisma.serverRole.findMany({ where: { serverId } }) : [];

const mentionedUserIds = message.mentions.map((user) => user.id);

console.log(isPrivateChannel);
const users = await prisma.firebaseMessagingToken.findMany({
where: {
account: {
Expand Down Expand Up @@ -125,6 +126,7 @@ export async function sendServerPushMessageNotification(
return combined === NotificationPingMode.ALL;
});

return;
const tokens = filteredUsers.map((fcm) => fcm.token);

if (!tokens.length) return;
Expand Down

0 comments on commit d77eecb

Please sign in to comment.