Skip to content

Conversation

@miaulalala
Copy link
Contributor

☑️ Resolves

API part for #3954


🛠️ API Checklist

🚧 Tasks

  • ...

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not possible
  • 📘 API documentation in docs/ has been updated or is not required
  • 🔖 Capability is added or not needed

@miaulalala miaulalala added this to the 🍏 Next Major (33) milestone Nov 10, 2025
@miaulalala miaulalala self-assigned this Nov 10, 2025
#[RequirePermission(permission: RequirePermission::CHAT)]
#[RequireReadWriteConversation]
#[ApiRoute(verb: 'GET', url: '/api/{apiVersion}/chat/{token}/schedule', requirements: [
'apiVersion' => '(v4)',
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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).

Comment on lines +386 to +387
$data = $scheduledMessages;
return new DataResponse($data, Http::STATUS_CREATED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$data = $scheduledMessages;
return new DataResponse($data, Http::STATUS_CREATED);
return new DataResponse($scheduledMessages, Http::STATUS_CREATED);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP

Comment on lines +341 to +357
* 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
Copy link
Contributor

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)
Copy link
Contributor

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 threads capability)

Wondering if that is correct? When we support replies, we also support replies in threads, or not?

Copy link
Contributor Author

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,
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be true?

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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

Comment on lines +51 to +60
$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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$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(),
Copy link
Contributor

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?

Comment on lines +38 to +39
) {
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
) {
}
) {
$this->commentsManager = $commentsManager
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants