-
Notifications
You must be signed in to change notification settings - Fork 20
/
motion_state.go
35 lines (28 loc) · 931 Bytes
/
motion_state.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"
)
// MotionState handels restrictions of the collection motion_state.
type MotionState struct{}
// Modes returns the restrictions modes for the meeting collection.
func (m MotionState) Modes(mode string) FieldRestricter {
switch mode {
case "A":
return m.see
}
return nil
}
func (m MotionState) see(ctx context.Context, ds *datastore.Request, mperms *perm.MeetingPermission, motionStateID int) (bool, error) {
meetingID, err := ds.MotionState_MeetingID(motionStateID).Value(ctx)
if err != nil {
return false, fmt.Errorf("getting meetingID: %w", err)
}
perms, err := mperms.Meeting(ctx, meetingID)
if err != nil {
return false, fmt.Errorf("getting permission: %w", err)
}
return perms.Has(perm.MotionCanSee), nil
}