Skip to content

Commit

Permalink
Merge pull request #3340 from nextcloud/fix/share-mail-address
Browse files Browse the repository at this point in the history
Partially fix email shares
  • Loading branch information
dartcafe authored Feb 24, 2024
2 parents cccac35 + 6156645 commit 2357818
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ All notable changes to this project will be documented in this file.
## [6.1.4] - tbd
### Fix
- Fixing 404 error when using public share where the poll has hidden results
- Partially fix email shares
- fix user name check for public participants

## [6.1.3] - 2024-02-21
### Fix
- Fixing bug, when an internal user tries to enter a poll using a public share a second time
Expand Down
14 changes: 14 additions & 0 deletions lib/Model/User/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,18 @@ public function __construct(
public function getDisplayName(): string {
return $this->displayName ? $this->displayName : $this->id;
}

public function jsonSerialize(): array {
if ($this->userMapper->getCurrentUserCached()->getIsLoggedIn()) {
return $this->getRichUserArray();
}
return $this->getSimpleUserArray();
}

public function getDescription(): string {
if ($this->getDisplayName()) {
return $this->getEmailAndDisplayName();
}
return $this->getEmailAddress();
}
}
16 changes: 11 additions & 5 deletions lib/Model/UserBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ public function getDescription(): string {
return $this->description;
}

public function getSubName(): string {
return $this->getDescription();
}

/**
* @deprecated Not used anymore?
*/
Expand Down Expand Up @@ -349,26 +353,27 @@ public function jsonSerialize(): array {
/**
* Full user array for poll owners, delegated poll admins and the current user himself
* without obfuscating/anonymizing
*
* @return (bool|string|string[])[]
*
* @psalm-return array{userId: string, displayName: string, emailAddress: string, isNoUser: bool, type: string, id: string, user: string, organisation: string, languageCode: string, localeCode: string, timeZone: string, desc: string, subname: string, subtitle: string, icon: string, categories: array<string>}
* @psalm-return array{userId: string, displayName: string, emailAddress: string, subName: string, subtitle: string, isNoUser: bool, desc: string, type: string, id: string, user: string, organisation: string, languageCode: string, localeCode: string, timeZone: string, icon: string, categories: array<string>}
*/
public function getRichUserArray(): array {
return [
'userId' => $this->getId(),
'displayName' => $this->getDisplayName(),
'emailAddress' => $this->getEmailAddress(),
'subName' => $this->getSubName(),
'subtitle' => $this->getDescription(),
'isNoUser' => $this->getIsNoUser(),
'desc' => $this->getDescription(),
'type' => $this->getType(),
'id' => $this->getId(),
'user' => $this->getId(),
'organisation' => $this->getOrganisation(),
'languageCode' => $this->getLanguageCode(),
'localeCode' => $this->getLocaleCode(),
'timeZone' => $this->getTimeZoneName(),
'desc' => $this->getDescription(),
'subname' => $this->getDescription(),
'subtitle' => $this->getDescription(),
'icon' => $this->getIcon(),
'categories' => $this->getCategories(),
];
Expand All @@ -384,7 +389,7 @@ public function getRichUserArray(): array {
*
* @psalm-return array{id: string, userId: string, displayName: string, emailAddress: string, isNoUser: bool, type: string}
*/
private function getSimpleUserArray(): array {
protected function getSimpleUserArray(): array {
return [
'id' => $this->getSafeId(),
'userId' => $this->getSafeId(),
Expand Down Expand Up @@ -441,6 +446,7 @@ public function getSafeEmailAddress(): string {

return '';
}

public function getOrganisation(): string {
return $this->organisation;
}
Expand Down
27 changes: 18 additions & 9 deletions src/js/components/User/UserSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@

<template>
<NcSelect id="ajax"
:aria-label-combobox="t('polls', 'Add shares')"
:options="users"
:multiple="false"
:user-select="true"
:tag-width="80"
:limit="30"
:loading="isLoading"
:searchable="true"
:placeholder="placeholder"
v-model="selectProps"
label="displayName"
@option:selected="clickAdd"
@search="loadUsersAsync">
Expand Down Expand Up @@ -64,6 +56,23 @@ export default {
}
},

computed: {
selectProps() {
return {
ariaLabelCombobox: t('polls', 'Add shares'),
options: this.users,
multiple: false,
userSelect: true,
// tagWidth: 80,
limit: 30,
loading: this.isLoading,
searchable: true,
placeholder: this.placeholder,
closeOnSelect: false,
}
},
},

methods: {
...mapActions({
addShare: 'shares/add',
Expand Down

0 comments on commit 2357818

Please sign in to comment.