29
29
use OCA \Talk \AppInfo \Application ;
30
30
use OCA \Talk \BackgroundJob \RetryJob ;
31
31
use OCA \Talk \Exceptions \RoomHasNoModeratorException ;
32
- use OCA \Talk \Model \Attendee ;
33
- use OCA \Talk \Model \AttendeeMapper ;
34
- use OCA \Talk \Participant ;
35
32
use OCA \Talk \Room ;
33
+ use OCA \Talk \Service \ParticipantService ;
36
34
use OCP \BackgroundJob \IJobList ;
37
35
use OCP \Federation \ICloudFederationFactory ;
38
36
use OCP \Federation \ICloudFederationNotification ;
@@ -60,8 +58,8 @@ class Notifications {
60
58
/** @var IUserManager */
61
59
private $ userManager ;
62
60
63
- /** @var AttendeeMapper */
64
- private $ attendeeMapper ;
61
+ /** @var ParticipantService */
62
+ private $ participantService ;
65
63
66
64
public function __construct (
67
65
ICloudFederationFactory $ cloudFederationFactory ,
@@ -70,15 +68,15 @@ public function __construct(
70
68
ICloudFederationProviderManager $ federationProviderManager ,
71
69
IJobList $ jobList ,
72
70
IUserManager $ userManager ,
73
- AttendeeMapper $ attendeeMapper
71
+ ParticipantService $ participantService
74
72
) {
75
73
$ this ->cloudFederationFactory = $ cloudFederationFactory ;
76
74
$ this ->addressHandler = $ addressHandler ;
77
75
$ this ->logger = $ logger ;
78
76
$ this ->federationProviderManager = $ federationProviderManager ;
79
77
$ this ->jobList = $ jobList ;
80
78
$ this ->userManager = $ userManager ;
81
- $ this ->attendeeMapper = $ attendeeMapper ;
79
+ $ this ->participantService = $ participantService ;
82
80
}
83
81
84
82
/**
@@ -104,21 +102,11 @@ public function sendRemoteShare(string $providerId, string $token, string $share
104
102
105
103
/** @var IUser|null $roomOwner */
106
104
$ roomOwner = null ;
107
- try {
108
- $ roomOwners = $ this ->attendeeMapper ->getActorsByParticipantTypes ($ room ->getId (), [Participant::OWNER ]);
109
- if (!empty ($ roomOwners ) && $ roomOwners [0 ]->getActorType () === Attendee::ACTOR_USERS ) {
110
- $ roomOwner = $ this ->userManager ->get ($ roomOwners [0 ]->getActorId ());
111
- }
112
- } catch (\Exception $ e ) {
113
- // Get a local moderator instead
114
- try {
115
- $ roomOwners = $ this ->attendeeMapper ->getActorsByParticipantTypes ($ room ->getId (), [Participant::MODERATOR ]);
116
- if (!empty ($ roomOwners ) && $ roomOwners [0 ]->getActorType () === Attendee::ACTOR_USERS ) {
117
- $ roomOwner = $ this ->userManager ->get ($ roomOwners [0 ]->getActorId ());
118
- }
119
- } catch (\Exception $ e ) {
120
- throw new RoomHasNoModeratorException ();
121
- }
105
+ $ roomOwnerAttendee = $ this ->participantService ->getHighestPermissionAttendee ($ room );
106
+ if ($ roomOwnerAttendee ) {
107
+ $ roomOwner = $ this ->userManager ->get ($ roomOwnerAttendee ->getActorId ());
108
+ } else {
109
+ throw new RoomHasNoModeratorException ();
122
110
}
123
111
124
112
$ remote = $ this ->prepareRemoteUrl ($ remote );
@@ -141,7 +129,7 @@ public function sendRemoteShare(string $providerId, string $token, string $share
141
129
$ protocol = $ share ->getProtocol ();
142
130
$ protocol ['roomName ' ] = $ roomName ;
143
131
$ protocol ['roomType ' ] = $ roomType ;
144
- $ protocol ['name ' ] = ' nctalk ' ;
132
+ $ protocol ['name ' ] = FederationManager:: TALK_PROTOCOL_NAME ;
145
133
$ share ->setProtocol ($ protocol );
146
134
147
135
$ response = $ this ->federationProviderManager ->sendShare ($ share );
0 commit comments