fix(ActivityCenterNotification)_: update pending state of request to join ActivityCenterNotification when member was joined (#5242)
This commit is contained in:
parent
dd7b3d1af8
commit
3cae2e06f3
|
@ -1049,6 +1049,26 @@ func (m *Messenger) joinCommunity(ctx context.Context, communityID types.HexByte
|
||||||
Image: "",
|
Image: "",
|
||||||
}
|
}
|
||||||
response.AddNotification(joinedNotification)
|
response.AddNotification(joinedNotification)
|
||||||
|
|
||||||
|
// Activity Center notification
|
||||||
|
requestID := communities.CalculateRequestID(common.PubkeyToHex(&m.identity.PublicKey), communityID)
|
||||||
|
notification, err := m.persistence.GetActivityCenterNotificationByID(requestID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if notification != nil && notification.MembershipStatus != ActivityCenterMembershipStatusAccepted {
|
||||||
|
notification.MembershipStatus = ActivityCenterMembershipStatusAccepted
|
||||||
|
notification.Read = false
|
||||||
|
notification.Deleted = false
|
||||||
|
|
||||||
|
notification.UpdatedAt = m.GetCurrentTimeInMillis()
|
||||||
|
err = m.addActivityCenterNotification(response, notification, nil)
|
||||||
|
if err != nil {
|
||||||
|
m.logger.Error("failed to update request to join accepted notification", zap.Error(err))
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
|
|
|
@ -1730,29 +1730,6 @@ func (m *Messenger) HandleCommunityRequestToJoinResponse(state *ReceivedMessageS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activity Center notification
|
|
||||||
requestID := communities.CalculateRequestID(common.PubkeyToHex(&m.identity.PublicKey), requestToJoinResponseProto.CommunityId)
|
|
||||||
notification, err := m.persistence.GetActivityCenterNotificationByID(requestID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if notification != nil {
|
|
||||||
if requestToJoinResponseProto.Accepted {
|
|
||||||
notification.MembershipStatus = ActivityCenterMembershipStatusAccepted
|
|
||||||
notification.Read = false
|
|
||||||
notification.Deleted = false
|
|
||||||
} else {
|
|
||||||
notification.MembershipStatus = ActivityCenterMembershipStatusDeclined
|
|
||||||
}
|
|
||||||
notification.UpdatedAt = m.GetCurrentTimeInMillis()
|
|
||||||
err = m.addActivityCenterNotification(state.Response, notification, nil)
|
|
||||||
if err != nil {
|
|
||||||
m.logger.Error("failed to update notification", zap.Error(err))
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue