Commit bd39bf86 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Use correct wire format when sending live notifications to clients

parent a36867cd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ The format is based on [keep a changelog](http://keepachangelog.com/) and this p
- Realtime notification routing now correctly resolves connected users.
- The server will now correctly log a reason when clients disconnect unexpectedly.
- Log a more informative error message when social providers are unreachable or return errors.
- Use correct wire format when sending live notifications to clients.

## [1.0.1] - 2017-08-05
### Added
+2 −8
Original line number Diff line number Diff line
@@ -51,18 +51,12 @@ func friendAdd(logger *zap.Logger, db *sql.DB, ns *NotificationService, userID [
				logger.Warn("Failed to send friend add notification", zap.Error(e))
				return
			}
			var recipient []byte
			var sender []byte
			var subject string
			var code int64
			if isFriendAccept {
				recipient = userID
				sender = friendID
				subject = fmt.Sprintf("%v accepted your friend request", handle)
				code = NOTIFICATION_FRIEND_ACCEPT
			} else {
				recipient = friendID
				sender = userID
				subject = fmt.Sprintf("%v wants to add you as a friend", handle)
				code = NOTIFICATION_FRIEND_REQUEST
			}
@@ -70,11 +64,11 @@ func friendAdd(logger *zap.Logger, db *sql.DB, ns *NotificationService, userID [
			if e := ns.NotificationSend([]*NNotification{
				&NNotification{
					Id:         uuid.NewV4().Bytes(),
					UserID:     recipient,
					UserID:     friendID,
					Subject:    subject,
					Content:    content,
					Code:       code,
					SenderID:   sender,
					SenderID:   userID,
					CreatedAt:  updatedAt,
					ExpiresAt:  updatedAt + ns.expiryMs,
					Persistent: true,
+6 −2
Original line number Diff line number Diff line
@@ -99,8 +99,12 @@ func (n *NotificationService) NotificationSend(notifications []*NNotification) e
	for userID, ns := range notificationsByUser {
		presences := n.tracker.ListByTopicUser("notifications", userID)
		if len(presences) != 0 {
			nots := convertNotifications(ns)
			n.messageRouter.Send(n.logger, presences, nots)
			envelope := &Envelope{
				Payload: &Envelope_LiveNotifications{
					LiveNotifications: convertNotifications(ns),
				},
			}
			n.messageRouter.Send(n.logger, presences, envelope)
		}
	}