Skip to content
Snippets Groups Projects
Commit fb8bb7aa authored by Valentine Zavgorodnev's avatar Valentine Zavgorodnev Committed by GitHub
Browse files

add profile pics support to notifications (#1017)

* add profile pics support to notifications

* make default value valid
parent 70b61e0f
No related branches found
No related tags found
No related merge requests found
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
"username": "guest", "username": "guest",
"password": "" "password": ""
}, },
"gcm_key": "", "gcm_key": null,
"mixpanel": "", "mixpanel": "",
"img_proxy_prefix": "", "img_proxy_prefix": "",
"ipfs_prefix": "", "ipfs_prefix": "",
......
...@@ -4,12 +4,12 @@ import Tarantool from '../db/tarantool'; ...@@ -4,12 +4,12 @@ import Tarantool from '../db/tarantool';
webPush.setGCMAPIKey(config.gcm_key); webPush.setGCMAPIKey(config.gcm_key);
function notify(account, nparams, title, body, url) { function notify(account, nparams, title, body, url, pic) {
var payload = JSON.stringify({ var payload = JSON.stringify({
title, title,
body, body,
url, url,
icon: 'https://steemit.com/favicon.ico' icon: pic || 'https://steemit.com/favicon.ico'
}); });
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
webPush.sendNotification(nparams, payload).then(function() { webPush.sendNotification(nparams, payload).then(function() {
...@@ -26,11 +26,11 @@ async function process_queue() { ...@@ -26,11 +26,11 @@ async function process_queue() {
const queue = await Tarantool.instance().call('webpush_get_delivery_queue'); const queue = await Tarantool.instance().call('webpush_get_delivery_queue');
for (const n of queue) { for (const n of queue) {
if (n.length === 0) return; if (n.length === 0) return;
const [account, nparams_array, title, body, url] = n; const [account, nparams_array, title, body, url, pic] = n;
console.log('-- notification -->', account, body, url); console.log('-- notification -->', account, body, url, pic);
for (const nparams of nparams_array) { for (const nparams of nparams_array) {
try { try {
await notify(account, nparams, title, body, url); await notify(account, nparams, title, body, url, pic);
} catch (err) { } catch (err) {
console.error('-- error in notify -->', account, err); console.error('-- error in notify -->', account, err);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment