-
Notifications
You must be signed in to change notification settings - Fork 21
/
topic.go
35 lines (28 loc) · 912 Bytes
/
topic.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package collection
import (
"context"
"fmt"
"github.com/OpenSlides/openslides-autoupdate-service/internal/restrict/perm"
"github.com/OpenSlides/openslides-autoupdate-service/pkg/datastore"
)
// Topic handels the restrictions for the topic collection.
type Topic struct{}
// Modes returns the field restriction for each mode.
func (t Topic) Modes(mode string) FieldRestricter {
switch mode {
case "A":
return t.see
}
return nil
}
func (t Topic) see(ctx context.Context, ds *datastore.Request, mperms *perm.MeetingPermission, topicID int) (bool, error) {
meetingID, err := ds.Topic_MeetingID(topicID).Value(ctx)
if err != nil {
return false, fmt.Errorf("fetching meeting_id %d: %w", topicID, err)
}
perms, err := mperms.Meeting(ctx, meetingID)
if err != nil {
return false, fmt.Errorf("getting perms for meeting %d: %w", meetingID, err)
}
return perms.Has(perm.AgendaItemCanSee), nil
}