[feature] Add support for the exclude_types[] parameter on the notifications endpoint (#784)

* Add support for the exclude_types[] parameter on the notifications endpoint

* Add swagger docs to notifications
This commit is contained in:
Blackle Morisanchetto 2022-08-31 13:20:52 -04:00 committed by GitHub
commit ecb97f4e0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 172 additions and 12 deletions

View file

@ -56,7 +56,7 @@ func (n *notificationDB) GetNotification(ctx context.Context, id string) (*gtsmo
return &dst, nil
}
func (n *notificationDB) GetNotifications(ctx context.Context, accountID string, limit int, maxID string, sinceID string) ([]*gtsmodel.Notification, db.Error) {
func (n *notificationDB) GetNotifications(ctx context.Context, accountID string, excludeTypes []string, limit int, maxID string, sinceID string) ([]*gtsmodel.Notification, db.Error) {
// Ensure reasonable
if limit < 0 {
limit = 0
@ -78,6 +78,10 @@ func (n *notificationDB) GetNotifications(ctx context.Context, accountID string,
q = q.Where("id > ?", sinceID)
}
for _, excludeType := range excludeTypes {
q = q.Where("notification_type != ?", excludeType)
}
q = q.
Where("target_account_id = ?", accountID).
Order("id DESC")