oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "amadan.net/oficina/equipo/internal/equipo/notifications"
5 "amadan.net/oficina/equipo/internal/equipo/personapi"
6 "gorm.io/gorm"
7 "net/http"
8)
9
10type Notification = notifications.Notification
11type NotificationSubscription = notifications.NotificationSubscription
12type NotificationApplication = notifications.Store
13
14func (s *Store) notificationApplication() *NotificationApplication {
15 return &notifications.Store{Write: s.write, Read: s.invitationRead, Authorize: func(tx *gorm.DB, a Actor) (string, error) {
16 if _, err := currentRunnerMember(tx, a.Address); err != nil {
17 return "", err
18 }
19 return runnerInstance(tx)
20 }, Audit: appendAudit, Devices: s.personDevices, Key: func() string { return s.personKey }, Now: s.runnerClock.Now, Invalid: ErrInvalid, Forbidden: ErrForbidden, NotFound: ErrNotFound, Conflict: ErrConflict, CursorExpired: ErrCursorExpired}
21}
22func (a *application) allowNotification(r *http.Request, key string) bool {
23 p, err := a.store.personCookie(r)
24 if err != nil {
25 return false
26 }
27 return a.store.AllowNotificationTopic(personapi.WithVerifiedPrincipal(r.Context(), p), Actor{Address: p.Address}, key)
28}
29