From Jay2k1, 3 Months ago, written in Diff-output.
This paste will check out in 7 Months.
  1. diff --git a/src/plugins/webpush.js b/src/plugins/webpush.js
  2. index cf34c10a..a6f1dffa 100644
  3. --- a/src/plugins/webpush.js
  4. +++ b/src/plugins/webpush.js
  5. @@ -6,6 +6,7 @@ const fs = require("fs");
  6.  const path = require("path");
  7.  const WebPushAPI = require("web-push");
  8.  const Helper = require("../helper");
  9. +const request = require("request");
  10.  
  11.  class WebPush {
  12.     constructor() {
  13. @@ -42,12 +43,37 @@ class WebPush {
  14.     }
  15.  
  16.     push(client, payload, onlyToOffline) {
  17. +
  18. +       /*** telegram push. could be useful for iOS users. ***/
  19. +
  20. +       // do not push if there are clients connected
  21. +       if (_.size(client.attachedClients) > 0) return;
  22. +
  23. +       const options = {
  24. +           uri: 'https://api.telegram.org/bot987654321:AbCdEfGhIjKlMnOp-ab1337f/sendMessage',
  25. +           method: 'POST',
  26. +           json: {
  27. +               "chat_id": "123456789",
  28. +               "text": payload.title + ": " + payload.body
  29. +           }
  30. +       };
  31. +
  32. +       request(options, function (error, response, body) {
  33. +         if (!error && response.statusCode == 200) {
  34. +           console.log('telegram push successful.');
  35. +         }
  36. +       });
  37. +      
  38. +
  39.         _.forOwn(client.config.sessions, ({pushSubscription}, token) => {
  40.             if (pushSubscription) {
  41.                 if (onlyToOffline && _.find(client.attachedClients, {token}) !== undefined) {
  42.                     return;
  43.                 }
  44.  
  45. +               // do not push if there are clients connected
  46. +               if (_.size(client.attachedClients) > 0) return;
  47. +
  48.                 this.pushSingle(client, pushSubscription, payload);
  49.             }
  50.         });