@@ -496,3 +496,104 @@ func (h *HandlerService) pastMeetingParticipantPutHandler(message INatsMsg) erro
496496func (h * HandlerService ) pastMeetingParticipantRemoveHandler (message INatsMsg ) error {
497497 return h .processPastMeetingParticipantMessage (message , pastMeetingParticipantRemove )
498498}
499+
500+ type pastMeetingAttachmentStub struct {
501+ UID string `json:"uid"`
502+ PastMeetingUID string `json:"past_meeting_uid"`
503+ }
504+
505+ // buildPastMeetingAttachmentTuples builds all of the tuples for a past meeting attachment object.
506+ func (h * HandlerService ) buildPastMeetingAttachmentTuples (
507+ object string ,
508+ attachment * pastMeetingAttachmentStub ,
509+ ) ([]client.ClientTupleKey , error ) {
510+ tuples := h .fgaService .NewTupleKeySlice (1 )
511+
512+ // Add the past_meeting relation to associate this attachment with its past meeting
513+ if attachment .PastMeetingUID != "" {
514+ tuples = append (
515+ tuples ,
516+ h .fgaService .TupleKey (
517+ constants .ObjectTypePastMeeting + attachment .PastMeetingUID ,
518+ constants .RelationPastMeeting ,
519+ object ,
520+ ),
521+ )
522+ }
523+
524+ return tuples , nil
525+ }
526+
527+ // pastMeetingAttachmentUpdateAccessHandler handles past meeting attachment access control updates.
528+ func (h * HandlerService ) pastMeetingAttachmentUpdateAccessHandler (message INatsMsg ) error {
529+ ctx := context .Background ()
530+
531+ logger .With ("message" , string (message .Data ())).InfoContext (
532+ ctx ,
533+ "handling past meeting attachment access control update" ,
534+ )
535+
536+ // Parse the event data.
537+ attachment := new (pastMeetingAttachmentStub )
538+ var err error
539+ err = json .Unmarshal (message .Data (), attachment )
540+ if err != nil {
541+ logger .With (errKey , err ).ErrorContext (ctx , "event data parse error" )
542+ return err
543+ }
544+
545+ // Validate required fields.
546+ if attachment .UID == "" {
547+ logger .ErrorContext (ctx , "past meeting attachment UID not found" )
548+ return errors .New ("past meeting attachment UID not found" )
549+ }
550+ if attachment .PastMeetingUID == "" {
551+ logger .ErrorContext (ctx , "past meeting UID not found" )
552+ return errors .New ("past meeting UID not found" )
553+ }
554+
555+ object := constants .ObjectTypePastMeetingAttachment + attachment .UID
556+
557+ // Build a list of tuples to sync.
558+ //
559+ // It is important that all tuples that should exist with respect to the past meeting attachment object
560+ // should be added to this tuples list because when SyncObjectTuples is called, it will delete
561+ // all tuples that are not in the tuples list parameter.
562+ tuples , err := h .buildPastMeetingAttachmentTuples (object , attachment )
563+ if err != nil {
564+ logger .With (errKey , err , "object" , object ).ErrorContext (ctx , "failed to build past meeting attachment tuples" )
565+ return err
566+ }
567+
568+ tuplesWrites , tuplesDeletes , err := h .fgaService .SyncObjectTuples (ctx , object , tuples )
569+ if err != nil {
570+ logger .With (errKey , err , "tuples" , tuples , "object" , object ).ErrorContext (ctx , "failed to sync tuples" )
571+ return err
572+ }
573+
574+ logger .With (
575+ "tuples" , tuples ,
576+ "object" , object ,
577+ "writes" , tuplesWrites ,
578+ "deletes" , tuplesDeletes ,
579+ ).InfoContext (ctx , "synced tuples" )
580+
581+ if message .Reply () != "" {
582+ // Send a reply if an inbox was provided.
583+ if err = message .Respond ([]byte ("OK" )); err != nil {
584+ logger .With (errKey , err ).WarnContext (ctx , "failed to send reply" )
585+ return err
586+ }
587+
588+ logger .With ("object" , object ).InfoContext (ctx , "sent past meeting attachment access control update response" )
589+ }
590+
591+ return nil
592+ }
593+
594+ // pastMeetingAttachmentDeleteAccessHandler handles deleting all tuples for a past meeting attachment object.
595+ //
596+ // This should happen when a past meeting attachment is deleted.
597+ func (h * HandlerService ) pastMeetingAttachmentDeleteAccessHandler (message INatsMsg ) error {
598+ return h .processDeleteAllAccessMessage (message , constants .ObjectTypePastMeetingAttachment , "past meeting attachment" )
599+ }
0 commit comments