Dismiss activity center notifications of community on leave or Mark read
This commit is contained in:
parent
ca468e21e5
commit
14ed8ba5e8
|
@ -401,6 +401,30 @@ func (db sqlitePersistence) DismissActivityCenterNotifications(ids []types.HexBy
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db sqlitePersistence) DismissAllActivityCenterNotificationsFromCommunity(communityID string) error {
|
||||||
|
|
||||||
|
chatIDs, err := db.AllChatIDsByCommunity(communityID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
chatIDsCount := len(chatIDs)
|
||||||
|
if chatIDsCount == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
chatIDsArgs := make([]interface{}, 0, chatIDsCount)
|
||||||
|
for _, chatID := range chatIDs {
|
||||||
|
chatIDsArgs = append(chatIDsArgs, chatID)
|
||||||
|
}
|
||||||
|
|
||||||
|
inVector := strings.Repeat("?, ", chatIDsCount-1) + "?"
|
||||||
|
query := "UPDATE activity_center_notifications SET read = 1, dismissed = 1 WHERE chat_id IN (" + inVector + ")" // nolint: gosec
|
||||||
|
_, err = db.db.Exec(query, chatIDsArgs...)
|
||||||
|
return err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (db sqlitePersistence) AcceptAllActivityCenterNotifications() ([]*ActivityCenterNotification, error) {
|
func (db sqlitePersistence) AcceptAllActivityCenterNotifications() ([]*ActivityCenterNotification, error) {
|
||||||
var tx *sql.Tx
|
var tx *sql.Tx
|
||||||
var err error
|
var err error
|
||||||
|
|
|
@ -4080,6 +4080,11 @@ func (m *Messenger) MarkAllRead(chatID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Messenger) MarkAllReadInCommunity(communityID string) ([]string, error) {
|
func (m *Messenger) MarkAllReadInCommunity(communityID string) ([]string, error) {
|
||||||
|
err := m.persistence.DismissAllActivityCenterNotificationsFromCommunity(communityID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
chatIDs, err := m.persistence.AllChatIDsByCommunity(communityID)
|
chatIDs, err := m.persistence.AllChatIDsByCommunity(communityID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -468,6 +468,11 @@ func (m *Messenger) DeclineRequestToJoinCommunity(request *requests.DeclineReque
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Messenger) LeaveCommunity(communityID types.HexBytes) (*MessengerResponse, error) {
|
func (m *Messenger) LeaveCommunity(communityID types.HexBytes) (*MessengerResponse, error) {
|
||||||
|
err := m.persistence.DismissAllActivityCenterNotificationsFromCommunity(communityID.String())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
mr, err := m.leaveCommunity(communityID)
|
mr, err := m.leaveCommunity(communityID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue