mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
merge: Link attributions (!1048)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1048 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Hazelnoot <acomputerdog@gmail.com>
This commit is contained in:
commit
e9a038b244
19 changed files with 252 additions and 13 deletions
12
locales/index.d.ts
vendored
12
locales/index.d.ts
vendored
|
@ -13157,6 +13157,18 @@ export interface Locale extends ILocale {
|
||||||
* Timeout in milliseconds for translation API requests.
|
* Timeout in milliseconds for translation API requests.
|
||||||
*/
|
*/
|
||||||
"translationTimeoutCaption": string;
|
"translationTimeoutCaption": string;
|
||||||
|
/**
|
||||||
|
* Attribution Domains
|
||||||
|
*/
|
||||||
|
"attributionDomains": string;
|
||||||
|
/**
|
||||||
|
* 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:
|
||||||
|
*/
|
||||||
|
"attributionDomainsDescription": string;
|
||||||
|
/**
|
||||||
|
* Written by {user}
|
||||||
|
*/
|
||||||
|
"writtenBy": ParameterizedString<"user">;
|
||||||
/**
|
/**
|
||||||
* Following (Pub)
|
* Following (Pub)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: piuvas and other Sharkey contributors
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class AddAttributionDomains1748096357260 {
|
||||||
|
name = 'AddAttributionDomains1748096357260'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "user" ADD "attributionDomains" text array NOT NULL DEFAULT '{}'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "attributionDomains"`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -77,6 +77,7 @@ function generateDummyUser(override?: Partial<MiUser>): MiUser {
|
||||||
mandatoryCW: null,
|
mandatoryCW: null,
|
||||||
rejectQuotes: false,
|
rejectQuotes: false,
|
||||||
allowUnsignedFetch: 'staff',
|
allowUnsignedFetch: 'staff',
|
||||||
|
attributionDomains: [],
|
||||||
...override,
|
...override,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -613,6 +613,7 @@ export class ApRendererService {
|
||||||
enableRss: user.enableRss,
|
enableRss: user.enableRss,
|
||||||
speakAsCat: user.speakAsCat,
|
speakAsCat: user.speakAsCat,
|
||||||
attachment: attachment.length ? attachment : undefined,
|
attachment: attachment.length ? attachment : undefined,
|
||||||
|
attributionDomains: user.attributionDomains,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (user.movedToUri) {
|
if (user.movedToUri) {
|
||||||
|
|
|
@ -546,6 +546,10 @@ const extension_context_definition = {
|
||||||
featured: 'toot:featured',
|
featured: 'toot:featured',
|
||||||
discoverable: 'toot:discoverable',
|
discoverable: 'toot:discoverable',
|
||||||
indexable: 'toot:indexable',
|
indexable: 'toot:indexable',
|
||||||
|
attributionDomains: {
|
||||||
|
'@id': 'toot:attributionDomains',
|
||||||
|
'@type': '@id',
|
||||||
|
},
|
||||||
// schema
|
// schema
|
||||||
schema: 'http://schema.org#',
|
schema: 'http://schema.org#',
|
||||||
PropertyValue: 'schema:PropertyValue',
|
PropertyValue: 'schema:PropertyValue',
|
||||||
|
|
|
@ -445,6 +445,7 @@ export class ApPersonService implements OnModuleInit, OnApplicationShutdown {
|
||||||
makeNotesFollowersOnlyBefore: (person as any).makeNotesFollowersOnlyBefore ?? null,
|
makeNotesFollowersOnlyBefore: (person as any).makeNotesFollowersOnlyBefore ?? null,
|
||||||
makeNotesHiddenBefore: (person as any).makeNotesHiddenBefore ?? null,
|
makeNotesHiddenBefore: (person as any).makeNotesHiddenBefore ?? null,
|
||||||
emojis,
|
emojis,
|
||||||
|
attributionDomains: (Array.isArray(person.attributionDomains) && person.attributionDomains.every(x => typeof x === 'string')) ? person.attributionDomains : [],
|
||||||
})) as MiRemoteUser;
|
})) as MiRemoteUser;
|
||||||
|
|
||||||
let _description: string | null = null;
|
let _description: string | null = null;
|
||||||
|
@ -628,6 +629,7 @@ export class ApPersonService implements OnModuleInit, OnApplicationShutdown {
|
||||||
// We use "!== false" to handle incorrect types, missing / null values, and "default to true" logic.
|
// We use "!== false" to handle incorrect types, missing / null values, and "default to true" logic.
|
||||||
hideOnlineStatus: person.hideOnlineStatus !== false,
|
hideOnlineStatus: person.hideOnlineStatus !== false,
|
||||||
isExplorable: person.discoverable !== false,
|
isExplorable: person.discoverable !== false,
|
||||||
|
attributionDomains: (Array.isArray(person.attributionDomains) && person.attributionDomains.every(x => typeof x === 'string')) ? person.attributionDomains : [],
|
||||||
...(await this.resolveAvatarAndBanner(exist, person.icon, person.image, person.backgroundUrl).catch(() => ({}))),
|
...(await this.resolveAvatarAndBanner(exist, person.icon, person.image, person.backgroundUrl).catch(() => ({}))),
|
||||||
} as Partial<MiRemoteUser> & Pick<MiRemoteUser, 'isBot' | 'isCat' | 'speakAsCat' | 'isLocked' | 'movedToUri' | 'alsoKnownAs' | 'isExplorable'>;
|
} as Partial<MiRemoteUser> & Pick<MiRemoteUser, 'isBot' | 'isCat' | 'speakAsCat' | 'isLocked' | 'movedToUri' | 'alsoKnownAs' | 'isExplorable'>;
|
||||||
|
|
||||||
|
|
|
@ -265,6 +265,7 @@ export interface IActor extends IObject {
|
||||||
enableRss?: boolean;
|
enableRss?: boolean;
|
||||||
listenbrainz?: string;
|
listenbrainz?: string;
|
||||||
backgroundUrl?: string;
|
backgroundUrl?: string;
|
||||||
|
attributionDomains?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isCollection = (object: IObject): object is ICollection =>
|
export const isCollection = (object: IObject): object is ICollection =>
|
||||||
|
|
|
@ -603,6 +603,7 @@ export class UserEntityService implements OnModuleInit {
|
||||||
enableRss: user.enableRss,
|
enableRss: user.enableRss,
|
||||||
mandatoryCW: user.mandatoryCW,
|
mandatoryCW: user.mandatoryCW,
|
||||||
rejectQuotes: user.rejectQuotes,
|
rejectQuotes: user.rejectQuotes,
|
||||||
|
attributionDomains: user.attributionDomains,
|
||||||
isSilenced: user.isSilenced || this.roleService.getUserPolicies(user.id).then(r => !r.canPublicNote),
|
isSilenced: user.isSilenced || this.roleService.getUserPolicies(user.id).then(r => !r.canPublicNote),
|
||||||
speakAsCat: user.speakAsCat ?? false,
|
speakAsCat: user.speakAsCat ?? false,
|
||||||
approved: user.approved,
|
approved: user.approved,
|
||||||
|
|
|
@ -389,6 +389,12 @@ export class MiUser {
|
||||||
})
|
})
|
||||||
public allowUnsignedFetch: UserUnsignedFetchOption;
|
public allowUnsignedFetch: UserUnsignedFetchOption;
|
||||||
|
|
||||||
|
@Column('varchar', {
|
||||||
|
name: 'attributionDomains',
|
||||||
|
length: 128, array: true, default: '{}',
|
||||||
|
})
|
||||||
|
public attributionDomains: string[];
|
||||||
|
|
||||||
constructor(data: Partial<MiUser>) {
|
constructor(data: Partial<MiUser>) {
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,14 @@ export const packedUserLiteSchema = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
attributionDomains: {
|
||||||
|
type: 'array',
|
||||||
|
nullable: false, optional: false,
|
||||||
|
items: {
|
||||||
|
type: 'string',
|
||||||
|
nullable: false, optional: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,9 @@ export const paramDef = {
|
||||||
enum: userUnsignedFetchOptions,
|
enum: userUnsignedFetchOptions,
|
||||||
nullable: false,
|
nullable: false,
|
||||||
},
|
},
|
||||||
|
attributionDomains: { type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
} },
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -373,6 +376,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
}
|
}
|
||||||
if (ps.mutedInstances !== undefined) profileUpdates.mutedInstances = ps.mutedInstances;
|
if (ps.mutedInstances !== undefined) profileUpdates.mutedInstances = ps.mutedInstances;
|
||||||
if (ps.notificationRecieveConfig !== undefined) profileUpdates.notificationRecieveConfig = ps.notificationRecieveConfig;
|
if (ps.notificationRecieveConfig !== undefined) profileUpdates.notificationRecieveConfig = ps.notificationRecieveConfig;
|
||||||
|
if (ps.attributionDomains !== undefined) updates.attributionDomains = ps.attributionDomains;
|
||||||
if (typeof ps.isLocked === 'boolean') updates.isLocked = ps.isLocked;
|
if (typeof ps.isLocked === 'boolean') updates.isLocked = ps.isLocked;
|
||||||
if (typeof ps.isExplorable === 'boolean') updates.isExplorable = ps.isExplorable;
|
if (typeof ps.isExplorable === 'boolean') updates.isExplorable = ps.isExplorable;
|
||||||
if (typeof ps.hideOnlineStatus === 'boolean') updates.hideOnlineStatus = ps.hideOnlineStatus;
|
if (typeof ps.hideOnlineStatus === 'boolean') updates.hideOnlineStatus = ps.hideOnlineStatus;
|
||||||
|
@ -663,7 +667,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
// these two methods need to be kept in sync with
|
// these two methods need to be kept in sync with
|
||||||
// `ApRendererService.renderPerson`
|
// `ApRendererService.renderPerson`
|
||||||
private userNeedsPublishing(oldUser: MiLocalUser, newUser: Partial<MiUser>): boolean {
|
private userNeedsPublishing(oldUser: MiLocalUser, newUser: Partial<MiUser>): boolean {
|
||||||
const basicFields: (keyof MiUser)[] = ['avatarId', 'bannerId', 'backgroundId', 'isBot', 'username', 'name', 'isLocked', 'isExplorable', 'isCat', 'noindex', 'speakAsCat', 'movedToUri', 'alsoKnownAs', 'hideOnlineStatus', 'enableRss', 'requireSigninToViewContents', 'makeNotesFollowersOnlyBefore', 'makeNotesHiddenBefore'];
|
const basicFields: (keyof MiUser)[] = ['avatarId', 'bannerId', 'backgroundId', 'isBot', 'username', 'name', 'isLocked', 'isExplorable', 'isCat', 'noindex', 'speakAsCat', 'movedToUri', 'alsoKnownAs', 'hideOnlineStatus', 'enableRss', 'requireSigninToViewContents', 'makeNotesFollowersOnlyBefore', 'makeNotesHiddenBefore', 'attributionDomains'];
|
||||||
for (const field of basicFields) {
|
for (const field of basicFields) {
|
||||||
if ((field in newUser) && oldUser[field] !== newUser[field]) {
|
if ((field in newUser) && oldUser[field] !== newUser[field]) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { RedisKVCache } from '@/misc/cache.js';
|
||||||
import { UtilityService } from '@/core/UtilityService.js';
|
import { UtilityService } from '@/core/UtilityService.js';
|
||||||
import { ApDbResolverService } from '@/core/activitypub/ApDbResolverService.js';
|
import { ApDbResolverService } from '@/core/activitypub/ApDbResolverService.js';
|
||||||
import type { MiAccessToken, NotesRepository } from '@/models/_.js';
|
import type { MiAccessToken, NotesRepository } from '@/models/_.js';
|
||||||
|
import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js';
|
||||||
import { ApUtilityService } from '@/core/activitypub/ApUtilityService.js';
|
import { ApUtilityService } from '@/core/activitypub/ApUtilityService.js';
|
||||||
import { ApRequestService } from '@/core/activitypub/ApRequestService.js';
|
import { ApRequestService } from '@/core/activitypub/ApRequestService.js';
|
||||||
import { SystemAccountService } from '@/core/SystemAccountService.js';
|
import { SystemAccountService } from '@/core/SystemAccountService.js';
|
||||||
|
@ -30,10 +31,14 @@ import { BucketRateLimit, Keyed, sendRateLimitHeaders } from '@/misc/rate-limit-
|
||||||
import type { MiLocalUser } from '@/models/User.js';
|
import type { MiLocalUser } from '@/models/User.js';
|
||||||
import { getIpHash } from '@/misc/get-ip-hash.js';
|
import { getIpHash } from '@/misc/get-ip-hash.js';
|
||||||
import { isRetryableError } from '@/misc/is-retryable-error.js';
|
import { isRetryableError } from '@/misc/is-retryable-error.js';
|
||||||
|
import * as Acct from '@/misc/acct.js';
|
||||||
import type { FastifyRequest, FastifyReply } from 'fastify';
|
import type { FastifyRequest, FastifyReply } from 'fastify';
|
||||||
|
|
||||||
export type LocalSummalyResult = SummalyResult & {
|
export type LocalSummalyResult = SummalyResult & {
|
||||||
haveNoteLocally?: boolean;
|
haveNoteLocally?: boolean;
|
||||||
|
linkAttribution?: {
|
||||||
|
userId: string,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Increment this to invalidate cached previews after a major change.
|
// Increment this to invalidate cached previews after a major change.
|
||||||
|
@ -82,6 +87,7 @@ export class UrlPreviewService {
|
||||||
private readonly utilityService: UtilityService,
|
private readonly utilityService: UtilityService,
|
||||||
private readonly apUtilityService: ApUtilityService,
|
private readonly apUtilityService: ApUtilityService,
|
||||||
private readonly apDbResolverService: ApDbResolverService,
|
private readonly apDbResolverService: ApDbResolverService,
|
||||||
|
private readonly remoteUserResolveService: RemoteUserResolveService,
|
||||||
private readonly apRequestService: ApRequestService,
|
private readonly apRequestService: ApRequestService,
|
||||||
private readonly systemAccountService: SystemAccountService,
|
private readonly systemAccountService: SystemAccountService,
|
||||||
private readonly apNoteService: ApNoteService,
|
private readonly apNoteService: ApNoteService,
|
||||||
|
@ -206,6 +212,8 @@ export class UrlPreviewService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.validateLinkAttribution(summary);
|
||||||
|
|
||||||
// Await this to avoid hammering redis when a bunch of URLs are fetched at once
|
// Await this to avoid hammering redis when a bunch of URLs are fetched at once
|
||||||
await this.previewCache.set(cacheKey, summary);
|
await this.previewCache.set(cacheKey, summary);
|
||||||
|
|
||||||
|
@ -426,6 +434,30 @@ export class UrlPreviewService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async validateLinkAttribution(summary: LocalSummalyResult) {
|
||||||
|
if (!summary.fediverseCreator) return;
|
||||||
|
if (!URL.canParse(summary.url)) return;
|
||||||
|
|
||||||
|
const url = URL.parse(summary.url);
|
||||||
|
|
||||||
|
const acct = Acct.parse(summary.fediverseCreator);
|
||||||
|
if (acct.host?.toLowerCase() === this.config.host) {
|
||||||
|
acct.host = null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const user = await this.remoteUserResolveService.resolveUser(acct.username, acct.host);
|
||||||
|
|
||||||
|
const attributionDomains = user.attributionDomains;
|
||||||
|
if (attributionDomains.some(x => `.${url?.host.toLowerCase()}`.endsWith(`.${x}`))) {
|
||||||
|
summary.linkAttribution = {
|
||||||
|
userId: user.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
this.logger.debug('User not found: ' + summary.fediverseCreator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Adapted from ApiCallService
|
// Adapted from ApiCallService
|
||||||
private async checkFetchPermissions(auth: AuthArray, reply: FastifyReply): Promise<boolean> {
|
private async checkFetchPermissions(auth: AuthArray, reply: FastifyReply): Promise<boolean> {
|
||||||
const [user, app] = auth;
|
const [user, app] = auth;
|
||||||
|
|
|
@ -65,6 +65,17 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
<I18n v-if="attributionUser" :src="i18n.ts.writtenBy" :class="$style.linkAttribution" tag="p">
|
||||||
|
<template #user>
|
||||||
|
<MkA v-user-preview="attributionUser.id" :to="userPage(attributionUser)">
|
||||||
|
<MkAvatar :class="$style.linkAttributionIcon" :user="attributionUser"/>
|
||||||
|
<MkUserName :user="attributionUser" style="color: var(--MI_THEME-accent)"/>
|
||||||
|
</MkA>
|
||||||
|
</template>
|
||||||
|
</I18n>
|
||||||
|
<p v-else-if="linkAttribution" :class="$style.linkAttribution"><MkEllipsis/></p>
|
||||||
|
|
||||||
<template v-if="showActions">
|
<template v-if="showActions">
|
||||||
<div v-if="tweetId" :class="$style.action">
|
<div v-if="tweetId" :class="$style.action">
|
||||||
<MkButton :small="true" inline @click="tweetExpanded = true">
|
<MkButton :small="true" inline @click="tweetExpanded = true">
|
||||||
|
@ -106,6 +117,7 @@ import { misskeyApi } from '@/utility/misskey-api.js';
|
||||||
import { warningExternalWebsite } from '@/utility/warning-external-website.js';
|
import { warningExternalWebsite } from '@/utility/warning-external-website.js';
|
||||||
import DynamicNoteSimple from '@/components/DynamicNoteSimple.vue';
|
import DynamicNoteSimple from '@/components/DynamicNoteSimple.vue';
|
||||||
import { $i } from '@/i';
|
import { $i } from '@/i';
|
||||||
|
import { userPage } from '@/filters/user.js';
|
||||||
|
|
||||||
type SummalyResult = Awaited<ReturnType<typeof summaly>>;
|
type SummalyResult = Awaited<ReturnType<typeof summaly>>;
|
||||||
|
|
||||||
|
@ -146,6 +158,10 @@ const player = ref<SummalyResult['player']>({
|
||||||
height: null,
|
height: null,
|
||||||
allow: [],
|
allow: [],
|
||||||
});
|
});
|
||||||
|
const linkAttribution = ref<{
|
||||||
|
userId: string,
|
||||||
|
} | null>(null);
|
||||||
|
const attributionUser = ref<Misskey.entities.User | null>(null);
|
||||||
const playerEnabled = ref(false);
|
const playerEnabled = ref(false);
|
||||||
const tweetId = ref<string | null>(null);
|
const tweetId = ref<string | null>(null);
|
||||||
const tweetExpanded = ref(props.detail);
|
const tweetExpanded = ref(props.detail);
|
||||||
|
@ -221,7 +237,12 @@ function refresh(withFetch = false) {
|
||||||
|
|
||||||
return res.json();
|
return res.json();
|
||||||
})
|
})
|
||||||
.then(async (info: SummalyResult & { haveNoteLocally?: boolean } | null) => {
|
.then(async (info: SummalyResult & {
|
||||||
|
haveNoteLocally?: boolean,
|
||||||
|
linkAttribution?: {
|
||||||
|
userId: string,
|
||||||
|
}
|
||||||
|
} | null) => {
|
||||||
unknownUrl.value = info == null;
|
unknownUrl.value = info == null;
|
||||||
title.value = info?.title ?? null;
|
title.value = info?.title ?? null;
|
||||||
description.value = info?.description ?? null;
|
description.value = info?.description ?? null;
|
||||||
|
@ -236,6 +257,16 @@ function refresh(withFetch = false) {
|
||||||
};
|
};
|
||||||
sensitive.value = info?.sensitive ?? false;
|
sensitive.value = info?.sensitive ?? false;
|
||||||
activityPub.value = info?.activityPub ?? null;
|
activityPub.value = info?.activityPub ?? null;
|
||||||
|
linkAttribution.value = info?.linkAttribution ?? null;
|
||||||
|
if (linkAttribution.value) {
|
||||||
|
try {
|
||||||
|
const response = await misskeyApi('users/show', { userId: linkAttribution.value.userId });
|
||||||
|
attributionUser.value = response;
|
||||||
|
} catch {
|
||||||
|
// makes the loading ellipsis vanish.
|
||||||
|
linkAttribution.value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
theNote.value = null;
|
theNote.value = null;
|
||||||
if (info?.haveNoteLocally) {
|
if (info?.haveNoteLocally) {
|
||||||
|
@ -395,6 +426,28 @@ refresh();
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.linkAttributionIcon {
|
||||||
|
display: inline-block;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
margin-left: 0.25em;
|
||||||
|
margin-right: 0.25em;
|
||||||
|
vertical-align: middle;
|
||||||
|
border-radius: 50%;
|
||||||
|
* {
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.linkAttribution {
|
||||||
|
width: 100%;
|
||||||
|
font-size: 0.8em;
|
||||||
|
display: inline-block;
|
||||||
|
margin: auto;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
.action {
|
.action {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
|
|
|
@ -15,36 +15,50 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch, computed } from 'vue';
|
||||||
import MkTextarea from '@/components/MkTextarea.vue';
|
import MkTextarea from '@/components/MkTextarea.vue';
|
||||||
import MkInfo from '@/components/MkInfo.vue';
|
import MkInfo from '@/components/MkInfo.vue';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import { ensureSignin } from '@/i.js';
|
import { ensureSignin } from '@/i.js';
|
||||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
|
import * as os from '@/os.js';
|
||||||
|
|
||||||
const $i = ensureSignin();
|
const $i = ensureSignin();
|
||||||
|
|
||||||
const instanceMutes = ref($i.mutedInstances.join('\n'));
|
const instanceMutes = ref($i.mutedInstances.join('\n'));
|
||||||
|
const domainArray = computed(() => {
|
||||||
|
return instanceMutes.value
|
||||||
|
.trim().split('\n')
|
||||||
|
.map(el => el.trim().toLowerCase())
|
||||||
|
.filter(el => el);
|
||||||
|
});
|
||||||
const changed = ref(false);
|
const changed = ref(false);
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
let mutes = instanceMutes.value
|
// checks for a full line without whitespace.
|
||||||
.trim().split('\n')
|
if (!domainArray.value.every(d => /^\S+$/.test(d))) {
|
||||||
.map(el => el.trim())
|
os.alert({
|
||||||
.filter(el => el);
|
type: 'error',
|
||||||
|
title: i18n.ts.invalidValue,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await misskeyApi('i/update', {
|
await misskeyApi('i/update', {
|
||||||
mutedInstances: mutes,
|
mutedInstances: domainArray.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
changed.value = false;
|
|
||||||
|
|
||||||
// Refresh filtered list to signal to the user how they've been saved
|
// Refresh filtered list to signal to the user how they've been saved
|
||||||
instanceMutes.value = mutes.join('\n');
|
instanceMutes.value = domainArray.value.join('\n');
|
||||||
|
|
||||||
|
changed.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(instanceMutes, () => {
|
watch(domainArray, (newArray, oldArray) => {
|
||||||
|
// compare arrays
|
||||||
|
if (newArray.length !== oldArray.length || !newArray.every((a, i) => a === oldArray[i])) {
|
||||||
changed.value = true;
|
changed.value = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<MkTextarea v-model="attributionDomains">
|
||||||
|
<template #label><SearchLabel>{{ i18n.ts.attributionDomains }}</SearchLabel></template>
|
||||||
|
<template #caption>
|
||||||
|
{{ i18n.ts.attributionDomainsDescription }}
|
||||||
|
<br/>
|
||||||
|
<Mfm :text="tutorialTag"/>
|
||||||
|
</template>
|
||||||
|
</MkTextarea>
|
||||||
|
<MkButton primary :disabled="!changed" @click="save()"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, watch, computed } from 'vue';
|
||||||
|
import { host as hostRaw } from '@@/js/config.js';
|
||||||
|
import { toUnicode } from 'punycode.js';
|
||||||
|
import MkTextarea from '@/components/MkTextarea.vue';
|
||||||
|
import MkButton from '@/components/MkButton.vue';
|
||||||
|
import { ensureSignin } from '@/i.js';
|
||||||
|
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||||
|
import { i18n } from '@/i18n.js';
|
||||||
|
import * as os from '@/os.js';
|
||||||
|
|
||||||
|
const $i = ensureSignin();
|
||||||
|
|
||||||
|
const attributionDomains = ref($i.attributionDomains.join('\n'));
|
||||||
|
const domainArray = computed(() => {
|
||||||
|
return attributionDomains.value
|
||||||
|
.trim().split('\n')
|
||||||
|
.map(el => el.trim().toLowerCase())
|
||||||
|
.filter(el => el);
|
||||||
|
});
|
||||||
|
const changed = ref(false);
|
||||||
|
const tutorialTag = '`<meta name="fediverse:creator" content="' + $i.username + '@' + toUnicode(hostRaw) + '" />`';
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
// checks for a full line without whitespace.
|
||||||
|
if (!domainArray.value.every(d => /^\S+$/.test(d))) {
|
||||||
|
os.alert({
|
||||||
|
type: 'error',
|
||||||
|
title: i18n.ts.invalidValue,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await misskeyApi('i/update', {
|
||||||
|
attributionDomains: domainArray.value,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Refresh filtered list to signal to the user how they've been saved
|
||||||
|
attributionDomains.value = domainArray.value.join('\n');
|
||||||
|
|
||||||
|
changed.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(domainArray, (newArray, oldArray) => {
|
||||||
|
// compare arrays
|
||||||
|
if (newArray.length !== oldArray.length || !newArray.every((a, i) => a === oldArray[i])) {
|
||||||
|
changed.value = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -163,6 +163,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template #caption>{{ i18n.ts.flagAsBotDescription }}</template>
|
<template #caption>{{ i18n.ts.flagAsBotDescription }}</template>
|
||||||
</MkSwitch>
|
</MkSwitch>
|
||||||
</SearchMarker>
|
</SearchMarker>
|
||||||
|
|
||||||
|
<SearchMarker
|
||||||
|
:label="i18n.ts.attributionDomains"
|
||||||
|
:keywords="['attribution', 'domains', 'preview', 'url']"
|
||||||
|
>
|
||||||
|
<AttributionDomainsSettings/>
|
||||||
|
</SearchMarker>
|
||||||
</div>
|
</div>
|
||||||
</MkFolder>
|
</MkFolder>
|
||||||
</SearchMarker>
|
</SearchMarker>
|
||||||
|
@ -172,6 +179,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, reactive, ref, watch, defineAsyncComponent } from 'vue';
|
import { computed, reactive, ref, watch, defineAsyncComponent } from 'vue';
|
||||||
|
import AttributionDomainsSettings from './profile.attribution-domains-setting.vue';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import MkInput from '@/components/MkInput.vue';
|
import MkInput from '@/components/MkInput.vue';
|
||||||
import MkSwitch from '@/components/MkSwitch.vue';
|
import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
|
|
|
@ -4292,6 +4292,7 @@ export type components = {
|
||||||
iconUrl: string | null;
|
iconUrl: string | null;
|
||||||
displayOrder: number;
|
displayOrder: number;
|
||||||
})[];
|
})[];
|
||||||
|
attributionDomains: string[];
|
||||||
};
|
};
|
||||||
UserDetailedNotMeOnly: {
|
UserDetailedNotMeOnly: {
|
||||||
/** Format: url */
|
/** Format: url */
|
||||||
|
@ -25185,6 +25186,7 @@ export type operations = {
|
||||||
defaultCWPriority?: 'default' | 'parent' | 'defaultParent' | 'parentDefault';
|
defaultCWPriority?: 'default' | 'parent' | 'defaultParent' | 'parentDefault';
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
allowUnsignedFetch?: 'never' | 'always' | 'essential' | 'staff';
|
allowUnsignedFetch?: 'never' | 'always' | 'essential' | 'staff';
|
||||||
|
attributionDomains?: string[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -598,6 +598,10 @@ roleAutomatic: "automatic"
|
||||||
translationTimeoutLabel: "Translation timeout"
|
translationTimeoutLabel: "Translation timeout"
|
||||||
translationTimeoutCaption: "Timeout in milliseconds for translation API requests."
|
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 {user}"
|
||||||
|
|
||||||
followingPub: "Following (Pub)"
|
followingPub: "Following (Pub)"
|
||||||
followersSub: "Followers (Sub)"
|
followersSub: "Followers (Sub)"
|
||||||
wellKnownResources: "Well-known resources"
|
wellKnownResources: "Well-known resources"
|
||||||
|
|
|
@ -7,3 +7,6 @@ openRemoteProfile: "Abrir perfil remoto"
|
||||||
allowClickingNotifications: "Permitir clicar em notificações"
|
allowClickingNotifications: "Permitir clicar em notificações"
|
||||||
pinnedOnly: "Fixado"
|
pinnedOnly: "Fixado"
|
||||||
blockingYou: "Bloqueando você"
|
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 {user}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue