|
1 | 1 | <?php
|
2 | 2 |
|
| 3 | +use GuzzleHttp\Exception\BadResponseException; |
| 4 | + |
3 | 5 | class PluginLibresignHook extends CommonDBTM
|
4 | 6 | {
|
5 | 7 | public static function itemUpdate(TicketValidation $ticket)
|
@@ -64,8 +66,8 @@ public static function preItemPurge(TicketValidation $ticket)
|
64 | 66 | {
|
65 | 67 | try {
|
66 | 68 | $iterator = self::getSignRequests([
|
67 |
| - 'ticket_id' => $ticket->input['tickets_id'], |
68 |
| - 'user_id' => $ticket->input['users_id_validate'] |
| 69 | + 'ticket_id' => $ticket->fields['tickets_id'], |
| 70 | + 'user_id' => $ticket->fields['users_id_validate'] |
69 | 71 | ]);
|
70 | 72 | if (!count($iterator)) {
|
71 | 73 | throw new Exception(__('No signer found'));
|
@@ -95,15 +97,24 @@ private static function requestDeleteSigner(string $uuid, string $email)
|
95 | 97 |
|
96 | 98 | include_once(Plugin::getPhpDir('libresign').'/inc/httpclient.class.php');
|
97 | 99 | $client = new PluginLibresignHttpclient();
|
98 |
| - $client->request('DELETE', $config->fields['nextcloud_url'] . '/signature', [ |
99 |
| - 'json' => [ |
100 |
| - 'uuid' => $uuid, |
101 |
| - 'users' => [ |
102 |
| - ['email' => $email] |
103 |
| - ] |
104 |
| - ], |
105 |
| - 'auth' => [$config->fields['username'], $config->fields['password']] |
106 |
| - ]); |
| 100 | + try { |
| 101 | + $client->delete($config->fields['nextcloud_url'] . '/signature', [ |
| 102 | + 'json' => [ |
| 103 | + 'uuid' => $uuid, |
| 104 | + 'users' => [ |
| 105 | + ['email' => $email] |
| 106 | + ] |
| 107 | + ], |
| 108 | + 'auth' => [$config->fields['username'], $config->fields['password']] |
| 109 | + ]); |
| 110 | + } catch (BadResponseException $e) { |
| 111 | + $return = $e->getResponse()->getBody()->getContents(); |
| 112 | + $json = json_decode($return); |
| 113 | + if ($json && $json->message) { |
| 114 | + throw new Exception(__($json->message)); |
| 115 | + } |
| 116 | + throw new Exception($return); |
| 117 | + } |
107 | 118 | }
|
108 | 119 |
|
109 | 120 | private static function getSignRequests($filter)
|
|
0 commit comments