mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
fix(avatar): Return the conversation data and fix the documentation
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
7cd0c18108
commit
4bcdacd743
2 changed files with 36 additions and 20 deletions
|
|
@ -424,7 +424,7 @@ Get all (for moderators and in case of "free selection") or the assigned breakou
|
|||
+ `403 Forbidden` When the current user is not a moderator/owner or the conversation is not a public conversation
|
||||
+ `404 Not Found` When the conversation could not be found for the participant
|
||||
|
||||
## Handle the avatar of conversation
|
||||
## Set conversations avatar
|
||||
|
||||
* ⚠️ Preview - Might be modified before the capability is added
|
||||
* Required capability: `avatar`
|
||||
|
|
@ -433,16 +433,21 @@ Get all (for moderators and in case of "free selection") or the assigned breakou
|
|||
* Data:
|
||||
|
||||
| field | type | Description |
|
||||
| ------ | ------ | ----------------------------------------------------------------------------------------------------------------------------------- |
|
||||
|--------|--------|-------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `file` | string | Blob of image in a multipart/form-data request. Only accept images with mimetype equal to PNG or JPEG and need to be squared image. |
|
||||
|
||||
* Response:
|
||||
- Status code:
|
||||
+ `200 OK`
|
||||
+ `400 Bad Request` When: is one2one, no image, file is too big, invalid mimetype or resource, isn't square, unknown error
|
||||
+ `400 Bad Request` When: is one-to-one, no image, file is too big, invalid mimetype or resource, isn't square, unknown error
|
||||
+ `403 Forbidden` When the current user is not a moderator, owner or guest moderator
|
||||
+ `404 Not Found` When the conversation could not be found for the participant
|
||||
|
||||
- Data: See array definition in `Get user´s conversations`
|
||||
|
||||
## Delete conversations avatar
|
||||
|
||||
* ⚠️ Preview - Might be modified before the capability is added
|
||||
* Required capability: `avatar`
|
||||
* Method: `DELETE`
|
||||
* Endpoint: `/room/{token}/avatar`
|
||||
|
|
@ -453,6 +458,11 @@ Get all (for moderators and in case of "free selection") or the assigned breakou
|
|||
+ `403 Forbidden` When the current user is not a moderator, owner or guest moderator
|
||||
+ `404 Not Found` When the conversation could not be found for the participant
|
||||
|
||||
- Data: See array definition in `Get user´s conversations`
|
||||
|
||||
## Get conversations avatar (binary)
|
||||
|
||||
* ⚠️ Preview - Might be modified before the capability is added
|
||||
* Required capability: `avatar`
|
||||
* Method: `GET`
|
||||
* Endpoint: `/room/{token}/avatar`
|
||||
|
|
@ -461,7 +471,11 @@ Get all (for moderators and in case of "free selection") or the assigned breakou
|
|||
- Status code:
|
||||
+ `200 OK`
|
||||
+ `404 Not Found` When the conversation could not be found for the participant
|
||||
- Body: the image file
|
||||
|
||||
## Get dark mode conversations avatar (binary)
|
||||
|
||||
* ⚠️ Preview - Might be modified before the capability is added
|
||||
* Required capability: `avatar`
|
||||
* Method: `GET`
|
||||
* Endpoint: `/room/{token}/avatar/dark`
|
||||
|
|
@ -470,3 +484,4 @@ Get all (for moderators and in case of "free selection") or the assigned breakou
|
|||
- Status code:
|
||||
+ `200 OK`
|
||||
+ `404 Not Found` When the conversation could not be found for the participant
|
||||
- Body: the image file
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace OCA\Talk\Controller;
|
|||
|
||||
use InvalidArgumentException;
|
||||
use OCA\Talk\Service\AvatarService;
|
||||
use OCA\Talk\Service\RoomFormatter;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\FileDisplayResponse;
|
||||
|
|
@ -38,24 +39,16 @@ use OCP\IUserSession;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class AvatarController extends AEnvironmentAwareController {
|
||||
private AvatarService $avatarService;
|
||||
private IUserSession $userSession;
|
||||
private IL10N $l;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
AvatarService $avatarService,
|
||||
IUserSession $userSession,
|
||||
IL10N $l10n,
|
||||
LoggerInterface $logger
|
||||
protected RoomFormatter $roomFormatter,
|
||||
protected AvatarService $avatarService,
|
||||
protected IUserSession $userSession,
|
||||
protected IL10N $l,
|
||||
protected LoggerInterface $logger
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->avatarService = $avatarService;
|
||||
$this->userSession = $userSession;
|
||||
$this->l = $l10n;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -66,9 +59,12 @@ class AvatarController extends AEnvironmentAwareController {
|
|||
try {
|
||||
$file = $this->request->getUploadedFile('file');
|
||||
$this->avatarService->setAvatarFromRequest($this->getRoom(), $file);
|
||||
return new DataResponse([
|
||||
'avatar' => $this->avatarService->getAvatarUrl($this->getRoom()),
|
||||
]);
|
||||
return new DataResponse($this->roomFormatter->formatRoom(
|
||||
$this->getResponseFormat(),
|
||||
[],
|
||||
$this->getRoom(),
|
||||
$this->participant,
|
||||
));
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -110,6 +106,11 @@ class AvatarController extends AEnvironmentAwareController {
|
|||
*/
|
||||
public function deleteAvatar(): DataResponse {
|
||||
$this->avatarService->deleteAvatar($this->getRoom());
|
||||
return new DataResponse([]);
|
||||
return new DataResponse($this->roomFormatter->formatRoom(
|
||||
$this->getResponseFormat(),
|
||||
[],
|
||||
$this->getRoom(),
|
||||
$this->participant,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue