Allow to pass activity center status as a parameter
This commit is contained in:
parent
e48083e31d
commit
7662cd613a
|
@ -285,11 +285,12 @@ func (db sqlitePersistence) unmarshalActivityCenterNotificationRows(rows *sql.Ro
|
|||
|
||||
}
|
||||
|
||||
type activityCenterQueryParamsRead uint
|
||||
type ActivityCenterQueryParamsRead uint
|
||||
|
||||
const (
|
||||
activityCenterQueryParamsReadRead = iota + 1
|
||||
activityCenterQueryParamsReadUnread
|
||||
ActivityCenterQueryParamsReadRead = iota + 1
|
||||
ActivityCenterQueryParamsReadUnread
|
||||
ActivityCenterQueryParamsReadAll
|
||||
)
|
||||
|
||||
type activityCenterQueryParams struct {
|
||||
|
@ -298,7 +299,7 @@ type activityCenterQueryParams struct {
|
|||
ids []types.HexBytes
|
||||
chatID string
|
||||
author string
|
||||
read activityCenterQueryParamsRead
|
||||
read ActivityCenterQueryParamsRead
|
||||
activityCenterType ActivityCenterType
|
||||
}
|
||||
|
||||
|
@ -331,9 +332,9 @@ func (db sqlitePersistence) buildActivityCenterQuery(tx *sql.Tx, params activity
|
|||
}
|
||||
|
||||
switch read {
|
||||
case activityCenterQueryParamsReadRead:
|
||||
case ActivityCenterQueryParamsReadRead:
|
||||
readWhere = "AND a.read = 1"
|
||||
case activityCenterQueryParamsReadUnread:
|
||||
case ActivityCenterQueryParamsReadUnread:
|
||||
readWhere = "AND NOT(a.read)"
|
||||
}
|
||||
|
||||
|
@ -508,7 +509,7 @@ func (db sqlitePersistence) UnreadActivityCenterNotifications(cursor string, lim
|
|||
activityCenterType: activityType,
|
||||
cursor: cursor,
|
||||
limit: limit,
|
||||
read: activityCenterQueryParamsReadUnread,
|
||||
read: ActivityCenterQueryParamsReadUnread,
|
||||
}
|
||||
|
||||
return db.activityCenterNotifications(params)
|
||||
|
@ -519,7 +520,18 @@ func (db sqlitePersistence) ReadActivityCenterNotifications(cursor string, limit
|
|||
activityCenterType: activityType,
|
||||
cursor: cursor,
|
||||
limit: limit,
|
||||
read: activityCenterQueryParamsReadRead,
|
||||
read: ActivityCenterQueryParamsReadRead,
|
||||
}
|
||||
|
||||
return db.activityCenterNotifications(params)
|
||||
}
|
||||
|
||||
func (db sqlitePersistence) ActivityCenterNotificationsBy(cursor string, limit uint64, activityType ActivityCenterType, readType ActivityCenterQueryParamsRead) (string, []*ActivityCenterNotification, error) {
|
||||
params := activityCenterQueryParams{
|
||||
activityCenterType: activityType,
|
||||
cursor: cursor,
|
||||
limit: limit,
|
||||
read: readType,
|
||||
}
|
||||
|
||||
return db.activityCenterNotifications(params)
|
||||
|
|
|
@ -267,6 +267,18 @@ func (m *Messenger) UnreadActivityCenterNotifications(cursor string, limit uint6
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (m *Messenger) ActivityCenterNotificationsBy(cursor string, limit uint64, activityType ActivityCenterType, readType ActivityCenterQueryParamsRead) (*ActivityCenterPaginationResponse, error) {
|
||||
cursor, notifications, err := m.persistence.ActivityCenterNotificationsBy(cursor, limit, activityType, readType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &ActivityCenterPaginationResponse{
|
||||
Cursor: cursor,
|
||||
Notifications: notifications,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m *Messenger) handleActivityCenterRead(state *ReceivedMessageState, message protobuf.SyncActivityCenterRead) error {
|
||||
resp, err := m.MarkActivityCenterNotificationsRead(context.TODO(), toHexBytes(message.Ids), false)
|
||||
|
||||
|
|
|
@ -1085,6 +1085,10 @@ func (api *PublicAPI) UnreadActivityCenterNotifications(cursor string, limit uin
|
|||
return api.service.messenger.UnreadActivityCenterNotifications(cursor, limit, activityType)
|
||||
}
|
||||
|
||||
func (api *PublicAPI) ActivityCenterNotificationsBy(cursor string, limit uint64, activityType protocol.ActivityCenterType, readType protocol.ActivityCenterQueryParamsRead) (*protocol.ActivityCenterPaginationResponse, error) {
|
||||
return api.service.messenger.ActivityCenterNotificationsBy(cursor, limit, activityType, readType)
|
||||
}
|
||||
|
||||
func (api *PublicAPI) RequestAllHistoricMessages() (*protocol.MessengerResponse, error) {
|
||||
return api.service.messenger.RequestAllHistoricMessages()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue