Skip to content
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

fix(docs): Document empty display names #11410

Merged
merged 2 commits into from
Jan 22, 2024
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: 2 additions & 2 deletions docs/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`: since Nextcloud 13
| `token` | string | Conversation token |
| `actorType` | string | See [Constants - Actor types of chat messages](constants.md#actor-types-of-chat-messages) |
| `actorId` | string | Actor id of the message author |
| `actorDisplayName` | string | Display name of the message author |
| `actorDisplayName` | string | Display name of the message author (can be empty for type `deleted_users` and `guests`) |
| `timestamp` | int | Timestamp in seconds and UTC time zone |
| `systemMessage` | string | empty for normal chat message or the type of the system message (untranslated) |
| `messageType` | string | Currently known types are `comment`, `comment_deleted`, `system` and `command` |
Expand All @@ -64,7 +64,7 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`: since Nextcloud 13
| `markdown` | bool | **Optional:** Whether the message should be rendered as markdown or shown as plain text |
| `lastEditActorType` | string | Actor type of the last editing author - See [Constants - Actor types of chat messages](constants.md#actor-types-of-chat-messages) (only available with `edit-messages` capability and when the message was actually edited) |
| `lastEditActorId` | string | Actor id of the last editing author (only available with `edit-messages` capability and when the message was actually edited) |
| `lastEditActorDisplayName` | string | Display name of the last editing author (only available with `edit-messages` capability and when the message was actually edited) |
| `lastEditActorDisplayName` | string | Display name of the last editing author (only available with `edit-messages` capability and when the message was actually edited) (can be empty for type `deleted_users` and `guests`) |
| `lastEditTimestamp` | int | Unix time stamp when the message was last edited (only available with `edit-messages` capability and when the message was actually edited) |

#### Parent data
Expand Down
3 changes: 2 additions & 1 deletion docs/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@
### Actor types of chat messages
* `users` - Logged-in users
* `guests` - Guest users (attendee type `guests` and `emails`)
* `bots` - Used by commands (actor-id is the used `/command`) and the changelog conversation (actor-id is `changelog`)
* `bots` - Used by bots, commands (actor-id is the used `/command`) and the changelog conversation (actor-id is `changelog`)
* `bridged` - Users whose messages are bridged in by the [Matterbridge integration](matterbridge.md)
* `deleted_users` - Former logged-in users that got deleted (actor id is hardcoded to `deleted_users` and the display name is empty)

### Session states
* `0` - Inactive (Notifications should still be sent, even though the user has this session in the room)
Expand Down
11 changes: 10 additions & 1 deletion tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2576,6 +2576,7 @@ protected function compareDataResponse(TableNode $formData = null) {
$includeReferenceId = in_array('referenceId', $formData->getRow(0), true);
$includeReactions = in_array('reactions', $formData->getRow(0), true);
$includeReactionsSelf = in_array('reactionsSelf', $formData->getRow(0), true);
$includeLastEdit = in_array('lastEditActorId', $formData->getRow(0), true);

$expected = $formData->getHash();
$count = count($expected);
Expand Down Expand Up @@ -2615,7 +2616,7 @@ protected function compareDataResponse(TableNode $formData = null) {
}
}

Assert::assertEquals($expected, array_map(function ($message) use ($includeParents, $includeReferenceId, $includeReactions, $includeReactionsSelf) {
Assert::assertEquals($expected, array_map(function ($message) use ($includeParents, $includeReferenceId, $includeReactions, $includeReactionsSelf, $includeLastEdit) {
$data = [
'room' => self::$tokenToIdentifier[$message['token']],
'actorType' => $message['actorType'],
Expand All @@ -2642,6 +2643,14 @@ protected function compareDataResponse(TableNode $formData = null) {
$data['reactionsSelf'] = null;
}
}
if ($includeLastEdit) {
$data['lastEditActorType'] = $message['lastEditActorType'] ?? '';
$data['lastEditActorDisplayName'] = $message['lastEditActorDisplayName'] ?? '';
$data['lastEditActorId'] = $message['lastEditActorId'] ?? '';
if ($message['lastEditActorType'] === 'guests') {
$data['lastEditActorId'] = self::$sessionIdToUser[$message['lastEditActorId']];
}
}
return $data;
}, $messages));
}
Expand Down
24 changes: 14 additions & 10 deletions tests/integration/features/chat-1/edit-message.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,26 @@ Feature: chat-1/edit-message
| room | users | participant2 | participant2-displayname | Message 1 | [] | |
And user "participant1" edits message "Message 1" in room "room" to "Message 1 - Edit 1" with 200
Then user "participant1" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| room | users | participant2 | participant2-displayname | Message 1 - Edit 1 | [] | |
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | lastEditActorType | lastEditActorId | lastEditActorDisplayName |
| room | users | participant2 | participant2-displayname | Message 1 - Edit 1 | [] | | users | participant1 | participant1-displayname |
Then user "participant2" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| room | users | participant2 | participant2-displayname | Message 1 - Edit 1 | [] | |
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | lastEditActorType | lastEditActorId | lastEditActorDisplayName |
| room | users | participant2 | participant2-displayname | Message 1 - Edit 1 | [] | | users | participant1 | participant1-displayname |
And user "participant2" edits message "Message 1 - Edit 1" in room "room" to "Message 1 - Edit 2" with 200
Then user "participant1" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| room | users | participant2 | participant2-displayname | Message 1 - Edit 2 | [] | |
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | lastEditActorType | lastEditActorId | lastEditActorDisplayName |
| room | users | participant2 | participant2-displayname | Message 1 - Edit 2 | [] | | users | participant2 | participant2-displayname |
Then user "participant2" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| room | users | participant2 | participant2-displayname | Message 1 - Edit 2 | [] | |
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | lastEditActorType | lastEditActorId | lastEditActorDisplayName |
| room | users | participant2 | participant2-displayname | Message 1 - Edit 2 | [] | | users | participant2 | participant2-displayname |
And user "participant2" edits message "Message 1 - Edit 1" in room "room" to "" with 400
Then user "participant1" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| room | users | participant2 | participant2-displayname | Message 1 - Edit 2 | [] | |
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | lastEditActorType | lastEditActorId | lastEditActorDisplayName |
| room | users | participant2 | participant2-displayname | Message 1 - Edit 2 | [] | | users | participant2 | participant2-displayname |
When user "participant2" is deleted
Then user "participant1" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | lastEditActorType | lastEditActorId | lastEditActorDisplayName |
| room | deleted_users | deleted_users | | Message 1 - Edit 2 | [] | | deleted_users | deleted_users | |

Scenario: Editing a caption
Given user "participant1" creates room "room" (v4)
Expand Down
Loading