diff options
| author | piuvas <mail@piuvas.net> | 2025-05-27 13:25:06 -0300 |
|---|---|---|
| committer | piuvas <mail@piuvas.net> | 2025-05-27 13:25:06 -0300 |
| commit | 5545ddf9ddefa5620c58ea34b2e6fdf18fdac30a (patch) | |
| tree | 67606539def90e70a758e56272b16493b0d1c84c | |
| parent | fix generated migration. (diff) | |
| download | sharkey-5545ddf9ddefa5620c58ea34b2e6fdf18fdac30a.tar.gz sharkey-5545ddf9ddefa5620c58ea34b2e6fdf18fdac30a.tar.bz2 sharkey-5545ddf9ddefa5620c58ea34b2e6fdf18fdac30a.zip | |
requested changes.
| -rw-r--r-- | locales/index.d.ts | 4 | ||||
| -rw-r--r-- | packages/backend/src/models/json-schema/user.ts | 2 | ||||
| -rw-r--r-- | packages/backend/src/server/web/UrlPreviewService.ts | 18 | ||||
| -rw-r--r-- | packages/frontend/src/components/MkUrlPreview.vue | 41 | ||||
| -rw-r--r-- | packages/frontend/src/pages/settings/profile.vue | 2 | ||||
| -rw-r--r-- | sharkey-locales/en-US.yml | 2 | ||||
| -rw-r--r-- | sharkey-locales/pt-PT.yml | 2 |
7 files changed, 32 insertions, 39 deletions
diff --git a/locales/index.d.ts b/locales/index.d.ts index 1070318fa2..f809613e7a 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -13138,9 +13138,9 @@ export interface Locale extends ILocale { */ "attributionDomainsDescription": string; /** - * Written by + * Written by {user} */ - "writtenBy": string; + "writtenBy": ParameterizedString<"user">; } declare const locales: { [lang: string]: Locale; diff --git a/packages/backend/src/models/json-schema/user.ts b/packages/backend/src/models/json-schema/user.ts index 9bfb57fc66..82d354cfd0 100644 --- a/packages/backend/src/models/json-schema/user.ts +++ b/packages/backend/src/models/json-schema/user.ts @@ -237,7 +237,7 @@ export const packedUserLiteSchema = { }, }, attributionDomains: { - type: 'object', + type: 'array', nullable: false, optional: false, additionalProperties: { type: 'string', diff --git a/packages/backend/src/server/web/UrlPreviewService.ts b/packages/backend/src/server/web/UrlPreviewService.ts index b50e5d49fd..ccf8fa342d 100644 --- a/packages/backend/src/server/web/UrlPreviewService.ts +++ b/packages/backend/src/server/web/UrlPreviewService.ts @@ -28,7 +28,7 @@ import { ApNoteService } from '@/core/activitypub/models/ApNoteService.js'; import { AuthenticateService, AuthenticationError } from '@/server/api/AuthenticateService.js'; import { SkRateLimiterService } from '@/server/SkRateLimiterService.js'; import { BucketRateLimit, Keyed, sendRateLimitHeaders } from '@/misc/rate-limit-utils.js'; -import type { MiLocalUser } from '@/models/User.js'; +import type { MiLocalUser, MiUser } from '@/models/User.js'; import { getIpHash } from '@/misc/get-ip-hash.js'; import { isRetryableError } from '@/misc/is-retryable-error.js'; import type { FastifyRequest, FastifyReply } from 'fastify'; @@ -36,10 +36,7 @@ import type { FastifyRequest, FastifyReply } from 'fastify'; export type LocalSummalyResult = SummalyResult & { haveNoteLocally?: boolean; linkAttribution?: { - name: string, - username: string, - avatarUrl: string, - avatarBlurhash: string, + user: MiUser, } }; @@ -448,6 +445,10 @@ export class UrlPreviewService { } const array = fediverseCreator.split('@'); + + // make sure we only have username@host. + if (array.length !== 2) return; + const username = array[0].toLowerCase(); let host: string | null = array[1]; if (host.toLowerCase() === this.config.host) { @@ -459,14 +460,11 @@ export class UrlPreviewService { const attributionDomains = user.attributionDomains; if (attributionDomains.some(x => `.${url.host.toLowerCase()}`.endsWith(`.${x}`))) { summary.linkAttribution = { - name: user.name ?? user.username, - username: fediverseCreator, - avatarUrl: user.avatarUrl ?? '', - avatarBlurhash: user.avatarBlurhash ?? '', + user: user, }; } } catch { - console.warn('user not found: ' + fediverseCreator); + this.logger.warn('user not found: ' + fediverseCreator); } } diff --git a/packages/frontend/src/components/MkUrlPreview.vue b/packages/frontend/src/components/MkUrlPreview.vue index ca8f6848e5..0cba73ef05 100644 --- a/packages/frontend/src/components/MkUrlPreview.vue +++ b/packages/frontend/src/components/MkUrlPreview.vue @@ -65,13 +65,14 @@ SPDX-License-Identifier: AGPL-3.0-only </footer> </article> </component> - <footer v-if="linkAttribution" :class="$style.footer" style="text-align: right"> - <a :href="'/@' + linkAttribution.username"> - <p :class="$style.linkAttribution">{{ i18n.ts.writtenBy }}</p> - <MkImgWithBlurhash :class="$style.linkAttributionIcon" :src="linkAttribution.avatarUrl" :hash="linkAttribution.avatarBlurhash" :cover="true" :onlyAvgColor="true"/> - <b :class="$style.linkAttribution" style="color: var(--MI_THEME-accent)">{{ linkAttribution.name }}</b> - </a> - </footer> + <I18n v-if="linkAttribution" :src="i18n.ts.writtenBy" :class="$style.linkAttribution" tag="p"> + <template #user> + <MkA v-user-preview="linkAttribution.user.id" :to="userPage(linkAttribution.user)"> + <MkAvatar :class="$style.linkAttributionIcon" :user="linkAttribution.user"/> + <MkUserName :user="linkAttribution.user" style="color: var(--MI_THEME-accent)"/> + </MkA> + </template> + </I18n> <template v-if="showActions"> <div v-if="tweetId" :class="$style.action"> <MkButton :small="true" inline @click="tweetExpanded = true"> @@ -114,6 +115,7 @@ import { misskeyApi } from '@/utility/misskey-api.js'; import { warningExternalWebsite } from '@/utility/warning-external-website.js'; import DynamicNoteSimple from '@/components/DynamicNoteSimple.vue'; import { $i } from '@/i'; +import { userPage } from '@/filters/user.js'; type SummalyResult = Awaited<ReturnType<typeof summaly>>; @@ -155,10 +157,7 @@ const player = ref<SummalyResult['player']>({ allow: [], }); const linkAttribution = ref<{ - name: string, - username: string, - avatarUrl: string, - avatarBlurhash: string, + user: Misskey.entities.User, } | null>(null); const playerEnabled = ref(false); const tweetId = ref<string | null>(null); @@ -238,10 +237,7 @@ function refresh(withFetch = false) { .then(async (info: SummalyResult & { haveNoteLocally?: boolean, linkAttribution?: { - name: string, - username: string, - avatarUrl: string, - avatarBlurhash: string, + user: Misskey.entities.User } } | null) => { unknownUrl.value = info == null; @@ -420,11 +416,11 @@ refresh(); .linkAttributionIcon { display: inline-block; - width: 1em; - height: 1em; - margin-left: 0.5em; + width: 16px; + height: 16px; + margin-left: 0.25em; margin-right: 0.25em; - vertical-align: top; + vertical-align: middle; border-radius: 50%; * { border-radius: 4px; @@ -432,11 +428,12 @@ refresh(); } .linkAttribution { + width: 100%; font-size: 0.8em; display: inline-block; - margin: 0; - line-height: 16px; - vertical-align: top; + margin: auto; + padding-top: 0.5em; + text-align: right; } .action { diff --git a/packages/frontend/src/pages/settings/profile.vue b/packages/frontend/src/pages/settings/profile.vue index 9dc7398062..4cc13a2552 100644 --- a/packages/frontend/src/pages/settings/profile.vue +++ b/packages/frontend/src/pages/settings/profile.vue @@ -220,7 +220,6 @@ const profile = reactive({ isBot: $i.isBot ?? false, isCat: $i.isCat ?? false, speakAsCat: $i.speakAsCat ?? false, - attributionDomains: $i.attributionDomains, }); watch(() => profile, () => { @@ -280,7 +279,6 @@ function save() { isBot: !!profile.isBot, isCat: !!profile.isCat, speakAsCat: !!profile.speakAsCat, - attributionDomains: !!profile.attributionDomains, }, undefined, { '0b3f9f6a-2f4d-4b1f-9fb4-49d3a2fd7191': { title: i18n.ts.yourNameContainsProhibitedWords, diff --git a/sharkey-locales/en-US.yml b/sharkey-locales/en-US.yml index bfd0613cc7..0ad01b96be 100644 --- a/sharkey-locales/en-US.yml +++ b/sharkey-locales/en-US.yml @@ -592,4 +592,4 @@ translationTimeoutCaption: "Timeout in milliseconds for translation API requests attributionDomains: "Attribution Domains" attributionDomainsDescription: "A list of domains whose content can be attributed to you on link previews, separated by new-line. Any subdomain will also be valid. The following needs to be on the webpage:" -writtenBy: "Written by" +writtenBy: "Written by {user}" diff --git a/sharkey-locales/pt-PT.yml b/sharkey-locales/pt-PT.yml index e522125e6c..7220cd2b59 100644 --- a/sharkey-locales/pt-PT.yml +++ b/sharkey-locales/pt-PT.yml @@ -9,4 +9,4 @@ pinnedOnly: "Fixado" blockingYou: "Bloqueando você" attributionDomains: "Domínios de Atribuição" attributionDomainsDescription: "Uma lista de domínios cujo conteúdo pode ser atribuído a você em prévias de link, separadas por linha. Qualquer subdomínio também será válido. O código seguinte precisa estar presente na página:" -writtenBy: "Escrito por" +writtenBy: "Escrito por {user}" |