-
Notifications
You must be signed in to change notification settings - Fork 21
/
projection.go
35 lines (28 loc) · 969 Bytes
/
projection.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"
)
// Projection handels the restriction for the projection collection.
type Projection struct{}
// Modes returns the restrictions modes for the meeting collection.
func (p Projection) Modes(mode string) FieldRestricter {
switch mode {
case "A":
return p.see
}
return nil
}
func (p Projection) see(ctx context.Context, ds *datastore.Request, mperms *perm.MeetingPermission, projectionID int) (bool, error) {
meetingID, err := ds.Projection_MeetingID(projectionID).Value(ctx)
if err != nil {
return false, fmt.Errorf("fetching meeting_id %d: %w", projectionID, 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.ProjectorCanSee), nil
}