summaryrefslogtreecommitdiff
path: root/internal/message/notificationsprocess.go
blob: 64726b75ffd610f240db81188c0252aacd6edd98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package message

import (
	apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
	"github.com/superseriousbusiness/gotosocial/internal/oauth"
)

func (p *processor) NotificationsGet(authed *oauth.Auth, limit int, maxID string) ([]*apimodel.Notification, ErrorWithCode) {
	notifs, err := p.db.GetNotificationsForAccount(authed.Account.ID, limit, maxID)
	if err != nil {
		return nil, NewErrorInternalError(err)
	}

	mastoNotifs := []*apimodel.Notification{}
	for _, n := range notifs {
		mastoNotif, err := p.tc.NotificationToMasto(n)
		if err != nil {
			return nil, NewErrorInternalError(err)
		}
		mastoNotifs = append(mastoNotifs, mastoNotif)
	}

	return mastoNotifs, nil
}