1 | <?php |
||
40 | class FederatedController extends BaseController { |
||
41 | |||
42 | /** @var string */ |
||
43 | protected $userId; |
||
44 | |||
45 | /** @var IL10N */ |
||
46 | protected $l10n; |
||
47 | |||
48 | /** @var ConfigService */ |
||
49 | protected $configService; |
||
50 | |||
51 | /** @var CirclesService */ |
||
52 | protected $circlesService; |
||
53 | |||
54 | /** @var MembersService */ |
||
55 | protected $membersService; |
||
56 | |||
57 | /** @var SharesService */ |
||
58 | protected $sharesService; |
||
59 | |||
60 | /** @var FederatedService */ |
||
61 | protected $federatedService; |
||
62 | |||
63 | /** @var MiscService */ |
||
64 | protected $miscService; |
||
65 | |||
66 | |||
67 | /** |
||
68 | * requestedLink() |
||
69 | * |
||
70 | * Called when a remote circle want to create a link. |
||
71 | * The function check if it is possible first; then create a link- object |
||
72 | * and sent it to be saved in the database. |
||
73 | * |
||
74 | * @PublicPage |
||
75 | * @NoCSRFRequired |
||
76 | * |
||
77 | * @param string $token |
||
78 | * @param string $uniqueId |
||
79 | * @param string $sourceName |
||
80 | * @param string $linkTo |
||
81 | * @param string $address |
||
82 | * |
||
83 | * @return DataResponse |
||
84 | */ |
||
85 | public function requestedLink($token, $uniqueId, $sourceName, $linkTo, $address) { |
||
118 | |||
119 | |||
120 | /** |
||
121 | * initFederatedDelivery() |
||
122 | * |
||
123 | * Note: this function will close the request mid-run from the client but will still |
||
124 | * running its process. |
||
125 | * Called by locally, the function will get the payload by its uniqueId from the database, and |
||
126 | * will deliver it to each remotes linked to the circle the payload belongs to. |
||
127 | * A status response is sent to free the client process before starting to broadcast the item |
||
128 | * to other federated links. |
||
129 | * |
||
130 | * @PublicPage |
||
131 | * @NoCSRFRequired |
||
132 | */ |
||
133 | public function initFederatedDelivery($uniqueId) { |
||
145 | |||
146 | |||
147 | /** |
||
148 | * shareFederatedItem() |
||
149 | * |
||
150 | * Note: this function will close the request mid-run from the client but will still |
||
151 | * running its process. |
||
152 | * Called by a remote circle to broadcast a Share item, the function will save the item |
||
153 | * in the database and broadcast it locally. A status response is sent to the remote to free |
||
154 | * the remote process before starting to broadcast the item to other federated links. |
||
155 | * |
||
156 | * @PublicPage |
||
157 | * @NoCSRFRequired |
||
158 | */ |
||
159 | public function receiveFederatedDelivery() { |
||
171 | |||
172 | /** |
||
173 | * Hacky way to async the rest of the process without keeping client on hold. |
||
174 | * |
||
175 | * @param string $result |
||
176 | */ |
||
177 | private function asyncAndLeaveClientOutOfThis($result = '') { |
||
191 | |||
192 | /** |
||
193 | * send a positive response to a request with an array of data, and confirm |
||
194 | * the identity of the link with a token |
||
195 | * |
||
196 | * @param array $data |
||
197 | * @param FederatedLink $link |
||
198 | * |
||
199 | * @return DataResponse |
||
200 | */ |
||
201 | private function federatedSuccess($data, $link) { |
||
207 | |||
208 | /** |
||
209 | * send a negative response to a request, with a reason of the failure. |
||
210 | * |
||
211 | * @param string $reason |
||
212 | * |
||
213 | * @return DataResponse |
||
214 | */ |
||
215 | private function federatedFail($reason) { |
||
224 | } |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.