Gitter migration: Point people to app.gitter.im (rollout pt. 1)
[gitter.git] / modules / push-gateways / lib / vapid / vapid-notification-generator.js
blobd45136213cdb918c623f82f88b12fdd8b06e11bc
1 'use strict';
3 function generateNewChatNotifications(notificationType, notificationDetails /*, device*/) {
4   var room = notificationDetails.room;
5   var chats = notificationDetails.chats;
7   return {
8     type: notificationType,
9     linkUrl: room.url + '?utm_source=web-push-notification',
10     room: {
11       id: room.id,
12       uri: room.uri,
13       name: room.name || room.uri,
14       oneToOne: room.oneToOne,
15       url: room.url
16     },
17     chats: chats.map(function(chat) {
18       var fromUser;
20       if (chat.fromUser) {
21         fromUser = {
22           id: chat.fromUser.id,
23           username: chat.fromUser.username,
24           displayName: chat.fromUser.displayName,
25           avatarUrl: chat.fromUser.avatarUrl
26         };
27       }
28       return {
29         id: chat.id,
30         text: chat.text,
31         sent: chat.sent,
32         fromUser: fromUser
33       };
34     })
35   };
38 function generateNotifications(notificationType, notificationDetails, device) {
39   switch (notificationType) {
40     case 'new_chat':
41       return generateNewChatNotifications(notificationType, notificationDetails, device);
42   }
45 module.exports = generateNotifications;