[Fix] Remove AC request notification on community request cancellation (#3381)
This commit is contained in:
parent
22bc76c39f
commit
e131d738bd
|
@ -1156,6 +1156,9 @@ func (s *MessengerCommunitiesSuite) TestCancelRequestAccess() {
|
|||
if len(response.RequestsToJoinCommunity) == 0 {
|
||||
return errors.New("request to join community not received")
|
||||
}
|
||||
if len(response.ActivityCenterNotifications()) == 0 {
|
||||
return errors.New("request to join community notification not added in activity center")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
|
@ -1210,6 +1213,17 @@ func (s *MessengerCommunitiesSuite) TestCancelRequestAccess() {
|
|||
s.Require().NoError(err)
|
||||
s.Require().Len(response.RequestsToJoinCommunity, 1)
|
||||
|
||||
// Retrieve activity center notifications for admin to make sure the request notification is deleted
|
||||
notifications, err := s.bob.ActivityCenterNotifications(ActivityCenterNotificationsRequest{
|
||||
Cursor: "",
|
||||
Limit: 10,
|
||||
ActivityTypes: []ActivityCenterType{},
|
||||
ReadType: ActivityCenterQueryParamsReadUnread,
|
||||
})
|
||||
|
||||
s.Require().NoError(err)
|
||||
s.Require().Len(notifications.Notifications, 0)
|
||||
|
||||
cancelRequestToJoin2 := response.RequestsToJoinCommunity[0]
|
||||
|
||||
s.Require().NotNil(cancelRequestToJoin2)
|
||||
|
|
|
@ -9,6 +9,8 @@ import (
|
|||
"runtime"
|
||||
"sync"
|
||||
|
||||
"github.com/status-im/status-go/signal"
|
||||
|
||||
"github.com/pborman/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
|
@ -1229,6 +1231,28 @@ func (m *Messenger) HandleCommunityCancelRequestToJoin(state *ReceivedMessageSta
|
|||
}
|
||||
|
||||
state.Response.RequestsToJoinCommunity = append(state.Response.RequestsToJoinCommunity, requestToJoin)
|
||||
|
||||
// delete activity center notification
|
||||
notification, err := m.persistence.GetActivityCenterNotificationByID(requestToJoin.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if notification != nil {
|
||||
err = m.persistence.DeleteActivityCenterNotification(types.FromHex(requestToJoin.ID.String()))
|
||||
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 := &MessengerResponse{}
|
||||
notification.Deleted = true
|
||||
response.AddActivityCenterNotification(notification)
|
||||
|
||||
signal.SendNewMessages(response)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue