Skip to content

Commit

Permalink
Merge branch 'alexemanuelol:master' into vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
FaiThiX authored Sep 23, 2024
2 parents 56f253d + ed50284 commit 778b1d3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
25 changes: 24 additions & 1 deletion src/util/FcmListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,33 @@ module.exports = async (client, guild) => {
client.fcmListeners[guild.id].on('ON_DATA_RECEIVED', (data) => {
const appData = data.appData;

if (!appData) {
client.log('FCM Host', `GuildID: ${guild.id}, SteamID: ${hoster}, appData could not be found.`)
return;
}

const title = appData.find(item => item.key === 'title')?.value;
const message = appData.find(item => item.key === 'message')?.value;
const channelId = appData.find(item => item.key === 'channelId')?.value;
const body = JSON.parse(appData.find(item => item.key === 'body')?.value);

if (!channelId) {
client.log('FCM Host', `GuildID: ${guild.id}, SteamID: ${hoster}, channelId could not be found.`)
return;
}

const bodyCheck = appData.find(item => item.key === 'body');

if (!bodyCheck) {
client.log('FCM Host', `GuildID: ${guild.id}, SteamID: ${hoster}, body could not be found.`)
return;
}

const body = JSON.parse(bodyCheck.value);

if (!body.type) {
client.log('FCM Host', `GuildID: ${guild.id}, SteamID: ${hoster}, body type could not be found.`)
return;
}

switch (channelId) {
case 'pairing': {
Expand Down
25 changes: 24 additions & 1 deletion src/util/FcmListenerLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,33 @@ module.exports = async (client, guild, steamId) => {
client.fcmListenersLite[guild.id][steamId].on('ON_DATA_RECEIVED', (data) => {
const appData = data.appData;

if (!appData) {
client.log('FCM LITE', `GuildID: ${guild.id}, SteamID: ${hoster}, appData could not be found.`)
return;
}

const title = appData.find(item => item.key === 'title')?.value;
const message = appData.find(item => item.key === 'message')?.value;
const channelId = appData.find(item => item.key === 'channelId')?.value;
const body = JSON.parse(appData.find(item => item.key === 'body')?.value);

if (!channelId) {
client.log('FCM LITE', `GuildID: ${guild.id}, SteamID: ${hoster}, channelId could not be found.`)
return;
}

const bodyCheck = appData.find(item => item.key === 'body');

if (!bodyCheck) {
client.log('FCM LITE', `GuildID: ${guild.id}, SteamID: ${hoster}, body could not be found.`)
return;
}

const body = JSON.parse(bodyCheck.value);

if (!body.type) {
client.log('FCM LITE', `GuildID: ${guild.id}, SteamID: ${hoster}, body type could not be found.`)
return;
}

switch (channelId) {
case 'pairing': {
Expand Down

0 comments on commit 778b1d3

Please sign in to comment.