Merge remote-tracking branch 'refs/remotes/misskey-original/develop' into develop

# Conflicts:
#	packages/frontend/src/components/MkAbuseReport.vue
#	packages/frontend/src/components/MkMention.vue
#	packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts
This commit is contained in:
mattyatea 2024-05-01 04:11:08 +09:00
commit 1a8d91355d
29 changed files with 458 additions and 108 deletions

View File

@ -35,6 +35,9 @@
- Enhance: リプライにて引用がある場合テキストが空でもノートできるように - Enhance: リプライにて引用がある場合テキストが空でもノートできるように
- 引用したいートのURLをコピーしリプライ投稿画面にペーストして添付することで達成できます - 引用したいートのURLをコピーしリプライ投稿画面にペーストして添付することで達成できます
- Enhance: フォローするかどうかの確認ダイアログを出せるように - Enhance: フォローするかどうかの確認ダイアログを出せるように
- Enhance: Playを手動でリロードできるように
- Enhance: 通報のコメント内のリンクをクリックした際、ウィンドウで開くように
- Chore: AiScriptを0.18.0にバージョンアップ
- Fix: 一部のページ内リンクが正しく動作しない問題を修正 - Fix: 一部のページ内リンクが正しく動作しない問題を修正
- Fix: 周年の実績が閏年を考慮しない問題を修正 - Fix: 周年の実績が閏年を考慮しない問題を修正
- Fix: ローカルURLのプレビューポップアップが左上に表示される - Fix: ローカルURLのプレビューポップアップが左上に表示される
@ -49,6 +52,10 @@
- Fix: ート詳細ページにおいてCW付き引用リートのCWボタンのラベルに「引用」が含まれていない問題を修正 - Fix: ート詳細ページにおいてCW付き引用リートのCWボタンのラベルに「引用」が含まれていない問題を修正
- Fix: ダイアログの入力で字数制限に違反していてもEnterキーが押せてしまう問題を修正 - Fix: ダイアログの入力で字数制限に違反していてもEnterキーが押せてしまう問題を修正
- Fix: ダイレクト投稿の宛先が保存されない問題を修正 - Fix: ダイレクト投稿の宛先が保存されない問題を修正
- Fix: Playのページを離れたときに、Playが正常に初期化されない問題を修正
- Fix: ページのOGP URLが間違っているのを修正
- Fix: リバーシの対局を正しく共有できないことがある問題を修正
- Fix: 通知をグループ化している際に、人数が正常に表示されないことがある問題を修正
### Server ### Server
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに - Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
@ -61,10 +68,12 @@
- Fix: リプライのみの引用リートと、CWのみの引用リートが純粋なリートとして誤って扱われてしまう問題を修正 - Fix: リプライのみの引用リートと、CWのみの引用リートが純粋なリートとして誤って扱われてしまう問題を修正
- Fix: 登録にメール認証が必須になっている場合、登録されているメールアドレスを削除できないように - Fix: 登録にメール認証が必須になっている場合、登録されているメールアドレスを削除できないように
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/606) (Cherry-picked from https://github.com/MisskeyIO/misskey/pull/606)
- Fix: Add Cache-Control to Bull Board
- Fix: nginx経由で/files/にRangeリクエストされた場合に正しく応答できないのを修正 - Fix: nginx経由で/files/にRangeリクエストされた場合に正しく応答できないのを修正
- Fix: 一部のタイムラインのストリーミングでインスタンスミュートが効かない問題を修正 - Fix: 一部のタイムラインのストリーミングでインスタンスミュートが効かない問題を修正
- Fix: グローバルタイムラインで返信が表示されないことがある問題を修正 - Fix: グローバルタイムラインで返信が表示されないことがある問題を修正
- Fix: リノートをミュートしたユーザの投稿のリノートがミュートされる問題を修正 - Fix: リノートをミュートしたユーザの投稿のリノートがミュートされる問題を修正
- Fix: AP Link等は添付ファイル扱いしないようになど (#13754)
## 2024.3.1 ## 2024.3.1

View File

@ -20,7 +20,7 @@ import type { Serialized } from '@/types.js';
import { ModerationLogService } from '@/core/ModerationLogService.js'; import { ModerationLogService } from '@/core/ModerationLogService.js';
import { MiEmojiRequest } from '@/models/EmojiRequest.js'; import { MiEmojiRequest } from '@/models/EmojiRequest.js';
const parseEmojiStrRegexp = /^(\w+)(?:@([\w.-]+))?$/; const parseEmojiStrRegexp = /^([-\w]+)(?:@([\w.-]+))?$/;
@Injectable() @Injectable()
export class CustomEmojiService implements OnApplicationShutdown { export class CustomEmojiService implements OnApplicationShutdown {

View File

@ -6,7 +6,7 @@
import { URL } from 'node:url'; import { URL } from 'node:url';
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import * as parse5 from 'parse5'; import * as parse5 from 'parse5';
import { Window } from 'happy-dom'; import { Window, XMLSerializer } from 'happy-dom';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js'; import type { Config } from '@/config.js';
import { intersperse } from '@/misc/prelude/array.js'; import { intersperse } from '@/misc/prelude/array.js';
@ -247,6 +247,8 @@ export class MfmService {
const doc = window.document; const doc = window.document;
const body = doc.createElement('p');
function appendChildren(children: mfm.MfmNode[], targetElement: any): void { function appendChildren(children: mfm.MfmNode[], targetElement: any): void {
if (children) { if (children) {
for (const child of children.map(x => (handlers as any)[x.type](x))) targetElement.appendChild(child); for (const child of children.map(x => (handlers as any)[x.type](x))) targetElement.appendChild(child);
@ -457,8 +459,8 @@ export class MfmService {
}, },
}; };
appendChildren(nodes, doc.body); appendChildren(nodes, body);
return `<p>${doc.body.innerHTML}</p>`; return new XMLSerializer().serializeToString(body);
} }
} }

View File

@ -17,7 +17,7 @@ import { bindThis } from '@/decorators.js';
import { checkHttps } from '@/misc/check-https.js'; import { checkHttps } from '@/misc/check-https.js';
import { ApResolverService } from '../ApResolverService.js'; import { ApResolverService } from '../ApResolverService.js';
import { ApLoggerService } from '../ApLoggerService.js'; import { ApLoggerService } from '../ApLoggerService.js';
import type { IObject } from '../type.js'; import { isDocument, type IObject } from '../type.js';
@Injectable() @Injectable()
export class ApImageService { export class ApImageService {
@ -39,7 +39,7 @@ export class ApImageService {
* Imageを作成します * Imageを作成します
*/ */
@bindThis @bindThis
public async createImage(actor: MiRemoteUser, value: string | IObject): Promise<MiDriveFile> { public async createImage(actor: MiRemoteUser, value: string | IObject): Promise<MiDriveFile | null> {
// 投稿者が凍結されていたらスキップ // 投稿者が凍結されていたらスキップ
if (actor.isSuspended) { if (actor.isSuspended) {
throw new Error('actor has been suspended'); throw new Error('actor has been suspended');
@ -47,16 +47,18 @@ export class ApImageService {
const image = await this.apResolverService.createResolver().resolve(value); const image = await this.apResolverService.createResolver().resolve(value);
if (!isDocument(image)) return null;
if (image.url == null) { if (image.url == null) {
throw new Error('invalid image: url not provided'); return null;
} }
if (typeof image.url !== 'string') { if (typeof image.url !== 'string') {
throw new Error('invalid image: unexpected type of url: ' + JSON.stringify(image.url, null, 2)); return null;
} }
if (!checkHttps(image.url)) { if (!checkHttps(image.url)) {
throw new Error('invalid image: unexpected schema of url: ' + image.url); return null;
} }
this.logger.info(`Creating the Image: ${image.url}`); this.logger.info(`Creating the Image: ${image.url}`);
@ -86,12 +88,11 @@ export class ApImageService {
/** /**
* Imageを解決します * Imageを解決します
* *
* Misskeyに対象のImageが登録されていればそれを返し * ImageをリモートサーバーからフェッチしてMisskeyに登録しそれを返します
* Misskeyに登録しそれを返します
*/ */
@bindThis @bindThis
public async resolveImage(actor: MiRemoteUser, value: string | IObject): Promise<MiDriveFile> { public async resolveImage(actor: MiRemoteUser, value: string | IObject): Promise<MiDriveFile | null> {
// TODO // TODO: Misskeyに対象のImageが登録されていればそれを返す
// リモートサーバーからフェッチしてきて登録 // リモートサーバーからフェッチしてきて登録
return await this.createImage(actor, value); return await this.createImage(actor, value);

View File

@ -4,7 +4,6 @@
*/ */
import { forwardRef, Inject, Injectable } from '@nestjs/common'; import { forwardRef, Inject, Injectable } from '@nestjs/common';
import promiseLimit from 'promise-limit';
import { In } from 'typeorm'; import { In } from 'typeorm';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import type { PollsRepository, EmojisRepository, NotesRepository } from '@/models/_.js'; import type { PollsRepository, EmojisRepository, NotesRepository } from '@/models/_.js';
@ -214,15 +213,13 @@ export class ApNoteService {
} }
// 添付ファイル // 添付ファイル
// TODO: attachmentは必ずしもImageではない const files: MiDriveFile[] = [];
// TODO: attachmentは必ずしも配列ではない
const limit = promiseLimit<MiDriveFile>(2); for (const attach of toArray(note.attachment)) {
const files = (await Promise.all(toArray(note.attachment).map(attach => ( attach.sensitive ||= note.sensitive; // Noteがsensitiveなら添付もsensitiveにする
limit(() => this.apImageService.resolveImage(actor, { const file = await this.apImageService.resolveImage(actor, attach);
...attach, if (file) files.push(file);
sensitive: note.sensitive, // Noteがsensitiveなら添付もsensitiveにする }
}))
))));
// リプライ // リプライ
const reply: MiNote | null = note.inReplyTo const reply: MiNote | null = note.inReplyTo

View File

@ -26,6 +26,7 @@ export interface IObject {
endTime?: Date; endTime?: Date;
icon?: any; icon?: any;
image?: any; image?: any;
mediaType?: string;
url?: ApObject | string; url?: ApObject | string;
href?: string; href?: string;
tag?: IObject | IObject[]; tag?: IObject | IObject[];
@ -241,14 +242,14 @@ export interface IKey extends IObject {
} }
export interface IApDocument extends IObject { export interface IApDocument extends IObject {
type: 'Document'; type: 'Audio' | 'Document' | 'Image' | 'Page' | 'Video';
name: string | null;
mediaType: string;
} }
export interface IApImage extends IObject { export const isDocument = (object: IObject): object is IApDocument =>
['Audio', 'Document', 'Image', 'Page', 'Video'].includes(getApType(object));
export interface IApImage extends IApDocument {
type: 'Image'; type: 'Image';
name: string | null;
} }
export interface ICreate extends IActivity { export interface ICreate extends IActivity {

View File

@ -120,12 +120,20 @@ export class ServerService implements OnApplicationShutdown {
return; return;
} }
const name = path.split('@')[0].replace(/\.webp$/i, ''); const emojiPath = path.replace(/\.webp$/i, '');
const host = path.split('@')[1]?.replace(/\.webp$/i, ''); const pathChunks = emojiPath.split('@');
if (pathChunks.length > 2) {
reply.code(400);
return;
}
const name = pathChunks.shift();
const host = pathChunks.pop();
const emoji = await this.emojisRepository.findOneBy({ const emoji = await this.emojisRepository.findOneBy({
// `@.` is the spec of ReactionService.decodeReaction // `@.` is the spec of ReactionService.decodeReaction
host: (host == null || host === '.') ? IsNull() : host, host: (host === undefined || host === '.') ? IsNull() : host,
name: name, name: name,
}); });

View File

@ -20,13 +20,188 @@ export const meta = {
res: { res: {
type: 'object', type: 'object',
properties: { properties: {
image: {
type: 'object',
optional: true,
properties: {
link: {
type: 'string',
optional: true,
},
url: {
type: 'string',
optional: false,
},
title: {
type: 'string',
optional: true,
},
},
},
paginationLinks: {
type: 'object',
optional: true,
properties: {
self: {
type: 'string',
optional: true,
},
first: {
type: 'string',
optional: true,
},
next: {
type: 'string',
optional: true,
},
last: {
type: 'string',
optional: true,
},
prev: {
type: 'string',
optional: true,
},
},
},
link: {
type: 'string',
optional: true,
},
title: {
type: 'string',
optional: true,
},
items: { items: {
type: 'array', type: 'array',
optional: false,
items: { items: {
type: 'object', type: 'object',
properties: {
link: {
type: 'string',
optional: true,
},
guid: {
type: 'string',
optional: true,
},
title: {
type: 'string',
optional: true,
},
pubDate: {
type: 'string',
optional: true,
},
creator: {
type: 'string',
optional: true,
},
summary: {
type: 'string',
optional: true,
},
content: {
type: 'string',
optional: true,
},
isoDate: {
type: 'string',
optional: true,
},
categories: {
type: 'array',
optional: true,
items: {
type: 'string',
},
},
contentSnippet: {
type: 'string',
optional: true,
},
enclosure: {
type: 'object',
optional: true,
properties: {
url: {
type: 'string',
optional: false,
},
length: {
type: 'number',
optional: true,
},
type: {
type: 'string',
optional: true,
},
},
},
},
}, },
} },
} feedUrl: {
type: 'string',
optional: true,
},
description: {
type: 'string',
optional: true,
},
itunes: {
type: 'object',
optional: true,
additionalProperties: true,
properties: {
image: {
type: 'string',
optional: true,
},
owner: {
type: 'object',
optional: true,
properties: {
name: {
type: 'string',
optional: true,
},
email: {
type: 'string',
optional: true,
},
},
},
author: {
type: 'string',
optional: true,
},
summary: {
type: 'string',
optional: true,
},
explicit: {
type: 'string',
optional: true,
},
categories: {
type: 'array',
optional: true,
items: {
type: 'string',
},
},
keywords: {
type: 'array',
optional: true,
items: {
type: 'string',
},
},
},
},
},
}, },
} as const; } as const;

View File

@ -211,6 +211,10 @@ export class ClientServerService {
// %71ueueとかでリクエストされたら困るため // %71ueueとかでリクエストされたら困るため
const url = decodeURI(request.routeOptions.url); const url = decodeURI(request.routeOptions.url);
if (url === bullBoardPath || url.startsWith(bullBoardPath + '/')) { if (url === bullBoardPath || url.startsWith(bullBoardPath + '/')) {
if (!url.startsWith(bullBoardPath + '/static/')) {
reply.header('Cache-Control', 'private, max-age=0, must-revalidate');
}
const token = request.cookies.token; const token = request.cookies.token;
if (token == null) { if (token == null) {
reply.code(401).send('Login required'); reply.code(401).send('Login required');

View File

@ -3,7 +3,7 @@ extends ./base
block vars block vars
- const user = page.user; - const user = page.user;
- const title = page.title; - const title = page.title;
- const url = `${config.url}/@${user.username}/${page.name}`; - const url = `${config.url}/@${user.username}/pages/${page.name}`;
block title block title
= `${title} | ${instanceName}` = `${title} | ${instanceName}`

View File

@ -39,6 +39,12 @@ describe('MfmService', () => {
const output = '<p>foo <i>bar</i></p>'; const output = '<p>foo <i>bar</i></p>';
assert.equal(mfmService.toHtml(mfm.parse(input)), output); assert.equal(mfmService.toHtml(mfm.parse(input)), output);
}); });
test('escape', () => {
const input = '```\n<p>Hello, world!</p>\n```';
const output = '<p><pre><code>&lt;p&gt;Hello, world!&lt;/p&gt;</code></pre></p>';
assert.equal(mfmService.toHtml(mfm.parse(input)), output);
});
}); });
describe('fromHtml', () => { describe('fromHtml', () => {

View File

@ -17,7 +17,7 @@ import { GlobalModule } from '@/GlobalModule.js';
import { CoreModule } from '@/core/CoreModule.js'; import { CoreModule } from '@/core/CoreModule.js';
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js'; import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
import { LoggerService } from '@/core/LoggerService.js'; import { LoggerService } from '@/core/LoggerService.js';
import type { IActor, IApDocument, ICollection, IPost } from '@/core/activitypub/type.js'; import type { IActor, IApDocument, ICollection, IObject, IPost } from '@/core/activitypub/type.js';
import { MiMeta, MiNote } from '@/models/_.js'; import { MiMeta, MiNote } from '@/models/_.js';
import { secureRndstr } from '@/misc/secure-rndstr.js'; import { secureRndstr } from '@/misc/secure-rndstr.js';
import { DownloadService } from '@/core/DownloadService.js'; import { DownloadService } from '@/core/DownloadService.js';
@ -295,7 +295,7 @@ describe('ActivityPub', () => {
await createRandomRemoteUser(resolver, personService), await createRandomRemoteUser(resolver, personService),
imageObject, imageObject,
); );
assert.ok(!driveFile.isLink); assert.ok(driveFile && !driveFile.isLink);
const sensitiveImageObject: IApDocument = { const sensitiveImageObject: IApDocument = {
type: 'Document', type: 'Document',
@ -308,7 +308,7 @@ describe('ActivityPub', () => {
await createRandomRemoteUser(resolver, personService), await createRandomRemoteUser(resolver, personService),
sensitiveImageObject, sensitiveImageObject,
); );
assert.ok(!sensitiveDriveFile.isLink); assert.ok(sensitiveDriveFile && !sensitiveDriveFile.isLink);
}); });
test('cacheRemoteFiles=false disables caching', async () => { test('cacheRemoteFiles=false disables caching', async () => {
@ -324,7 +324,7 @@ describe('ActivityPub', () => {
await createRandomRemoteUser(resolver, personService), await createRandomRemoteUser(resolver, personService),
imageObject, imageObject,
); );
assert.ok(driveFile.isLink); assert.ok(driveFile && driveFile.isLink);
const sensitiveImageObject: IApDocument = { const sensitiveImageObject: IApDocument = {
type: 'Document', type: 'Document',
@ -337,7 +337,7 @@ describe('ActivityPub', () => {
await createRandomRemoteUser(resolver, personService), await createRandomRemoteUser(resolver, personService),
sensitiveImageObject, sensitiveImageObject,
); );
assert.ok(sensitiveDriveFile.isLink); assert.ok(sensitiveDriveFile && sensitiveDriveFile.isLink);
}); });
test('cacheRemoteSensitiveFiles=false only affects sensitive files', async () => { test('cacheRemoteSensitiveFiles=false only affects sensitive files', async () => {
@ -353,7 +353,7 @@ describe('ActivityPub', () => {
await createRandomRemoteUser(resolver, personService), await createRandomRemoteUser(resolver, personService),
imageObject, imageObject,
); );
assert.ok(!driveFile.isLink); assert.ok(driveFile && !driveFile.isLink);
const sensitiveImageObject: IApDocument = { const sensitiveImageObject: IApDocument = {
type: 'Document', type: 'Document',
@ -366,7 +366,19 @@ describe('ActivityPub', () => {
await createRandomRemoteUser(resolver, personService), await createRandomRemoteUser(resolver, personService),
sensitiveImageObject, sensitiveImageObject,
); );
assert.ok(sensitiveDriveFile.isLink); assert.ok(sensitiveDriveFile && sensitiveDriveFile.isLink);
});
test('Link is not an attachment files', async () => {
const linkObject: IObject = {
type: 'Link',
href: 'https://example.com/',
};
const driveFile = await imageService.createImage(
await createRandomRemoteUser(resolver, personService),
linkObject,
);
assert.strictEqual(driveFile, null);
}); });
}); });
}); });

View File

@ -24,7 +24,7 @@
"@rollup/plugin-json": "6.1.0", "@rollup/plugin-json": "6.1.0",
"@rollup/plugin-replace": "5.0.5", "@rollup/plugin-replace": "5.0.5",
"@rollup/pluginutils": "5.1.0", "@rollup/pluginutils": "5.1.0",
"@syuilo/aiscript": "0.17.0", "@syuilo/aiscript": "0.18.0",
"@tabler/icons-webfont": "2.44.0", "@tabler/icons-webfont": "2.44.0",
"@twemoji/parser": "15.0.0", "@twemoji/parser": "15.0.0",
"@vitejs/plugin-vue": "5.0.4", "@vitejs/plugin-vue": "5.0.4",

View File

@ -20,7 +20,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
<div :class="$style.detail"> <div :class="$style.detail">
<div> <div>
<Mfm :text="report.comment"/> <Mfm :text="report.comment" :linkBehavior="'window'"/>
<MkFolder v-if="report.notes.length !== 0" :class="$style.notes"> <MkFolder v-if="report.notes.length !== 0" :class="$style.notes">
<template #label>{{ i18n.ts.reportedNote }}</template> <template #label>{{ i18n.ts.reportedNote }}</template>
<div v-for="note in report.notes" :class="$style.notes"> <div v-for="note in report.notes" :class="$style.notes">

View File

@ -6,6 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template> <template>
<component <component
:is="self ? 'MkA' : 'a'" ref="el" style="word-break: break-all;" class="_link" :[attr]="self ? url.substring(local.length) : url" :rel="rel ?? 'nofollow noopener'" :target="target" :is="self ? 'MkA' : 'a'" ref="el" style="word-break: break-all;" class="_link" :[attr]="self ? url.substring(local.length) : url" :rel="rel ?? 'nofollow noopener'" :target="target"
:behavior="props.behavior"
:title="url" :title="url"
> >
<slot></slot> <slot></slot>
@ -19,10 +20,12 @@ import { url as local } from '@/config.js';
import { useTooltip } from '@/scripts/use-tooltip.js'; import { useTooltip } from '@/scripts/use-tooltip.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { isEnabledUrlPreview } from '@/instance.js'; import { isEnabledUrlPreview } from '@/instance.js';
import { MkABehavior } from '@/components/global/MkA.vue';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
url: string; url: string;
rel?: null | string; rel?: null | string;
behavior?: MkABehavior;
}>(), { }>(), {
}); });

View File

@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<MkA v-user-preview="canonical" :class="[$style.root, { [$style.isMe]: isMe && gamingType === '' , [$style.gamingDark]: gamingType === 'dark',[$style.gamingLight]: gamingType === 'light' }]" :to="url" :style="{ background: bgCss }"> <MkA v-user-preview="canonical" :class="[$style.root, { [$style.isMe]: isMe && gamingType === '' , [$style.gamingDark]: gamingType === 'dark',[$style.gamingLight]: gamingType === 'light' }]" :to="url" :style="{ background: bgCss }" :behavior="behavior">
<img :class="$style.icon" :src="avatarUrl" alt=""> <img :class="$style.icon" :src="avatarUrl" alt="">
<span> <span>
<span>@{{ username }}</span> <span>@{{ username }}</span>
@ -21,12 +21,14 @@ import { host as localHost } from '@/config.js';
import { $i } from '@/account.js'; import { $i } from '@/account.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { getStaticImageUrl } from '@/scripts/media-proxy.js'; import { getStaticImageUrl } from '@/scripts/media-proxy.js';
import { MkABehavior } from '@/components/global/MkA.vue';
const gamingType = computed(defaultStore.makeGetterSetter('gamingType')); const gamingType = computed(defaultStore.makeGetterSetter('gamingType'));
const props = defineProps<{ const props = defineProps<{
username: string; username: string;
host: string; host: string;
behavior?: MkABehavior;
}>(); }>();
const canonical = props.host === localHost ? `@${props.username}` : `@${props.username}@${toUnicode(props.host)}`; const canonical = props.host === localHost ? `@${props.username}` : `@${props.username}@${toUnicode(props.host)}`;

View File

@ -58,8 +58,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<span v-else-if="notification.type === 'achievementEarned'">{{ i18n.ts._notification.achievementEarned }}</span> <span v-else-if="notification.type === 'achievementEarned'">{{ i18n.ts._notification.achievementEarned }}</span>
<span v-else-if="notification.type === 'test'">{{ i18n.ts._notification.testNotification }}</span> <span v-else-if="notification.type === 'test'">{{ i18n.ts._notification.testNotification }}</span>
<MkA v-else-if="notification.type === 'follow' || notification.type === 'mention' || notification.type === 'reply' || notification.type === 'renote' || notification.type === 'quote' || notification.type === 'reaction' || notification.type === 'receiveFollowRequest' || notification.type === 'followRequestAccepted'" v-user-preview="notification.user.id" :class="$style.headerName" :to="userPage(notification.user)"><MkUserName :user="notification.user"/></MkA> <MkA v-else-if="notification.type === 'follow' || notification.type === 'mention' || notification.type === 'reply' || notification.type === 'renote' || notification.type === 'quote' || notification.type === 'reaction' || notification.type === 'receiveFollowRequest' || notification.type === 'followRequestAccepted'" v-user-preview="notification.user.id" :class="$style.headerName" :to="userPage(notification.user)"><MkUserName :user="notification.user"/></MkA>
<span v-else-if="notification.type === 'reaction:grouped' && notification.note.reactionAcceptance === 'likeOnly'">{{ i18n.tsx._notification.likedBySomeUsers({ n: notification.reactions.length }) }}</span> <span v-else-if="notification.type === 'reaction:grouped' && notification.note.reactionAcceptance === 'likeOnly'">{{ i18n.tsx._notification.likedBySomeUsers({ n: getActualReactedUsersCount(notification) }) }}</span>
<span v-else-if="notification.type === 'reaction:grouped'">{{ i18n.tsx._notification.reactedBySomeUsers({ n: notification.reactions.length }) }}</span> <span v-else-if="notification.type === 'reaction:grouped'">{{ i18n.tsx._notification.reactedBySomeUsers({ n: getActualReactedUsersCount(notification) }) }}</span>
<span v-else-if="notification.type === 'renote:grouped'">{{ i18n.tsx._notification.renotedBySomeUsers({ n: notification.users.length }) }}</span> <span v-else-if="notification.type === 'renote:grouped'">{{ i18n.tsx._notification.renotedBySomeUsers({ n: notification.users.length }) }}</span>
<span v-else-if="notification.type === 'app'">{{ notification.header }}</span> <span v-else-if="notification.type === 'app'">{{ notification.header }}</span>
<MkTime v-if="withTime" :time="notification.createdAt" :class="$style.headerTime"/> <MkTime v-if="withTime" :time="notification.createdAt" :class="$style.headerTime"/>
@ -72,7 +72,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkA> </MkA>
<MkA v-else-if="notification.type === 'renote' || notification.type === 'renote:grouped'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note.renote)"> <MkA v-else-if="notification.type === 'renote' || notification.type === 'renote:grouped'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note.renote)">
<i class="ti ti-quote" :class="$style.quote"></i> <i class="ti ti-quote" :class="$style.quote"></i>
<Mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="true" :author="notification.note.renote.user"/> <Mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="true" :author="notification.note.renote?.user"/>
<i class="ti ti-quote" :class="$style.quote"></i> <i class="ti ti-quote" :class="$style.quote"></i>
</MkA> </MkA>
<MkA v-else-if="notification.type === 'reply'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)"> <MkA v-else-if="notification.type === 'reply'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
@ -174,6 +174,11 @@ const rejectFollowRequest = () => {
followRequestDone.value = true; followRequestDone.value = true;
misskeyApi('following/requests/reject', { userId: props.notification.user.id }); misskeyApi('following/requests/reject', { userId: props.notification.user.id });
}; };
function getActualReactedUsersCount(notification: Misskey.entities.Notification) {
if (notification.type !== 'reaction:grouped') return 0;
return new Set(notification.reactions.map((reaction) => reaction.user.id)).size;
}
</script> </script>
<style lang="scss" module> <style lang="scss" module>

View File

@ -9,6 +9,10 @@ SPDX-License-Identifier: AGPL-3.0-only
</a> </a>
</template> </template>
<script lang="ts">
export type MkABehavior = 'window' | 'browser' | null;
</script>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, shallowRef } from 'vue'; import { computed, shallowRef } from 'vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
@ -20,12 +24,14 @@ import { useRouter } from '@/router/supplier.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
to: string; to: string;
activeClass?: null | string; activeClass?: null | string;
behavior?: null | 'window' | 'browser'; behavior?: MkABehavior;
}>(), { }>(), {
activeClass: null, activeClass: null,
behavior: null, behavior: null,
}); });
const linkBehaviour = props.behavior;
const el = shallowRef<HTMLElement>(); const el = shallowRef<HTMLElement>();
defineExpose({ $el: el }); defineExpose({ $el: el });

View File

@ -17,7 +17,7 @@ import MkCode from '@/components/MkCode.vue';
import MkCodeInline from '@/components/MkCodeInline.vue'; import MkCodeInline from '@/components/MkCodeInline.vue';
import MkGoogle from '@/components/MkGoogle.vue'; import MkGoogle from '@/components/MkGoogle.vue';
import MkSparkle from '@/components/MkSparkle.vue'; import MkSparkle from '@/components/MkSparkle.vue';
import MkA from '@/components/global/MkA.vue'; import MkA, { MkABehavior } from '@/components/global/MkA.vue';
import { host } from '@/config'; import { host } from '@/config';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
import { mixEmoji } from '@/scripts/emojiKitchen/emojiMixer'; import { mixEmoji } from '@/scripts/emojiKitchen/emojiMixer';
@ -77,6 +77,7 @@ type MfmProps = {
parsedNodes?: mfm.MfmNode[] | null; parsedNodes?: mfm.MfmNode[] | null;
enableEmojiMenu?: boolean; enableEmojiMenu?: boolean;
enableEmojiMenuReaction?: boolean; enableEmojiMenuReaction?: boolean;
linkBehavior?: MkABehavior;
}; };
type MfmEvents = { type MfmEvents = {
@ -415,6 +416,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
key: Math.random(), key: Math.random(),
url: token.props.url, url: token.props.url,
rel: 'nofollow noopener', rel: 'nofollow noopener',
behavior: props.linkBehavior,
})]; })];
} }
@ -423,6 +425,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
key: Math.random(), key: Math.random(),
url: token.props.url, url: token.props.url,
rel: 'nofollow noopener', rel: 'nofollow noopener',
behavior: props.linkBehavior,
}, genEl(token.children, scale, true))]; }, genEl(token.children, scale, true))];
} }
@ -431,6 +434,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
key: Math.random(), key: Math.random(),
host: (token.props.host == null && props.author && props.author.host != null ? props.author.host : token.props.host) ?? host, host: (token.props.host == null && props.author && props.author.host != null ? props.author.host : token.props.host) ?? host,
username: token.props.username, username: token.props.username,
behavior: props.linkBehavior,
})]; })];
} }
@ -439,6 +443,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
key: Math.random(), key: Math.random(),
to: isNote ? `/tags/${encodeURIComponent(token.props.hashtag)}` : `/user-tags/${encodeURIComponent(token.props.hashtag)}`, to: isNote ? `/tags/${encodeURIComponent(token.props.hashtag)}` : `/user-tags/${encodeURIComponent(token.props.hashtag)}`,
style: 'color:var(--hashtag);', style: 'color:var(--hashtag);',
behavior: props.linkBehavior,
}, `#${token.props.hashtag}`)]; }, `#${token.props.hashtag}`)];
} }

View File

@ -6,6 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template> <template>
<component <component
:is="self ? 'MkA' : 'a'" ref="el" :class="$style.root" class="_link" :[attr]="self ? props.url.substring(local.length) : props.url" :rel="rel ?? 'nofollow noopener'" :target="target" :is="self ? 'MkA' : 'a'" ref="el" :class="$style.root" class="_link" :[attr]="self ? props.url.substring(local.length) : props.url" :rel="rel ?? 'nofollow noopener'" :target="target"
:behavior = "props.behavior"
@contextmenu.stop="() => {}" @contextmenu.stop="() => {}"
> >
<template v-if="!self"> <template v-if="!self">
@ -31,11 +32,13 @@ import * as os from '@/os.js';
import { useTooltip } from '@/scripts/use-tooltip.js'; import { useTooltip } from '@/scripts/use-tooltip.js';
import { safeURIDecode } from '@/scripts/safe-uri-decode.js'; import { safeURIDecode } from '@/scripts/safe-uri-decode.js';
import { isEnabledUrlPreview } from '@/instance.js'; import { isEnabledUrlPreview } from '@/instance.js';
import { MkABehavior } from '@/components/global/MkA.vue';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
url: string; url: string;
rel?: string; rel?: string;
showUrlPreview?: boolean; showUrlPreview?: boolean;
behavior?: MkABehavior;
}>(), { }>(), {
showUrlPreview: true, showUrlPreview: true,
}); });

View File

@ -48,7 +48,7 @@ import MkInput from '@/components/MkInput.vue';
import MkSelect from '@/components/MkSelect.vue'; import MkSelect from '@/components/MkSelect.vue';
import { useRouter } from '@/router/supplier.js'; import { useRouter } from '@/router/supplier.js';
const PRESET_DEFAULT = `/// @ 0.16.0 const PRESET_DEFAULT = `/// @ 0.18.0
var name = "" var name = ""
@ -60,13 +60,13 @@ Ui:render([
Ui:C:button({ Ui:C:button({
text: "Hello" text: "Hello"
onClick: @() { onClick: @() {
Mk:dialog(null \`Hello, {name}!\`) Mk:dialog(null, \`Hello, {name}!\`)
} }
}) })
]) ])
`; `;
const PRESET_OMIKUJI = `/// @ 0.16.0 const PRESET_OMIKUJI = `/// @ 0.18.0
// //
// //
@ -81,11 +81,11 @@ let choices = [
"大凶" "大凶"
] ]
// ID+ // PlayID+ID+
let random = Math:gen_rng(\`{USER_ID}{Date:year()}{Date:month()}{Date:day()}\`) let random = Math:gen_rng(\`{THIS_ID}{USER_ID}{Date:year()}{Date:month()}{Date:day()}\`)
// //
let chosen = choices[random(0 (choices.len - 1))] let chosen = choices[random(0, (choices.len - 1))]
// //
let result = \`今日のあなたの運勢は **{chosen}** です。\` let result = \`今日のあなたの運勢は **{chosen}** です。\`
@ -109,7 +109,7 @@ Ui:render([
]) ])
`; `;
const PRESET_SHUFFLE = `/// @ 0.16.0 const PRESET_SHUFFLE = `/// @ 0.18.0
// //
let string = "ペペロンチーノ" let string = "ペペロンチーノ"
@ -123,13 +123,13 @@ var cursor = 0
@do() { @do() {
if (cursor != 0) { if (cursor != 0) {
results = results.slice(0 (cursor + 1)) results = results.slice(0, (cursor + 1))
cursor = 0 cursor = 0
} }
let chars = [] let chars = []
for (let i, length) { for (let i, length) {
let r = Math:rnd(0 (length - 1)) let r = Math:rnd(0, (length - 1))
chars.push(string.pick(r)) chars.push(string.pick(r))
} }
let result = chars.join("") let result = chars.join("")
@ -163,11 +163,11 @@ var cursor = 0
text: "←" text: "←"
disabled: !(results.len > 1 && (results.len - cursor) > 1) disabled: !(results.len > 1 && (results.len - cursor) > 1)
onClick: back onClick: back
} { }, {
text: "→" text: "→"
disabled: !(results.len > 1 && cursor > 0) disabled: !(results.len > 1 && cursor > 0)
onClick: forward onClick: forward
} { }, {
text: "引き直す" text: "引き直す"
onClick: do onClick: do
}] }]
@ -188,27 +188,27 @@ var cursor = 0
do() do()
`; `;
const PRESET_QUIZ = `/// @ 0.16.0 const PRESET_QUIZ = `/// @ 0.18.0
let title = '地理クイズ' let title = '地理クイズ'
let qas = [{ let qas = [{
q: 'オーストラリアの首都は?' q: 'オーストラリアの首都は?'
choices: ['シドニー' 'キャンベラ' 'メルボルン'] choices: ['シドニー', 'キャンベラ', 'メルボルン']
a: 'キャンベラ' a: 'キャンベラ'
aDescription: '最大の都市はシドニーですが首都はキャンベラです。' aDescription: '最大の都市はシドニーですが首都はキャンベラです。'
} { }, {
q: '国土面積2番目の国は' q: '国土面積2番目の国は'
choices: ['カナダ' 'アメリカ' '中国'] choices: ['カナダ', 'アメリカ', '中国']
a: 'カナダ' a: 'カナダ'
aDescription: '大きい順にロシア、カナダ、アメリカ、中国です。' aDescription: '大きい順にロシア、カナダ、アメリカ、中国です。'
} { }, {
q: '二重内陸国ではないのは?' q: '二重内陸国ではないのは?'
choices: ['リヒテンシュタイン' 'ウズベキスタン' 'レソト'] choices: ['リヒテンシュタイン', 'ウズベキスタン', 'レソト']
a: 'レソト' a: 'レソト'
aDescription: 'レソトは(一重)内陸国です。' aDescription: 'レソトは(一重)内陸国です。'
} { }, {
q: '閘門がない運河は?' q: '閘門がない運河は?'
choices: ['キール運河' 'スエズ運河' 'パナマ運河'] choices: ['キール運河', 'スエズ運河', 'パナマ運河']
a: 'スエズ運河' a: 'スエズ運河'
aDescription: 'スエズ運河は高低差がないので閘門はありません。' aDescription: 'スエズ運河は高低差がないので閘門はありません。'
}] }]
@ -244,9 +244,9 @@ each (let qa, qas) {
}) })
Ui:C:container({ Ui:C:container({
children: [] children: []
} \`{qa.id}:a\`) }, \`{qa.id}:a\`)
] ]
} qa.id)) }, qa.id))
} }
@finish() { @finish() {
@ -296,12 +296,12 @@ qaEls.push(Ui:C:container({
onClick: finish onClick: finish
}) })
] ]
} 'footer')) }, 'footer'))
Ui:render(qaEls) Ui:render(qaEls)
`; `;
const PRESET_TIMELINE = `/// @ 0.16.0 const PRESET_TIMELINE = `/// @ 0.18.0
// API // API
@fetch() { @fetch() {
@ -315,7 +315,7 @@ const PRESET_TIMELINE = `/// @ 0.16.0
]) ])
// //
let notes = Mk:api("notes/local-timeline" {}) let notes = Mk:api("notes/local-timeline", {})
// UI // UI
let noteEls = [] let noteEls = []

View File

@ -15,11 +15,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkAsUi v-if="root" :component="root" :components="components"/> <MkAsUi v-if="root" :component="root" :components="components"/>
</div> </div>
<div class="actions _panel"> <div class="actions _panel">
<MkButton v-if="flash.isLiked" v-tooltip="i18n.ts.unlike" asLike class="button" rounded primary @click="unlike()"><i class="ti ti-heart"></i><span v-if="flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton> <div class="items">
<MkButton v-else v-tooltip="i18n.ts.like" asLike class="button" rounded @click="like()"><i class="ti ti-heart"></i><span v-if="flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton> <MkButton v-tooltip="i18n.ts.reload" class="button" rounded @click="reset"><i class="ti ti-reload"></i></MkButton>
<MkButton v-tooltip="i18n.ts.shareWithNote" class="button" rounded @click="shareWithNote"><i class="ti ti-repeat ti-fw"></i></MkButton> </div>
<MkButton v-tooltip="i18n.ts.copyLink" class="button" rounded @click="copyLink"><i class="ti ti-link ti-fw"></i></MkButton> <div class="items">
<MkButton v-if="isSupportShare()" v-tooltip="i18n.ts.share" class="button" rounded @click="share"><i class="ti ti-share ti-fw"></i></MkButton> <MkButton v-if="flash.isLiked" v-tooltip="i18n.ts.unlike" asLike class="button" rounded primary @click="unlike()"><i class="ti ti-heart"></i><span v-if="flash?.likedCount && flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton>
<MkButton v-else v-tooltip="i18n.ts.like" asLike class="button" rounded @click="like()"><i class="ti ti-heart"></i><span v-if="flash?.likedCount && flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton>
<MkButton v-tooltip="i18n.ts.copyLink" class="button" rounded @click="copyLink"><i class="ti ti-link ti-fw"></i></MkButton>
<MkButton v-tooltip="i18n.ts.share" class="button" rounded @click="share"><i class="ti ti-share ti-fw"></i></MkButton>
</div>
</div> </div>
</div> </div>
<div v-else :class="$style.ready"> <div v-else :class="$style.ready">
@ -49,7 +53,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkA v-if="$i && $i.id === flash.userId" :to="`/play/${flash.id}/edit`" style="color: var(--accent);">{{ i18n.ts._play.editThisPage }}</MkA> <MkA v-if="$i && $i.id === flash.userId" :to="`/play/${flash.id}/edit`" style="color: var(--accent);">{{ i18n.ts._play.editThisPage }}</MkA>
<MkAd :prefer="['horizontal', 'horizontal-big']"/> <MkAd :prefer="['horizontal', 'horizontal-big']"/>
</div> </div>
<MkError v-else-if="error" @retry="fetchPage()"/> <MkError v-else-if="error" @retry="fetchFlash()"/>
<MkLoading v-else/> <MkLoading v-else/>
</Transition> </Transition>
</MkSpacer> </MkSpacer>
@ -94,12 +98,33 @@ function fetchFlash() {
}); });
} }
function share(ev: MouseEvent) {
if (!flash.value) return;
os.popupMenu([
{
text: i18n.ts.shareWithNote,
icon: 'ti ti-pencil',
action: shareWithNote,
},
...(isSupportShare() ? [{
text: i18n.ts.share,
icon: 'ti ti-share',
action: shareWithNavigator,
}] : []),
], ev.currentTarget ?? ev.target);
}
function copyLink() { function copyLink() {
if (!flash.value) return;
copyToClipboard(`${url}/play/${flash.value.id}`); copyToClipboard(`${url}/play/${flash.value.id}`);
os.success(); os.success();
} }
function share() { function shareWithNavigator() {
if (!flash.value) return;
navigator.share({ navigator.share({
title: flash.value.title, title: flash.value.title,
text: flash.value.summary, text: flash.value.summary,
@ -108,21 +133,28 @@ function share() {
} }
function shareWithNote() { function shareWithNote() {
if (!flash.value) return;
os.post({ os.post({
initialText: `${flash.value.title} ${url}/play/${flash.value.id}`, initialText: `${flash.value.title}\n${url}/play/${flash.value.id}`,
instant: true,
}); });
} }
function like() { function like() {
if (!flash.value) return;
os.apiWithDialog('flash/like', { os.apiWithDialog('flash/like', {
flashId: flash.value.id, flashId: flash.value.id,
}).then(() => { }).then(() => {
flash.value.isLiked = true; flash.value!.isLiked = true;
flash.value.likedCount++; flash.value!.likedCount++;
}); });
} }
async function unlike() { async function unlike() {
if (!flash.value) return;
const confirm = await os.confirm({ const confirm = await os.confirm({
type: 'warning', type: 'warning',
text: i18n.ts.unlikeConfirm, text: i18n.ts.unlikeConfirm,
@ -131,8 +163,8 @@ async function unlike() {
os.apiWithDialog('flash/unlike', { os.apiWithDialog('flash/unlike', {
flashId: flash.value.id, flashId: flash.value.id,
}).then(() => { }).then(() => {
flash.value.isLiked = false; flash.value!.isLiked = false;
flash.value.likedCount--; flash.value!.likedCount--;
}); });
} }
@ -152,6 +184,7 @@ function start() {
async function run() { async function run() {
if (aiscript.value) aiscript.value.abort(); if (aiscript.value) aiscript.value.abort();
if (!flash.value) return;
aiscript.value = new Interpreter({ aiscript.value = new Interpreter({
...createAiScriptEnv({ ...createAiScriptEnv({
@ -193,12 +226,17 @@ async function run() {
} }
} }
onDeactivated(() => { function reset() {
if (aiscript.value) aiscript.value.abort(); if (aiscript.value) aiscript.value.abort();
started.value = false;
}
onDeactivated(() => {
reset();
}); });
onUnmounted(() => { onUnmounted(() => {
if (aiscript.value) aiscript.value.abort(); reset();
}); });
const headerActions = computed(() => []); const headerActions = computed(() => []);
@ -265,11 +303,19 @@ definePageMetadata(() => ({
} }
> .actions { > .actions {
display: flex;
justify-content: center;
gap: 12px;
margin-top: 16px; margin-top: 16px;
padding: 16px;
> .items {
display: flex;
justify-content: center;
gap: 12px;
padding: 16px;
border-bottom: 1px solid var(--divider);
&:last-child {
border-bottom: none;
}
}
} }
} }
} }

View File

@ -151,6 +151,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
import { deepClone } from '@/scripts/clone.js'; import { deepClone } from '@/scripts/clone.js';
import { useInterval } from '@/scripts/use-interval.js'; import { useInterval } from '@/scripts/use-interval.js';
import { signinRequired } from '@/account.js'; import { signinRequired } from '@/account.js';
import { url } from '@/config.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { misskeyApi } from '@/scripts/misskey-api.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { userPage } from '@/filters/user.js'; import { userPage } from '@/filters/user.js';
@ -442,7 +443,7 @@ function autoplay() {
function share() { function share() {
os.post({ os.post({
initialText: `#MisskeyReversi ${location.href}`, initialText: `#MisskeyReversi\n${url}/reversi/g/${game.value.id}`,
instant: true, instant: true,
}); });
} }

View File

@ -28,6 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref } from 'vue';
import * as Misskey from 'misskey-js';
import MarqueeText from '@/components/MkMarquee.vue'; import MarqueeText from '@/components/MkMarquee.vue';
import { useInterval } from '@/scripts/use-interval.js'; import { useInterval } from '@/scripts/use-interval.js';
import { shuffle } from '@/scripts/shuffle.js'; import { shuffle } from '@/scripts/shuffle.js';
@ -42,13 +43,13 @@ const props = defineProps<{
refreshIntervalSec?: number; refreshIntervalSec?: number;
}>(); }>();
const items = ref([]); const items = ref<Misskey.entities.FetchRssResponse['items']>([]);
const fetching = ref(true); const fetching = ref(true);
const key = ref(0); const key = ref(0);
const tick = () => { const tick = () => {
window.fetch(`/api/fetch-rss?url=${props.url}`, {}).then(res => { window.fetch(`/api/fetch-rss?url=${props.url}`, {}).then(res => {
res.json().then(feed => { res.json().then((feed: Misskey.entities.FetchRssResponse) => {
if (props.shuffle) { if (props.shuffle) {
shuffle(feed.items); shuffle(feed.items);
} }

View File

@ -24,6 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { ref, watch, computed } from 'vue'; import { ref, watch, computed } from 'vue';
import * as Misskey from 'misskey-js';
import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js'; import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js';
import { GetFormResultType } from '@/scripts/form.js'; import { GetFormResultType } from '@/scripts/form.js';
import MkContainer from '@/components/MkContainer.vue'; import MkContainer from '@/components/MkContainer.vue';
@ -64,7 +65,7 @@ const { widgetProps, configure } = useWidgetPropsManager(name,
emit, emit,
); );
const rawItems = ref([]); const rawItems = ref<Misskey.entities.FetchRssResponse['items']>([]);
const items = computed(() => rawItems.value.slice(0, widgetProps.maxEntries)); const items = computed(() => rawItems.value.slice(0, widgetProps.maxEntries));
const fetching = ref(true); const fetching = ref(true);
const fetchEndpoint = computed(() => { const fetchEndpoint = computed(() => {
@ -79,8 +80,8 @@ const tick = () => {
window.fetch(fetchEndpoint.value, {}) window.fetch(fetchEndpoint.value, {})
.then(res => res.json()) .then(res => res.json())
.then(feed => { .then((feed: Misskey.entities.FetchRssResponse) => {
rawItems.value = feed.items ?? []; rawItems.value = feed.items;
fetching.value = false; fetching.value = false;
}); });
}; };

View File

@ -28,6 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { ref, watch, computed } from 'vue'; import { ref, watch, computed } from 'vue';
import * as Misskey from 'misskey-js';
import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js'; import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js';
import MarqueeText from '@/components/MkMarquee.vue'; import MarqueeText from '@/components/MkMarquee.vue';
import { GetFormResultType } from '@/scripts/form.js'; import { GetFormResultType } from '@/scripts/form.js';
@ -87,7 +88,7 @@ const { widgetProps, configure } = useWidgetPropsManager(name,
emit, emit,
); );
const rawItems = ref([]); const rawItems = ref<Misskey.entities.FetchRssResponse['items']>([]);
const items = computed(() => { const items = computed(() => {
const newItems = rawItems.value.slice(0, widgetProps.maxEntries); const newItems = rawItems.value.slice(0, widgetProps.maxEntries);
if (widgetProps.shuffle) { if (widgetProps.shuffle) {
@ -110,8 +111,8 @@ const tick = () => {
window.fetch(fetchEndpoint.value, {}) window.fetch(fetchEndpoint.value, {})
.then(res => res.json()) .then(res => res.json())
.then(feed => { .then((feed: Misskey.entities.FetchRssResponse) => {
rawItems.value = feed.items ?? []; rawItems.value = feed.items;
fetching.value = false; fetching.value = false;
key.value++; key.value++;
}); });

View File

@ -51,6 +51,22 @@ const devConfig = {
'/_info_card_': httpUrl, '/_info_card_': httpUrl,
'/bios': httpUrl, '/bios': httpUrl,
'/cli': httpUrl, '/cli': httpUrl,
'/inbox': httpUrl,
'/notes': {
target: httpUrl,
headers: {
'Accept': 'application/activity+json',
},
},
'/users': {
target: httpUrl,
headers: {
'Accept': 'application/activity+json',
},
},
'/.well-known': {
target: httpUrl,
},
}, },
}, },
build: { build: {

View File

@ -26067,7 +26067,52 @@ export type operations = {
200: { 200: {
content: { content: {
'application/json': { 'application/json': {
items: Record<string, never>[]; image?: {
link?: string;
url: string;
title?: string;
};
paginationLinks?: {
self?: string;
first?: string;
next?: string;
last?: string;
prev?: string;
};
link?: string;
title?: string;
items: {
link?: string;
guid?: string;
title?: string;
pubDate?: string;
creator?: string;
summary?: string;
content?: string;
isoDate?: string;
categories?: string[];
contentSnippet?: string;
enclosure?: {
url: string;
length?: number;
type?: string;
};
}[];
feedUrl?: string;
description?: string;
itunes?: {
image?: string;
owner?: {
name?: string;
email?: string;
};
author?: string;
summary?: string;
explicit?: string;
categories?: string[];
keywords?: string[];
[key: string]: unknown;
};
}; };
}; };
}; };

View File

@ -710,8 +710,8 @@ importers:
specifier: 5.1.0 specifier: 5.1.0
version: 5.1.0(rollup@4.12.0) version: 5.1.0(rollup@4.12.0)
'@syuilo/aiscript': '@syuilo/aiscript':
specifier: 0.17.0 specifier: 0.18.0
version: 0.17.0 version: 0.18.0
'@tabler/icons-webfont': '@tabler/icons-webfont':
specifier: 2.44.0 specifier: 2.44.0
version: 2.44.0 version: 2.44.0
@ -6748,7 +6748,7 @@ packages:
ts-dedent: 2.2.0 ts-dedent: 2.2.0
type-fest: 2.19.0 type-fest: 2.19.0
vue: 3.4.21(typescript@5.3.3) vue: 3.4.21(typescript@5.3.3)
vue-component-type-helpers: 2.0.10 vue-component-type-helpers: 2.0.14
transitivePeerDependencies: transitivePeerDependencies:
- encoding - encoding
- supports-color - supports-color
@ -7014,8 +7014,8 @@ packages:
dev: false dev: false
optional: true optional: true
/@syuilo/aiscript@0.17.0: /@syuilo/aiscript@0.18.0:
resolution: {integrity: sha512-3JtQ1rWJHMxQ3153zLCXMUOwrOgjPPYGBl0dPHhR0ohm4tn7okMQRugxMCT0t3YxByemb9FfiM6TUjd0tEGxdA==} resolution: {integrity: sha512-/iY9Vv4LLjtW/KUzId1QwXC4BlpIEPCMcoT7dyRhYdyxtwhS3Hx4b/4j1HYP+n3Pq9XKyW5zvkY72/+DNu4g6Q==}
dependencies: dependencies:
seedrandom: 3.0.5 seedrandom: 3.0.5
stringz: 2.1.0 stringz: 2.1.0
@ -19455,8 +19455,8 @@ packages:
resolution: {integrity: sha512-6bnLkn8O0JJyiFSIF0EfCogzeqNXpnjJ0vW/SZzNHfe6sPx30lTtTXlE5TFs2qhJlAtDFybStVNpL73cPe3OMQ==} resolution: {integrity: sha512-6bnLkn8O0JJyiFSIF0EfCogzeqNXpnjJ0vW/SZzNHfe6sPx30lTtTXlE5TFs2qhJlAtDFybStVNpL73cPe3OMQ==}
dev: true dev: true
/vue-component-type-helpers@2.0.10: /vue-component-type-helpers@2.0.14:
resolution: {integrity: sha512-FC5fKJjDks3Ue/KRSYBdsiCaZa0kUPQfs8yQpb8W9mlO6BenV8G1z58xobeRMzevnmEcDa09LLwuXDwb4f6NMQ==} resolution: {integrity: sha512-DInfgOyXlMyliyqAAD9frK28tTfch0+tMi4qoWJcZlRxUf+NFAtraJBnAsKLep+FOyLMiajkhfyEb3xLK08i7w==}
dev: true dev: true
/vue-demi@0.14.7(vue@3.4.21): /vue-demi@0.14.7(vue@3.4.21):