-
Notifications
You must be signed in to change notification settings - Fork 502
feat: scheduled message API #16297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: scheduled message API #16297
Conversation
Signed-off-by: Anna Larch <[email protected]>
| #[RequirePermission(permission: RequirePermission::CHAT)] | ||
| #[RequireReadWriteConversation] | ||
| #[ApiRoute(verb: 'GET', url: '/api/{apiVersion}/chat/{token}/schedule', requirements: [ | ||
| 'apiVersion' => '(v4)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chat should be v1 still
| 'token' => '[a-z0-9]{4,30}', | ||
| ])] | ||
| public function scheduledMessages(): DataResponse { | ||
| if ($this->room->getType() !== Room::TYPE_GROUP && $this->room->getType() !== Room::TYPE_ONE_TO_ONE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is TYPE_PUBLIC not supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users that joined via public link (even when they're full users) are not persisted as participants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is different, a room has TYPE_GROUP when no guest can join, but is has TYPE_PUBLIC if it's joinable by guests (but it means that there are still participants/users).
| $data = $scheduledMessages; | ||
| return new DataResponse($data, Http::STATUS_CREATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $data = $scheduledMessages; | |
| return new DataResponse($data, Http::STATUS_CREATED); | |
| return new DataResponse($scheduledMessages, Http::STATUS_CREATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIP
| * The author and timestamp are automatically set to the current user | ||
| * and time. | ||
| * | ||
| * Required capability: `scheduled-messages` | ||
| * | ||
| * @param string $message the message to send | ||
| * @param int $replyTo Parent id which this message is a reply to | ||
| * @psalm-param non-negative-int $replyTo | ||
| * @param bool $silent If sent silent the chat message will not create any notifications | ||
| * @param string $threadTitle Only supported when not replying, when given will create a thread (requires `threads` capability) | ||
| * @param int $threadId Thread id which this message is a reply to without quoting a specific message (ignored when $replyTo is given, also requires `threads` capability) | ||
| * @return DataResponse<Http::STATUS_CREATED, TalkScheduledMessage, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND|Http::STATUS_REQUEST_ENTITY_TOO_LARGE|Http::STATUS_TOO_MANY_REQUESTS, array{error: string}, array{}> | ||
| * | ||
| * 201: Message scheduled successfully | ||
| * 400: Scheduled message is not possible | ||
| * 404: Actor not found | ||
| * 413: Message too long |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from setting?
| * @psalm-param non-negative-int $replyTo | ||
| * @param bool $silent If sent silent the chat message will not create any notifications | ||
| * @param string $threadTitle Only supported when not replying, when given will create a thread (requires `threads` capability) | ||
| * @param int $threadId Thread id which this message is a reply to without quoting a specific message (ignored when $replyTo is given, also requires `threads` capability) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- @param int $threadId Thread id [...] (ignored when $replyTo is given, also requires
threadscapability)
Wondering if that is correct? When we support replies, we also support replies in threads, or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy pasted, need to look into it
| protected IURLGenerator $url, | ||
| protected IL10N $l, | ||
| protected ThreadService $threadService, | ||
| protected ScheduledMessageService $scheduledMessageService, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it unused in room controller?
| 'notnull' => true, | ||
| ]); | ||
| $table->addColumn('send_at', Types::DATETIME, [ | ||
| 'notnull' => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, we can leave it nullable because then it's just a hop and a jump to supporting drafts
| protected string $message = ''; | ||
| protected string $messageType = ''; | ||
| protected ?string $metaData = null; | ||
| protected ?\DateTime $createdAt = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be null, when the DB has it as nonnull => true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it can, but it would fail if I didn't set the param as new \DateTime() in the constructor
| $this->addType('room_id', Types::INTEGER); | ||
| $this->addType('actorId', Types::STRING); | ||
| $this->addType('actorType', Types::STRING); | ||
| $this->addType('threadId', Types::INTEGER); | ||
| $this->addType('parentId', Types::INTEGER); | ||
| $this->addType('message', Types::TEXT); | ||
| $this->addType('messageType', Types::STRING); | ||
| $this->addType('metaData', Types::TEXT); | ||
| $this->addType('sendAt', Types::DATETIME); | ||
| $this->addType('createdAt', Types::DATETIME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $this->addType('room_id', Types::INTEGER); | |
| $this->addType('actorId', Types::STRING); | |
| $this->addType('actorType', Types::STRING); | |
| $this->addType('threadId', Types::INTEGER); | |
| $this->addType('parentId', Types::INTEGER); | |
| $this->addType('message', Types::TEXT); | |
| $this->addType('messageType', Types::STRING); | |
| $this->addType('metaData', Types::TEXT); | |
| $this->addType('sendAt', Types::DATETIME); | |
| $this->addType('createdAt', Types::DATETIME); | |
| $this->addType('room_id', Types::BIGINT); | |
| $this->addType('actorId', Types::STRING); | |
| $this->addType('actorType', Types::STRING); | |
| $this->addType('threadId', Types::BIGINT); | |
| $this->addType('parentId', Types::BIGINT); | |
| $this->addType('message', Types::TEXT); | |
| $this->addType('messageType', Types::STRING); | |
| $this->addType('metaData', Types::TEXT); | |
| $this->addType('sendAt', Types::DATETIME); | |
| $this->addType('createdAt', Types::DATETIME); |
Not sure if this also needs to be BIGINT as in the migration?
| #[\Override] | ||
| public function jsonSerialize(): array { | ||
| return [ | ||
| 'roomId' => $this->getRoomId(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the ID here as well?
| ) { | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ) { | |
| } | |
| ) { | |
| $this->commentsManager = $commentsManager | |
| } |
☑️ Resolves
API part for #3954
🛠️ API Checklist
🚧 Tasks
🏁 Checklist
docs/has been updated or is not required