From 34817c3e66f6cf31566230cf0654a4b0824ee166 Mon Sep 17 00:00:00 2001 From: dartcafe Date: Tue, 8 Oct 2024 09:44:44 +0200 Subject: [PATCH] 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()