mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
requested changes.
This commit is contained in:
parent
3884f2fa6a
commit
5545ddf9dd
7 changed files with 32 additions and 39 deletions
4
locales/index.d.ts
vendored
4
locales/index.d.ts
vendored
|
@ -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;
|
||||
|
|
|
@ -237,7 +237,7 @@ export const packedUserLiteSchema = {
|
|||
},
|
||||
},
|
||||
attributionDomains: {
|
||||
type: 'object',
|
||||
type: 'array',
|
||||
nullable: false, optional: false,
|
||||
additionalProperties: {
|
||||
type: 'string',
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -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}"
|
||||
|
|
Loading…
Add table
Reference in a new issue