|
| 1 | +package collection |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + |
| 7 | + "github.com/OpenSlides/openslides-autoupdate-service/internal/restrict/perm" |
| 8 | + "github.com/OpenSlides/openslides-autoupdate-service/pkg/datastore/dsfetch" |
| 9 | +) |
| 10 | + |
| 11 | +// MotionWorkingGroupSpeaker handels restrictions of the collection motion_working_group_speaker. |
| 12 | +// |
| 13 | +// The user can see a motion_working_group_speaker if he has `motion.can_manage_metadata` |
| 14 | +// |
| 15 | +// Mode A: The user can see the motion working group speaker. |
| 16 | +type MotionWorkingGroupSpeaker struct{} |
| 17 | + |
| 18 | +// Name returns the collection name. |
| 19 | +func (m MotionWorkingGroupSpeaker) Name() string { |
| 20 | + return "motion_working_group_speaker" |
| 21 | +} |
| 22 | + |
| 23 | +// MeetingID returns the meetingID for the object. |
| 24 | +func (m MotionWorkingGroupSpeaker) MeetingID(ctx context.Context, ds *dsfetch.Fetch, id int) (int, bool, error) { |
| 25 | + meetingID, err := ds.MotionWorkingGroupSpeaker_MeetingID(id).Value(ctx) |
| 26 | + if err != nil { |
| 27 | + return 0, false, fmt.Errorf("get meeting id: %w", err) |
| 28 | + } |
| 29 | + |
| 30 | + return meetingID, true, nil |
| 31 | +} |
| 32 | + |
| 33 | +// Modes returns the restrictions modes for the meeting collection. |
| 34 | +func (m MotionWorkingGroupSpeaker) Modes(mode string) FieldRestricter { |
| 35 | + switch mode { |
| 36 | + case "A": |
| 37 | + return m.see |
| 38 | + } |
| 39 | + return nil |
| 40 | +} |
| 41 | + |
| 42 | +func (m MotionWorkingGroupSpeaker) see(ctx context.Context, ds *dsfetch.Fetch, motionWorkingGroupSpeakerIDs ...int) ([]int, error) { |
| 43 | + return meetingPerm(ctx, ds, m, motionWorkingGroupSpeakerIDs, perm.MotionCanManageMetadata) |
| 44 | +} |
0 commit comments