Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ public function parseCommentToResponse(IComment $comment, Message $parentMessage
* found".
*/
public function sendMessage(string $message, string $actorDisplayName = '', string $referenceId = '', int $replyTo = 0, bool $silent = false): DataResponse {
if (trim($message) === '') {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

[$actorType, $actorId] = $this->getActorInfo($actorDisplayName);
if (!$actorId) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
Expand Down
9 changes: 6 additions & 3 deletions src/components/NewMessageForm/NewMessageForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export default {
},

hasText() {
return this.text !== ''
return this.text.trim() !== ''
},

containerElement() {
Expand Down Expand Up @@ -540,12 +540,15 @@ export default {
}
}

if (this.text !== '') {
if (this.hasText) {
// FIXME: remove after issue is resolved: https://github.com/nextcloud/nextcloud-vue/issues/3264
const temp = document.createElement('textarea')
temp.innerHTML = this.text
this.text = temp.value
const temporaryMessage = await this.$store.dispatch('createTemporaryMessage', { text: this.text, token: this.token })
const temporaryMessage = await this.$store.dispatch('createTemporaryMessage', {
text: this.text.trim(),
token: this.token,
})
// FIXME: move "addTemporaryMessage" into "postNewMessage" as it's a pre-requisite anyway ?
if (!this.broadcast) {
await this.$store.dispatch('addTemporaryMessage', temporaryMessage)
Expand Down
1 change: 1 addition & 0 deletions tests/integration/features/chat/group.feature
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Feature: chat/group
| invite | attendees1 |
When user "participant1" sends message "Message 1" to room "group room" with 201
And user "participant2" sends message "Message 2" to room "group room" with 201
And user "participant2" sends message "" to room "group room" with 400
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| group room | users | participant2 | participant2-displayname | Message 2 | [] |
Expand Down