From Jay2k1, 1 Month ago, written in Diff-output.
This paste will run down the curtain in 9 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/bot12345678:AAFasdasdasdasdasdasdasdasdasdasd/sendMessage',
  25. +           method: 'POST',
  26. +           json: {
  27. +               "chat_id": "987654321",
  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.         _.forOwn(client.config.sessions, ({pushSubscription}, token) => {
  39.             if (pushSubscription) {
  40.                 if (onlyToOffline && _.find(client.attachedClients, {token}) !== undefined) {
  41.                     return;
  42.                 }
  43.  
  44. +               // do not push if there are clients connected
  45. +               if (_.size(client.attachedClients) > 0) return;
  46. +
  47.                 this.pushSingle(client, pushSubscription, payload);
  48.             }
  49.         });