From 34817c3e66f6cf31566230cf0654a4b0824ee166 Mon Sep 17 00:00:00 2001 From: dartcafe Date: Tue, 8 Oct 2024 09:44:44 +0200 Subject: [PATCH 1/4] fixing some aftermath Signed-off-by: dartcafe --- lib/Model/UserBase.php | 29 +++++++++++---------- src/Types/index.ts | 22 ++++++++-------- src/components/Shares/SharePublicAdd.vue | 23 +++++++++++------ src/components/User/UserItem.vue | 10 +++++++- src/components/VoteTable/VoteTable.vue | 6 ++--- src/helpers/modules/arrayHelper.ts | 3 --- src/stores/poll.ts | 32 +++++++++--------------- src/stores/shares.ts | 6 ++--- 8 files changed, 66 insertions(+), 65 deletions(-) diff --git a/lib/Model/UserBase.php b/lib/Model/UserBase.php index b6ea3f111..dbc467682 100644 --- a/lib/Model/UserBase.php +++ b/lib/Model/UserBase.php @@ -185,13 +185,6 @@ public function getSubName(): string { return $this->getDescription(); } - /** - * @deprecated Not used anymore? - */ - private function getIcon(): string { - return $this->icon; - } - public function getEmailAddress(): string { return $this->emailAddress; } @@ -321,12 +314,10 @@ public function getRichUserArray(): array { 'desc' => $this->getDescription(), 'type' => $this->getType(), 'id' => $this->getId(), - 'user' => $this->getId(), 'organisation' => $this->getOrganisation(), 'languageCode' => $this->getLanguageCode(), 'localeCode' => $this->getLocaleCode(), 'timeZone' => $this->getTimeZoneName(), - 'icon' => $this->getIcon(), 'categories' => $this->getCategories(), ]; } @@ -337,18 +328,26 @@ public function getRichUserArray(): array { /** * Simply user array returning safe attributes - * @return (bool|string)[] * - * @psalm-return array{id: string, userId: string, displayName: string, emailAddress: string, isNoUser: bool, type: string} + * @return (bool|null|string)[] + * + * @psalm-return array{id: string, displayName: string, emailAddress: string, isNoUser: bool, type: string, subName: null, subtitle: null, desc: null, user: null, organisation: null, languageCode: null, localeCode: null, timeZone: null, icon: null, categories: null} */ protected function getSimpleUserArray(): array { return [ 'id' => $this->getSafeId(), - 'userId' => $this->getSafeId(), 'displayName' => $this->getSafeDisplayName(), 'emailAddress' => $this->getSafeEmailAddress(), 'isNoUser' => $this->getIsNoUser(), 'type' => $this->getSafeType(), + 'subName' => null, + 'subtitle' => null, + 'desc' => null, + 'organisation' => null, + 'languageCode' => null, + 'localeCode' => null, + 'timeZone' => null, + 'categories' => null, ]; } @@ -392,7 +391,7 @@ public function getSafeDisplayName(): string { } // Function for obfuscating mail adresses; Default return the email address - public function getSafeEmailAddress(): string { + public function getSafeEmailAddress(): string | null { // return real email address for cron jobs if ($this->userSession->getUser()->getIsSystemUser()) { return $this->getEmailAddress(); @@ -404,14 +403,14 @@ public function getSafeEmailAddress(): string { } if ($this->anonymizeLevel === EntityWithUser::ANON_FULL) { - return ''; + return null; } if ($this->appSettings->getAllowSeeMailAddresses()) { return $this->getEmailAddress(); } - return ''; + return null; } public function getOrganisation(): string { diff --git a/src/Types/index.ts b/src/Types/index.ts index ae49fb13b..2c81490b6 100644 --- a/src/Types/index.ts +++ b/src/Types/index.ts @@ -78,24 +78,22 @@ export type AppPermissions = { } export type User = { + id: string displayName: string - emailAddress: string - subName: string - subtitle: string + emailAddress: string | null isNoUser: boolean - desc: string type: UserType - id: string - organisation: string - languageCode: string - localeCode: string - timeZone: string - categories: string[] + subName: string | null + subtitle: string | null + desc: string | null + organisation: string | null + languageCode: string | null + localeCode: string | null + timeZone: string | null + categories: string[] | null } export type Participant = { - userId: string - displayName: string pollId: number user: User } diff --git a/src/components/Shares/SharePublicAdd.vue b/src/components/Shares/SharePublicAdd.vue index cf5522dce..322abaf38 100644 --- a/src/components/Shares/SharePublicAdd.vue +++ b/src/components/Shares/SharePublicAdd.vue @@ -13,7 +13,7 @@ import PlusIcon from 'vue-material-design-icons/Plus.vue' import UserItem from '../User/UserItem.vue' - import { VirtualUserItemType } from '../../Types/index.ts' + import { User, UserType, VirtualUserItemType } from '../../Types/index.ts' import { useSharesStore } from '../../stores/shares.ts' const sharesStore = useSharesStore() @@ -23,13 +23,20 @@ type: VirtualUserItemType.AddPublicLink, } - const user = { - user: { - type: 'public', - userId: '', - displayName: '', - emailAddress: '', - }, + const user: User = { + id: '', + displayName: '', + emailAddress: '', + isNoUser: false, + type: UserType.None, + subName: null, + subtitle: null, + desc: null, + organisation: null, + languageCode: null, + localeCode: null, + timeZone: null, + categories: null, } async function addPublicShare() { diff --git a/src/components/User/UserItem.vue b/src/components/User/UserItem.vue index 15a6ed2ae..8b110ee07 100644 --- a/src/components/User/UserItem.vue +++ b/src/components/User/UserItem.vue @@ -100,7 +100,15 @@ displayName: '', emailAddress: '', isNoUser: true, - type: null, + type: UserType.None, + subName: null, + subtitle: null, + desc: null, + organisation: null, + languageCode: null, + localeCode: null, + timeZone: null, + categories: null, } }, }, diff --git a/src/components/VoteTable/VoteTable.vue b/src/components/VoteTable/VoteTable.vue index e9af9516d..23727cce9 100644 --- a/src/components/VoteTable/VoteTable.vue +++ b/src/components/VoteTable/VoteTable.vue @@ -37,14 +37,14 @@
+ :key="participant.id" + :class="['participant', {'current-user': (participant.id === sessionStore.currentUser.id) }]">
diff --git a/src/helpers/modules/arrayHelper.ts b/src/helpers/modules/arrayHelper.ts index 0b65e1271..1ef439b9f 100644 --- a/src/helpers/modules/arrayHelper.ts +++ b/src/helpers/modules/arrayHelper.ts @@ -15,9 +15,6 @@ const uniqueOptions = (options: Option[]) => const uniqueParticipants = (votes: Vote[]): Participant[] => { const participants: Participant[] = votes.map((vote) => ({ - userId: vote.user.id, - displayName: vote.user.displayName, - isNoUser: vote.user.isNoUser, user: vote.user, pollId: vote.pollId, })) diff --git a/src/stores/poll.ts b/src/stores/poll.ts index c370497b0..ecba0b6ce 100644 --- a/src/stores/poll.ts +++ b/src/stores/poll.ts @@ -145,19 +145,19 @@ export const usePollStore = defineStore('poll', { maxVotesPerUser: 0, }, owner: { + id: '', displayName: '', emailAddress: '', - subName: '', - subtitle: '', isNoUser: false, - desc: '', - type: UserType.User, - id: '', - organisation: '', - languageCode: '', - localeCode: '', - timeZone: '', - categories: [], + type: UserType.None, + subName: null, + subtitle: null, + desc: null, + organisation: null, + languageCode: null, + localeCode: null, + timeZone: null, + categories: null, }, status: { lastInteraction: 0, @@ -241,11 +241,7 @@ export const usePollStore = defineStore('poll', { // add current user, if not among participants and voting is allowed if (!participants.find((participant: User) => participant.id === sessionStore.currentUser.id) && sessionStore.currentUser.id && state.permissions.vote) { - participants.push({ - id: sessionStore.currentUser.id, - displayName: sessionStore.currentUser.displayName, - isNoUser: sessionStore.currentUser.isNoUser, - }) + participants.push(sessionStore.currentUser) } return participants @@ -254,11 +250,7 @@ export const usePollStore = defineStore('poll', { safeParticipants() { const sessionStore = useSessionStore() if (this.getSafeTable) { - return [{ - id: sessionStore.currentUser.id, - displayName: sessionStore.currentUser.displayName, - isNoUser: sessionStore.currentUser.isNoUser, - }] + return [sessionStore.currentUser] } return this.participants }, diff --git a/src/stores/shares.ts b/src/stores/shares.ts index 8d5f2d657..fb3b2ed3d 100644 --- a/src/stores/shares.ts +++ b/src/stores/shares.ts @@ -88,13 +88,13 @@ export const useSharesStore = defineStore('shares', { } }, - async add(payload: { user: { type: string, userId: string, displayName: string, emailAddress: string }} ): Promise { + async add(user: User ): Promise { const sessionStore = useSessionStore() try { - await SharesAPI.addShare(sessionStore.route.params.id, payload.user) + await SharesAPI.addShare(sessionStore.route.params.id, user) } catch (error) { if (error?.code === 'ERR_CANCELED') return - Logger.error('Error writing share', { error, payload }) + Logger.error('Error writing share', { error, payload: user }) throw error } finally { this.load() From daac8526faf18461f10345cc374c472a2e2e79e7 Mon Sep 17 00:00:00 2001 From: dartcafe Date: Tue, 8 Oct 2024 10:42:59 +0200 Subject: [PATCH 2/4] tidy Signed-off-by: dartcafe --- lib/Model/UserBase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Model/UserBase.php b/lib/Model/UserBase.php index dbc467682..4e7e15faa 100644 --- a/lib/Model/UserBase.php +++ b/lib/Model/UserBase.php @@ -301,7 +301,7 @@ public function jsonSerialize(): array { * * @return (bool|string|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} + * @psalm-return array{userId: string, displayName: string, emailAddress: string, subName: string, subtitle: string, isNoUser: bool, desc: string, type: string, id: string, organisation: string, languageCode: string, localeCode: string, timeZone: string, categories: array} */ public function getRichUserArray(): array { return [ @@ -391,7 +391,7 @@ public function getSafeDisplayName(): string { } // Function for obfuscating mail adresses; Default return the email address - public function getSafeEmailAddress(): string | null { + public function getSafeEmailAddress(): ?string { // return real email address for cron jobs if ($this->userSession->getUser()->getIsSystemUser()) { return $this->getEmailAddress(); From d1458dac40250ba0864ae683d10616b226a39bfb Mon Sep 17 00:00:00 2001 From: dartcafe Date: Tue, 8 Oct 2024 12:00:03 +0200 Subject: [PATCH 3/4] fix again Signed-off-by: dartcafe --- lib/Model/Group/Circle.php | 2 -- lib/Model/Group/ContactGroup.php | 2 -- lib/Model/Group/Group.php | 2 -- lib/Model/User/Admin.php | 1 - lib/Model/User/Contact.php | 2 -- lib/Model/User/Email.php | 2 -- lib/Model/User/GenericUser.php | 4 ---- lib/Model/User/Ghost.php | 1 - lib/Model/User/User.php | 3 --- lib/Model/UserBase.php | 6 ++---- 10 files changed, 2 insertions(+), 23 deletions(-) diff --git a/lib/Model/Group/Circle.php b/lib/Model/Group/Circle.php index 337143dd3..c378a718e 100644 --- a/lib/Model/Group/Circle.php +++ b/lib/Model/Group/Circle.php @@ -22,7 +22,6 @@ */ class Circle extends UserBase { public const TYPE = 'circle'; - public const ICON = 'icon-circles'; private CirclesCircle $circle; @@ -30,7 +29,6 @@ public function __construct( string $id, ) { parent::__construct($id, self::TYPE); - $this->icon = self::ICON; $this->description = $this->l10n->t('Circle'); $this->richObjectType = 'circle'; diff --git a/lib/Model/Group/ContactGroup.php b/lib/Model/Group/ContactGroup.php index 8acf5dd01..f5182895c 100644 --- a/lib/Model/Group/ContactGroup.php +++ b/lib/Model/Group/ContactGroup.php @@ -16,13 +16,11 @@ class ContactGroup extends UserBase { public const TYPE = 'contactGroup'; - public const ICON = 'icon-group'; public function __construct( string $id, ) { parent::__construct($id, self::TYPE); - $this->icon = self::ICON; $this->description = $this->l10n->t('Contact group'); $this->richObjectType = 'addressbook-contact'; diff --git a/lib/Model/Group/Group.php b/lib/Model/Group/Group.php index 02b951c5b..b729ecd32 100644 --- a/lib/Model/Group/Group.php +++ b/lib/Model/Group/Group.php @@ -16,7 +16,6 @@ class Group extends UserBase { public const TYPE = 'group'; - public const ICON = 'icon-group'; private IGroup $group; @@ -24,7 +23,6 @@ public function __construct( string $id, ) { parent::__construct($id, self::TYPE); - $this->icon = self::ICON; $this->description = $this->l10n->t('Group'); $this->richObjectType = 'user-group'; diff --git a/lib/Model/User/Admin.php b/lib/Model/User/Admin.php index fcd504555..c3dbaeb41 100644 --- a/lib/Model/User/Admin.php +++ b/lib/Model/User/Admin.php @@ -10,7 +10,6 @@ class Admin extends User { public const TYPE = 'admin'; - public const ICON = 'icon-settings'; public function __construct(string $id) { parent::__construct($id, self::TYPE); diff --git a/lib/Model/User/Contact.php b/lib/Model/User/Contact.php index 018995add..0c0cc93aa 100644 --- a/lib/Model/User/Contact.php +++ b/lib/Model/User/Contact.php @@ -16,14 +16,12 @@ class Contact extends UserBase { public const TYPE = 'contact'; - public const ICON = 'icon-mail'; protected LoggerInterface $logger; private array $contact = []; public function __construct(string $id) { parent::__construct($id, self::TYPE); - $this->icon = self::ICON; $this->description = $this->l10n->t('Contact'); $this->richObjectType = 'addressbook-contact'; $this->logger = Container::queryClass(LoggerInterface::class); diff --git a/lib/Model/User/Email.php b/lib/Model/User/Email.php index 7746f7927..2d714af03 100644 --- a/lib/Model/User/Email.php +++ b/lib/Model/User/Email.php @@ -13,7 +13,6 @@ class Email extends UserBase { public const TYPE = 'email'; - public const ICON = 'icon-mail'; public function __construct( string $id, @@ -22,7 +21,6 @@ public function __construct( string $languageCode = '', ) { parent::__construct($id, self::TYPE, languageCode: $languageCode); - $this->icon = self::ICON; $this->richObjectType = 'email'; $this->description = $emailAddress !== '' ? $emailAddress : $this->l10n->t('External Email'); $this->emailAddress = $emailAddress !== '' ? $emailAddress : $id; diff --git a/lib/Model/User/GenericUser.php b/lib/Model/User/GenericUser.php index aea68be39..112c4d0f3 100644 --- a/lib/Model/User/GenericUser.php +++ b/lib/Model/User/GenericUser.php @@ -13,8 +13,6 @@ class GenericUser extends UserBase { public const TYPE = 'external'; - public const ICON_DEFAULT = 'icon-share'; - public const ICON_PUBLIC = 'icon-public'; public function __construct( string $id, @@ -27,12 +25,10 @@ public function __construct( ) { parent::__construct($id, $type, $displayName, $emailAddress, $languageCode, $localeCode, $timeZoneName); - $this->icon = self::ICON_DEFAULT; $this->description = $this->l10n->t('External participant'); $this->richObjectType = 'guest'; if ($type === UserBase::TYPE_PUBLIC) { - $this->icon = self::ICON_PUBLIC; // $this->description = $this->l10n->t('Public link'); $this->description = ''; } diff --git a/lib/Model/User/Ghost.php b/lib/Model/User/Ghost.php index 94ef3172f..0b10fccd5 100644 --- a/lib/Model/User/Ghost.php +++ b/lib/Model/User/Ghost.php @@ -12,7 +12,6 @@ class Ghost extends UserBase { public const TYPE = 'deleted'; - public const ICON = 'icon-ghost'; public function __construct(string $id) { parent::__construct($id, self::TYPE); diff --git a/lib/Model/User/User.php b/lib/Model/User/User.php index 52682bb6d..c0b7c5e06 100644 --- a/lib/Model/User/User.php +++ b/lib/Model/User/User.php @@ -18,8 +18,6 @@ class User extends UserBase { /** @var string */ public const TYPE = 'user'; /** @var string */ - public const ICON = 'icon-user'; - /** @var string */ public const PRINCIPAL_PREFIX = 'principals/users/'; private IConfig $config; @@ -30,7 +28,6 @@ public function __construct( string $type = self::TYPE, ) { parent::__construct($id, $type); - $this->icon = self::ICON; $this->description = $this->l10n->t('User'); $this->setUp(); diff --git a/lib/Model/UserBase.php b/lib/Model/UserBase.php index 4e7e15faa..7248d8313 100644 --- a/lib/Model/UserBase.php +++ b/lib/Model/UserBase.php @@ -55,7 +55,6 @@ class UserBase implements JsonSerializable { protected string $description = ''; protected string $richObjectType = 'user'; protected string $organisation = ''; - protected string $icon = ''; protected IDateTimeZone $timeZone; protected IGroupManager $groupManager; protected IL10N $l10n; @@ -71,7 +70,6 @@ public function __construct( protected string $localeCode = '', protected string $timeZoneName = '', ) { - $this->icon = 'icon-share'; $this->l10n = Container::getL10N(); $this->groupManager = Server::get(IGroupManager::class); $this->timeZone = Server::get(IDateTimeZone::class); @@ -331,7 +329,7 @@ public function getRichUserArray(): array { * * @return (bool|null|string)[] * - * @psalm-return array{id: string, displayName: string, emailAddress: string, isNoUser: bool, type: string, subName: null, subtitle: null, desc: null, user: null, organisation: null, languageCode: null, localeCode: null, timeZone: null, icon: null, categories: null} + * @psalm-return array{id: string, displayName: string, emailAddress: string, isNoUser: bool, type: string, subName: null, subtitle: null, desc: null, user: null, organisation: null, languageCode: null, localeCode: null, timeZone: null, categories: null} */ protected function getSimpleUserArray(): array { return [ @@ -391,7 +389,7 @@ public function getSafeDisplayName(): string { } // Function for obfuscating mail adresses; Default return the email address - public function getSafeEmailAddress(): ?string { + public function getSafeEmailAddress(): string | null { // return real email address for cron jobs if ($this->userSession->getUser()->getIsSystemUser()) { return $this->getEmailAddress(); From 0d017cda3e5532e7f939a4d439741e29631e45e3 Mon Sep 17 00:00:00 2001 From: dartcafe Date: Tue, 8 Oct 2024 12:32:33 +0200 Subject: [PATCH 4/4] argh Signed-off-by: dartcafe --- lib/Model/UserBase.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/Model/UserBase.php b/lib/Model/UserBase.php index 7248d8313..1e9c55bbb 100644 --- a/lib/Model/UserBase.php +++ b/lib/Model/UserBase.php @@ -298,8 +298,6 @@ public function jsonSerialize(): array { * without obfuscating/anonymizing * * @return (bool|string|string[])[] - * - * @psalm-return array{userId: string, displayName: string, emailAddress: string, subName: string, subtitle: string, isNoUser: bool, desc: string, type: string, id: string, organisation: string, languageCode: string, localeCode: string, timeZone: string, categories: array} */ public function getRichUserArray(): array { return [ @@ -328,8 +326,6 @@ public function getRichUserArray(): array { * Simply user array returning safe attributes * * @return (bool|null|string)[] - * - * @psalm-return array{id: string, displayName: string, emailAddress: string, isNoUser: bool, type: string, subName: null, subtitle: null, desc: null, user: null, organisation: null, languageCode: null, localeCode: null, timeZone: null, categories: null} */ protected function getSimpleUserArray(): array { return [ @@ -389,7 +385,7 @@ public function getSafeDisplayName(): string { } // Function for obfuscating mail adresses; Default return the email address - public function getSafeEmailAddress(): string | null { + public function getSafeEmailAddress(): ?string { // return real email address for cron jobs if ($this->userSession->getUser()->getIsSystemUser()) { return $this->getEmailAddress();