From 702ede5652ba59db43cd655e6de2a523828fd9b0 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Fri, 18 Feb 2022 10:14:32 -0600 Subject: [PATCH 1/2] android push notification --- certificates/apn.p12 | Bin 3327 -> 0 bytes config/notifications.js | 3 ++- server.js | 18 +++++------------- services/firebaseService.js | 3 +++ services/pushNotificationTokenService.js | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) delete mode 100755 certificates/apn.p12 diff --git a/certificates/apn.p12 b/certificates/apn.p12 deleted file mode 100755 index a1a26dfe1ddfc5c682c31c1a4404df00534b7af0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3327 zcmY+FcQhM}8pabsiqO)a_J|o&Viu)F)T~h>ReSHE=2u093R0?esn)JttJG*!P${iZ z6tQE(sL{r%dHbDn@BQxm<2lcHpXWXApYIQWfgDo-sSy|mo|X5b(!%{%L>+Zd&?(Uw{B<5lo;9pPXTPG3oowR8$uL zk1(`5yM8BTA}1TW6s5h+;iF85Q}wHH_YXTMeQr(V`_7RW?+pdYkS`8k+iLl*ypgz| ziwooYS-hM^{taUq79ie=!0{>%s@kT+9wEHkol!TWJsNBmm6x!8X!E<}ti7A3g{ZBU z>Ff}f{&X+K*f3@w-Q?D5V6fF*P?c!$M`^|(TE!^y_7aT6d|Vy6-}lqG_yjnYmp~Yi&u+O53ZJmzG&PDC@5(d2Gz!m0oJ?ec zi@q#5vch=`N8SS_TeGr#pnmgj(yUuV3wqeSESc-xg(pmO5GFbpG`gFo!H;_V6{eh! zZdckmSDP-g&$?tBMb&B;)QJkv`Ux88doFO9~7_Dwba4OWFmD3~=$ngYCNJ z0Rnewgm2#WD4TJ$h|5R@fJcc%4rIm7Yn^C4If^QKm4pOQno_Pu{4#hJ*q3orAa|tK zEi1EsCht}fK6P)A(ARsD0R*0jHGgb@Nwb|B=g}KSDax{vMdw1pwd=u>fn3YvkJP15 z_vqxkjSlR?A9KIyrTHU5w1&esgp<-UBT3{0hA0_@F8~z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;|Bs^7e^azg`X#!a z$@uHv6a`^Ggr?YlpizrKUlx`Tdxr|h4bjMqiUBylJ#hcjCcy4Gc~xhUT%O^y0uMV( z`io30Z4Aw{eW6e?&8W5<3^i>FQ(JC8 zF<2YPftTB}CtW9~l4Nr|0`A$;aM32d9irbG5%r<&ZyY?JA2PlcoO~ecgmhcGOD0@DV_fc@cVO=e*)|9? z&e#xn5*;-+a@JVEwk7l^Eeor?OpDyp8_; z_G*RdUae?F4WmlL@f?Z2PA<=X+e);LF!enn%H@vD;L1Q!qx8u4ESo13k6<* zl_q)dzfCm0f-Z1o&wVEjIoZQ}V$v@jGm<@(_r?hhOr`}`^VLr^ANE`ad3hT)sKXuzx_3>=C7V_7v~lv{6j&^& z{l)R6Mx_bTdVPrB2wmL0Ry8{m2#+DiJ@#{h9$p`{YL|{Dig8ZfDM>rHxH{|4S-snI z+m<(;RJv)zOj3fc7ci3G1Bz3jrF!5_;|T|Rlw>}E={jUsP>mWm1yZov_L1og z+X44u!?=I6nR5zzM=u>7-v-#GTA!3VB+#)?!@X`>T8(ilBV7)&+yaBz(iCKaWC7DQ zH;>hlx0G5X9-42`Je5<^U^e@RwNItxI(Ww)jWR{|FLT5UW78;m29{us7y2@N>>tKz zbw~?&St&%EGbw&@U#sx1@~gsf?6Xu~O)|~uWcT;yaFZ_DJm#tXZUjkl-TdWR%%-}E zNYT-;Wb%@79<64;@?a6kZNDjQ2u4eyCQI18(N z{r%GqieqxpJB6o3zoy1!0UsBcgL|1NC+ diff --git a/config/notifications.js b/config/notifications.js index c33737ba..726330f9 100644 --- a/config/notifications.js +++ b/config/notifications.js @@ -60,9 +60,10 @@ function sendApplePN(token, alertMessage, badgeCount, payload, category){ // setTimeout(async () => { return apnProvider.send(notification, token) .then(result=>{ - // logger.debug(JSON.stringify(result)); + logger.debug(`${result}`); apnProvider.shutdown(); // close all open connections when queue is fully drained. }) + .catch(error => logger.error(`Error sending PN ${error}`)) // }, delay); } diff --git a/server.js b/server.js index 57e10d96..275cd2e9 100644 --- a/server.js +++ b/server.js @@ -12,21 +12,13 @@ const { tokenVerify } = require('./middlewares/authentication'); const {externalResourcesCheck} = require('./middlewares/externalResourcesCheck'); const firebaseAdmin = require("firebase-admin"); // Firebase Service initializer -const firebaseServiceAccount = { - type: process.env.FIREBASE_TYPE, - project_id: process.env.FIREBASE_PROJECT_ID, - private_key_id: process.env.FIREBASE_PRIVATE_KEY_ID, - private_key: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n') , - client_email: process.env.FIREBASE_CLIENT_EMAIL, - client_id: process.env.FIREBASE_CLIENT_ID, - auth_uri: process.env.FIREBASE_AUTH_URI, - token_uri: process.env.FIREBASE_TOKEN_URI, - auth_provider_x509_cert_url: process.env.FIREBASE_AUTH_PROVIDER_X509_CERT_URL, - client_x509_cert_url: process.env.FIREBASE_CLIENT_X509_CERT_URL -}; module.exports.firebaseAdmin = firebaseAdmin.initializeApp({ - credential: firebaseAdmin.credential.cert(firebaseServiceAccount) + credential: firebaseAdmin.credential.cert({ + projectId: process.env.FIREBASE_PROJECT_ID, + clientEmail: process.env.FIREBASE_CLIENT_EMAIL, + privateKey: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n') , + }) }); const url = require('url'); // const kue = require('kue'); diff --git a/services/firebaseService.js b/services/firebaseService.js index a80e3750..59974026 100644 --- a/services/firebaseService.js +++ b/services/firebaseService.js @@ -1,4 +1,5 @@ import {firebaseAdmin} from '../server'; +const logger = require('../utils/logger')(module); /** * @@ -33,6 +34,8 @@ class FirebaseService { } return this.firebaseAdmin.messaging().sendToDevice(registrationToken, message, options) + .then(result => logger.debug(`${result}`)) + .catch(error => console.log('Error sending Android PN', error)) } /** diff --git a/services/pushNotificationTokenService.js b/services/pushNotificationTokenService.js index 6396cb8b..a48be901 100644 --- a/services/pushNotificationTokenService.js +++ b/services/pushNotificationTokenService.js @@ -66,7 +66,7 @@ module.exports = { }) }, editMutedChannels: (req, res) => { - const { userData: { address: userAddress } } = req.user; + const { address: userAddress } = req.user; const { channelAddress, isMuted } = req.body; if (!channelAddress) { From 9455a079025cc4c54908c9e3aa6b4b7029c428d5 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Wed, 23 Feb 2022 10:36:01 -0600 Subject: [PATCH 2/2] fix workflow tag --- .github/workflows/tag.workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tag.workflow.yml b/.github/workflows/tag.workflow.yml index 6da85972..434e8451 100644 --- a/.github/workflows/tag.workflow.yml +++ b/.github/workflows/tag.workflow.yml @@ -25,9 +25,9 @@ jobs: - name: Log in to DO Container Registry run: doctl registry login --expiry-seconds 600 - name: Tag image - run: docker tag metis ${{ secrets.DIGITALOCEAN_REGISTRY }}:${{ steps.tag.outputs.tag }} + run: docker tag metis registry.digitalocean.com/metis/metis:${{ steps.tag.outputs.tag }} - name: Push image to DO Container Registry - run: docker push ${{ secrets.DIGITALOCEAN_REGISTRY }}:${{ steps.tag.outputs.tag }} + run: docker push registry.digitalocean.com/metis/metis:${{ steps.tag.outputs.tag }} - name: Channel specific notification Slack uses: adamkdean/simple-slack-notify@master env: