1111
1212use Exception ;
1313use InvalidArgumentException ;
14- use OCA \NotifyPush \Queue \IQueue ;
1514use OCA \Text \Context \ContextManager ;
1615use OCA \Text \Context \IContext ;
1716use OCA \Text \Context \NewSessionData ;
3029
3130class ApiService {
3231 public function __construct (
33- private readonly ConfigService $ configService ,
3432 private readonly ContextManager $ contextManager ,
3533 private readonly SessionService $ sessionService ,
3634 private readonly DocumentService $ documentService ,
3735 private readonly FileService $ fileService ,
3836 private readonly LoggerInterface $ logger ,
3937 private readonly LockService $ lockService ,
4038 private readonly IL10N $ l10n ,
41- private readonly ? IQueue $ queue ,
39+ private readonly PushService $ pushService ,
4240 ) {
4341 }
4442
@@ -98,8 +96,7 @@ public function push(Session $session, Document $document, int $version, array $
9896 return new DataResponse (['error ' => $ this ->l10n ->t ('Editing session has expired. Please reload the page. ' )], Http::STATUS_PRECONDITION_FAILED );
9997 }
10098 try {
101- $ result = $ this ->documentService ->addStep ($ document , $ session , $ steps , $ version , $ recoveryAttempt , $ token );
102- $ this ->addToPushQueue ($ document , [$ awareness , ...array_values ($ steps )]);
99+ $ result = $ this ->pushService ->push ($ session , $ document , $ version , $ steps , $ awareness , $ recoveryAttempt , $ token );
103100 } catch (InvalidArgumentException $ e ) {
104101 return new DataResponse (['error ' => $ e ->getMessage ()], Http::STATUS_UNPROCESSABLE_ENTITY );
105102 } catch (DoesNotExistException ) {
@@ -111,27 +108,6 @@ public function push(Session $session, Document $document, int $version, array $
111108 return new DataResponse ($ result );
112109 }
113110
114- private function addToPushQueue (Document $ document , array $ steps ): void {
115- if ($ this ->queue === null || !$ this ->configService ->isNotifyPushSyncEnabled ()) {
116- return ;
117- }
118-
119- $ sessions = $ this ->sessionService ->getActiveSessions ($ document ->id );
120- $ userIds = array_values (array_filter (array_unique (
121- array_map (fn ($ session ): ?string => $ session ['userId ' ], $ sessions )
122- )));
123- foreach ($ userIds as $ userId ) {
124- $ this ->queue ->push ('notify_custom ' , [
125- 'user ' => $ userId ,
126- 'message ' => 'text_steps ' ,
127- 'body ' => [
128- 'documentId ' => $ document ->getId (),
129- 'steps ' => array_values (array_filter ($ steps )),
130- ],
131- ]);
132- }
133- }
134-
135111 public function sync (Session $ session , Document $ document , int $ version = 0 , ?string $ shareToken = null ): DataResponse {
136112 $ documentId = $ session ->getDocumentId ();
137113 $ result = [];
0 commit comments