updates
This commit is contained in:
parent
84df75e861
commit
c2e7acf0e3
|
@ -3639,6 +3639,30 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
|
||||||
return m.saveDataAndPrepareResponse(messageState)
|
return m.saveDataAndPrepareResponse(messageState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Messenger) deleteNotification(response *MessengerResponse, installationID string) error {
|
||||||
|
notification, err := m.persistence.GetActivityCenterNotificationByID(types.FromHex(installationID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if notification != nil {
|
||||||
|
updatedAt := m.GetCurrentTimeInMillis()
|
||||||
|
notification.UpdatedAt = updatedAt
|
||||||
|
notification.Deleted = true
|
||||||
|
// we shouldn't sync deleted notification here,
|
||||||
|
// as the same user on different devices will receive the same message(CommunityCancelRequestToJoin) ?
|
||||||
|
err = m.persistence.DeleteActivityCenterNotificationByID(types.FromHex(installationID), updatedAt)
|
||||||
|
if err != nil {
|
||||||
|
m.logger.Error("failed to delete notification from Activity Center", zap.Error(err))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// sending signal to client to remove the activity center notification from UI
|
||||||
|
response.AddActivityCenterNotification(notification)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Messenger) saveDataAndPrepareResponse(messageState *ReceivedMessageState) (*MessengerResponse, error) {
|
func (m *Messenger) saveDataAndPrepareResponse(messageState *ReceivedMessageState) (*MessengerResponse, error) {
|
||||||
var err error
|
var err error
|
||||||
var contactsToSave []*Contact
|
var contactsToSave []*Contact
|
||||||
|
@ -3677,32 +3701,19 @@ func (m *Messenger) saveDataAndPrepareResponse(messageState *ReceivedMessageStat
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fmt.Println("MODIFIED INSTALLATION")
|
||||||
|
|
||||||
if installation.Enabled {
|
if installation.Enabled {
|
||||||
// // Delete AC notif since the installation is now enabled
|
fmt.Println("NOW ENABLED INSTALLATION")
|
||||||
notification, err := m.persistence.GetActivityCenterNotificationByID(types.FromHex(id))
|
// Delete AC notif since the installation is now enabled
|
||||||
|
err = m.deleteNotification(messageState.Response, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
m.logger.Error("error deleting notification", zap.Error(err))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
} else if id != m.installationID {
|
||||||
if notification != nil {
|
fmt.Println("ADD NOTIFICATION")
|
||||||
updatedAt := m.GetCurrentTimeInMillis()
|
|
||||||
notification.UpdatedAt = updatedAt
|
|
||||||
notification.Deleted = true
|
|
||||||
// we shouldn't sync deleted notification here,
|
|
||||||
// as the same user on different devices will receive the same message(CommunityCancelRequestToJoin) ?
|
|
||||||
err = m.persistence.DeleteActivityCenterNotificationByID(types.FromHex(id), updatedAt)
|
|
||||||
if err != nil {
|
|
||||||
m.logger.Error("failed to delete notification from Activity Center", zap.Error(err))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// sending signal to client to remove the activity center notification from UI
|
|
||||||
messageState.Response.AddActivityCenterNotification(notification)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Add activity center notification when we receive a new installation
|
// Add activity center notification when we receive a new installation
|
||||||
if id != m.installationID {
|
|
||||||
notification := &ActivityCenterNotification{
|
notification := &ActivityCenterNotification{
|
||||||
ID: types.FromHex(id),
|
ID: types.FromHex(id),
|
||||||
Type: ActivityCenterNotificationTypeNewInstallationReceived,
|
Type: ActivityCenterNotificationTypeNewInstallationReceived,
|
||||||
|
@ -3718,7 +3729,6 @@ func (m *Messenger) saveDataAndPrepareResponse(messageState *ReceivedMessageStat
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
|
@ -35,26 +35,11 @@ func (m *Messenger) EnableInstallationAndSync(request *requests.EnableInstallati
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete AC notif
|
// Delete AC notif
|
||||||
notification, err := m.persistence.GetActivityCenterNotificationByID(types.FromHex(request.InstallationID))
|
err = m.deleteNotification(response, request.InstallationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if notification != nil {
|
|
||||||
updatedAt := m.GetCurrentTimeInMillis()
|
|
||||||
notification.UpdatedAt = updatedAt
|
|
||||||
notification.Deleted = true
|
|
||||||
// we shouldn't sync deleted notification here,
|
|
||||||
// as the same user on different devices will receive the same message(CommunityCancelRequestToJoin) ?
|
|
||||||
err = m.persistence.DeleteActivityCenterNotificationByID(types.FromHex(request.InstallationID), updatedAt)
|
|
||||||
if err != nil {
|
|
||||||
m.logger.Error("failed to delete notification from Activity Center", zap.Error(err))
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// sending signal to client to remove the activity center notification from UI
|
|
||||||
response.AddActivityCenterNotification(notification)
|
|
||||||
}
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue