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(federation): Fix federation invite system messages #10682

Merged
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 css/icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@
* .app-Talk rules above.
* "forced-white" needs to be included in the class name as the Avatar does
* not accept several classes. */
.mention-bubble__icon.icon-group-forced-white,
.user-bubble__avatar .avatar-class-icon.icon-group-forced-white,
.tribute-container .icon-group-forced-white {
background-image: url(../img/icon-contacts-white.svg);
}

.mention-bubble__icon.icon-user-forced-white,
.user-bubble__avatar .avatar-class-icon.icon-user-forced-white,
.tribute-container .icon-user-forced-white {
background-image: url(../img/icon-user-white.svg)
}
Expand Down
2 changes: 2 additions & 0 deletions docs/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,5 @@ See [OCP\RichObjectStrings\Definitions](https://github.com/nextcloud/server/blob
* `audio_recording_stopped` - {actor} stopped an audio recording
* `avatar_set` - {actor} set the conversation avatar
* `avatar_removed` - {actor} removed the conversation avatar
* `federated_user_added` - {actor} invited {federated_user} / {federated_user} accepted the invitation
* `federated_user_removed` - {actor} removed {federated_user} / {federated_user} declined the invitation
6 changes: 3 additions & 3 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ public function parseMessage(Message $chatMessage): void {
}
} elseif ($message === 'federated_user_added') {
$parsedParameters['federated_user'] = $this->getRemoteUser($parameters['federated_user']);
$parsedMessage = $this->l->t('{actor} invited {user}');
$parsedMessage = $this->l->t('{actor} invited {federated_user}');
if ($currentUserIsActor) {
$parsedMessage = $this->l->t('You invited {user}');
$parsedMessage = $this->l->t('You invited {federated_user}');
} elseif ($cliIsActor) {
$parsedMessage = $this->l->t('An administrator invited {user}');
$parsedMessage = $this->l->t('An administrator invited {federated_user}');
} elseif ($parsedParameters['federated_user']['id'] === $parsedParameters['actor']['id']) {
$parsedMessage = $this->l->t('{federated_user} accepted the invitation');
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/AvatarWrapper/AvatarWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ export default {
if (!this.source || this.isUser || this.isBot || this.isGuest || this.isDeletedUser) {
return ''
}
if (this.isRemoteUser) {
return 'icon-user'
}
if (this.source === 'emails') {
return 'icon-mail'
}
Expand All @@ -146,6 +149,9 @@ export default {
isUser() {
return this.source === 'users' || this.source === ATTENDEE.ACTOR_TYPE.BRIDGED
},
isRemoteUser() {
return this.source === 'federated_users'
},
isBot() {
return this.source === 'bots' && this.id !== 'changelog'
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
:display-name="name"
:avatar-image="'icon-user-forced-white'"
:primary="isCurrentGuest" />
<NcUserBubble v-else-if="isRemoteUser"
:display-name="name"
:avatar-image="'icon-user-forced-white'"
:primary="isCurrentUser" />
<NcUserBubble v-else
:display-name="name"
:user="id"
Expand Down Expand Up @@ -69,6 +73,10 @@ export default {
type: String,
required: true,
},
server: {
type: String,
default: '',
},
},

computed: {
Expand All @@ -81,6 +89,9 @@ export default {
isMentionToGuest() {
return this.type === 'guest'
},
isRemoteUser() {
return this.type === 'user' && this.server !== ''
},
isCurrentGuest() {
// On mention bubbles the id is actually "guest/ACTOR_ID" for guests
// This is to make sure guests can never collide with users,
Expand All @@ -91,6 +102,11 @@ export default {
&& this.id === ('guest/' + this.$store.getters.getActorId())
},
isCurrentUser() {
if (this.isRemoteUser) {
// For now, we don't highlight remote users even if they are the one
return false
}

return this.$store.getters.getActorType() === 'users'
&& this.id === this.$store.getters.getUserId()
},
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/features/federation/invite.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Feature: federation/invite
| federated_users | participant2 | 3 |
Then user "participant1" sees the following system messages in room "room" with 200
| room | actorType | actorId | systemMessage | message | messageParameters |
| room | users | participant1 | federated_user_added | You invited {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} |
And user "participant2" has the following invitations (v1)
| remote_server | remote_token |
Expand All @@ -44,7 +44,7 @@ Feature: federation/invite
Then user "participant1" sees the following system messages in room "room" with 200
| room | actorType | actorId | systemMessage | message | messageParameters |
| room | federated_users | participant2@http://localhost:8180 | federated_user_added | {federated_user} accepted the invitation | {"actor":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | federated_user_added | You invited {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} |

Scenario: Declining an invite
Expand All @@ -60,7 +60,7 @@ Feature: federation/invite
| federated_users | participant2 | 3 |
Then user "participant1" sees the following system messages in room "room" with 200
| room | actorType | actorId | systemMessage | message | messageParameters |
| room | users | participant1 | federated_user_added | You invited {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} |
And user "participant2" has the following invitations (v1)
| remote_server | remote_token |
Expand All @@ -76,7 +76,7 @@ Feature: federation/invite
Then user "participant1" sees the following system messages in room "room" with 200
| room | actorType | actorId | systemMessage | message | messageParameters |
| room | federated_users | participant2@http://localhost:8180 | federated_user_removed | {federated_user} declined the invitation | {"actor":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | federated_user_added | You invited {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | federated_user_added | You invited {federated_user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} |

Scenario: Authenticate as a federation user
Expand Down