Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/i-597' into i-597
Browse files Browse the repository at this point in the history
  • Loading branch information
penginn-net committed Jan 6, 2025
2 parents e8d3ea4 + 596cc8a commit 4f2fae1
Show file tree
Hide file tree
Showing 34 changed files with 406 additions and 171 deletions.
37 changes: 37 additions & 0 deletions CHANGELOG_YOJO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
## 1.3.0

### Release Date

### General
- Feat: システムユーザーのファイル一覧を追加 [#595](https://github.com/yojo-art/cherrypick/pull/595)

### Client
- Enhance: ノート詳細から前後のHTL/LTLを開く機能を追加 [#572](https://github.com/yojo-art/cherrypick/pull/572)
- Enhance: インポート時にライセンス欄にインポート元を追記する [#573](https://github.com/yojo-art/cherrypick/pull/573)
- Feat: コンパネのファイルに絵文字として利用中ラベルを表示する [#603](https://github.com/yojo-art/cherrypick/pull/603)

### Server
- Change: `ap/fetch-outbox`から`includeAnnounce`オプションを削除 [#606](https://github.com/yojo-art/cherrypick/pull/606)
- Feat: フォローしているユーザーなら鍵ノートでもアンテナにひっかかるように [#568](https://github.com/yojo-art/cherrypick/pull/568)
- based-on https://github.com/team-shahu/misskey/pull/38


## 1.2.2
Cherrypick 4.13.0
Misskey 2024.10.1

### Release Date
2024-12-27

### General
-

### Client
- Fix: ノート詳細画面でリアクション出来ない [#584](https://github.com/yojo-art/cherrypick/pull/584)
- Fix: タイムラインオプションで表示有無選択の選択肢を修正 [#590](https://github.com/yojo-art/cherrypick/pull/590)
- Fix: MFMチートシートが表示できない不具合を修正 [#592](https://github.com/yojo-art/cherrypick/pull/592)
- Fix: 引用や返信のノートすべてに翻訳ボタンが表示される [#598](https://github.com/yojo-art/cherrypick/pull/598)

### Server
- Fix:`api/ap/fetch-outbox`でリノートしか取得されないのを修正 [#588](https://github.com/yojo-art/cherrypick/pull/588)

## 1.2.1
Cherrypick 4.13.0
Misskey 2024.10.1
Expand Down
8 changes: 8 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,10 @@ export interface Locale extends ILocale {
* カスタム絵文字
*/
"customEmojis": string;
/**
* 詳細情報が利用できません
*/
"emojiRemoteDetailedUnavailable": string;
/**
* 絵文字
*/
Expand Down Expand Up @@ -4211,6 +4215,10 @@ export interface Locale extends ILocale {
* CWを維持する
*/
"keepCw": string;
/**
* %sが検索語句に置き換えられます
*/
"searchEngineDescription": string;
/**
* Pub/Subのアカウント
*/
Expand Down
2 changes: 2 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ selectWidget: "ウィジェットを選択"
editWidgets: "ウィジェットを編集"
editWidgetsExit: "編集を終了"
customEmojis: "カスタム絵文字"
emojiRemoteDetailedUnavailable: "詳細情報が利用できません"
emoji: "絵文字"
emojis: "絵文字"
emojiName: "絵文字名"
Expand Down Expand Up @@ -1044,6 +1045,7 @@ usernameInfo: "サーバー上であなたのアカウントを一意に識別
aiChanMode: "藍モード"
devMode: "開発者モード"
keepCw: "CWを維持する"
searchEngineDescription: "%sが検索語句に置き換えられます"
pubSub: "Pub/Subのアカウント"
lastCommunication: "直近の通信"
resolved: "解決済み"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yojo-art",
"version": "1.2.1",
"version": "1.2.2",
"basedMisskeyVersion": "2024.10.1",
"basedCherrypickVersion": "4.13.0",
"codename": "nasubi",
Expand Down
19 changes: 16 additions & 3 deletions packages/backend/src/core/AntennaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { GlobalEventService } from '@/core/GlobalEventService.js';
import * as Acct from '@/misc/acct.js';
import type { Packed } from '@/misc/json-schema.js';
import { DI } from '@/di-symbols.js';
import type { AntennasRepository, UserGroupJoiningsRepository, UserListMembershipsRepository } from '@/models/_.js';
import type { AntennasRepository, UserGroupJoiningsRepository, UserListMembershipsRepository, FollowingsRepository } from '@/models/_.js';
import { UtilityService } from '@/core/UtilityService.js';
import { bindThis } from '@/decorators.js';
import type { GlobalEvents } from '@/core/GlobalEventService.js';
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
import { CacheService } from '@/core/CacheService.js';
import { deserializeAntenna } from './deserializeAntenna.js';
import type { OnApplicationShutdown } from '@nestjs/common';

Expand All @@ -41,6 +42,10 @@ export class AntennaService implements OnApplicationShutdown {
@Inject(DI.userListMembershipsRepository)
private userListMembershipsRepository: UserListMembershipsRepository,

@Inject(DI.followingsRepository)
private followingsRepository: FollowingsRepository,

private cacheService: CacheService,
private utilityService: UtilityService,
private globalEventService: GlobalEventService,
private fanoutTimelineService: FanoutTimelineService,
Expand Down Expand Up @@ -99,8 +104,16 @@ export class AntennaService implements OnApplicationShutdown {

@bindThis
public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; isBot: boolean; }): Promise<boolean> {
if (note.visibility === 'specified') return false;
if (note.visibility === 'followers') return false;
if (note.visibility === 'specified') {
if (note.userId !== antenna.userId) {
if (note.visibleUserIds == null) return false;
if (!note.visibleUserIds.includes(antenna.userId)) return false;
}
}
if (note.visibility === 'followers') {
const isFollowing = Object.hasOwn(await this.cacheService.userFollowingsCache.fetch(antenna.userId), note.userId);
if (!isFollowing && antenna.userId !== note.userId) return false;
}

if (antenna.excludeBots && noteUser.isBot) return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ export class ApOutboxFetchService implements OnModuleInit {
this.apLoggerService = this.moduleRef.get('ApLoggerService');
this.logger = this.apLoggerService.logger;
}

/**
* outboxから投稿を取得します
*/
@bindThis
public async fetchOutbox(userId: MiUser['id'], includeAnnounce = false, resolver?: Resolver): Promise<void> {
public async fetchOutbox(userId: MiUser['id'], resolver?: Resolver): Promise<void> {
const user = (await this.usersRepository.findOneBy({ id: userId }) as MiRemoteUser | null) ?? null;
if (!user) throw new IdentifiableError('3fc5a089-cab4-48db-b9f3-f220574b3c0a', 'No such user');
if (!user.host) throw new IdentifiableError('67070303-177c-4600-af93-b26a7ab889c6', 'Is local user');
Expand All @@ -85,14 +84,19 @@ export class ApOutboxFetchService implements OnModuleInit {
const cache = await this.redisClient.get(`${outboxUrl}--next`);
let next: string | IOrderedCollectionPage;

if (!cache) {
if (cache) {
next = cache;
} else {
// Resolve to (Ordered)Collection Object
const outbox = await Resolver.resolveOrderedCollection(outboxUrl);
if (!outbox.first) throw new IdentifiableError('a723c2df-0250-4091-b5fc-e3a7b36c7b61', 'outbox first page not exist');
next = outbox.first;
} else next = cache;
}

let created = 0;
let current = {
created: 0,
breaked: false,
};

for (let page = 0; page < pagelimit; page++) {
const collection = (typeof(next) === 'string' ? await Resolver.resolveOrderedCollectionPage(next) : next);
Expand All @@ -101,23 +105,29 @@ export class ApOutboxFetchService implements OnModuleInit {
const activityes = (collection.orderedItems ?? collection.items);
if (!activityes) throw new IdentifiableError('2a05bb06-f38c-4854-af6f-7fd5e87c98ee', 'item is unavailable');

created = await this.fetchObjects(user, activityes, includeAnnounce, created);
if (createLimit <= created) break;//次ページ見て一件だけしか取れないのは微妙
if (!collection.next) break;
do {
current = await this.fetchObjects(user, activityes, current.created);
page++;
}
while (!current.breaked && page < pagelimit);

if (!collection.next) break;
next = collection.next;
await this.redisClient.set(`${outboxUrl}--next`, `${next}`, 'EX', 60 * 15);//15min
}
this.logger.succ(`Outbox Fetced: ${outboxUrl}`);
}

@bindThis
private async fetchObjects(user: MiRemoteUser, activityes: any[], includeAnnounce:boolean, created: number): Promise<number> {
private async fetchObjects(user: MiRemoteUser, activityes: any[], created: number): Promise<{
created: number;
breaked: boolean;
}> {
for (const activity of activityes) {
if (createLimit < created) return created;
if (createLimit < created) return { created: created, breaked: true };
try {
if (activity.actor !== user.uri) throw new IdentifiableError('bde7c204-5441-4a87-9b7e-f81e8d05788a');
if (activity.type === 'Announce' && includeAnnounce) {
if (activity.type === 'Announce') {
const object = await this.apNoteService.fetchNote(activity.id);

if (object) continue;
Expand Down Expand Up @@ -177,7 +187,7 @@ export class ApOutboxFetchService implements OnModuleInit {
}
} else if (isCreate(activity)) {
if (typeof(activity.object) !== 'string') {
if (!isNote(activity)) continue;
if (!isNote(activity.object)) continue;
}
const fetch = await this.apNoteService.fetchNote(activity.object);
if (fetch) continue;
Expand All @@ -190,11 +200,11 @@ export class ApOutboxFetchService implements OnModuleInit {
} else {
this.logger.error(`fetchError:${activity.id}`);
this.logger.error(`${err}`);
continue;
}
continue;
}
created ++;
}
return created;
return { created: created, breaked: false };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const paramDef = {
untilId: { type: 'string', format: 'misskey:id' },
userId: { type: 'string', format: 'misskey:id', nullable: true },
type: { type: 'string', nullable: true, pattern: /^[a-zA-Z0-9\/\-*]+$/.toString().slice(1, -1) },
origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'local' },
origin: { type: 'string', enum: ['combined', 'local', 'remote', 'system'], default: 'local' },
hostname: {
type: 'string',
nullable: true,
Expand Down Expand Up @@ -66,6 +66,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
query.andWhere('file.userHost IS NULL');
} else if (ps.origin === 'remote') {
query.andWhere('file.userHost IS NOT NULL');
} else if (ps.origin === 'system') {
query.andWhere('file.userId IS NULL');
}

if (ps.hostname) {
Expand Down
9 changes: 2 additions & 7 deletions packages/backend/src/server/api/endpoints/ap/fetch-outbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ export const paramDef = {
default: false,
description: 'Outboxの取得が終わるまで待ちます',
},
includeAnnounce: {
type: 'boolean',
default: false,
description: 'Outbox取得の際にRenoteも対象にします',
},
//skip: { type: 'integer', minimum: 1, default: 0 },
},
required: ['userId'],
Expand All @@ -87,7 +82,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
super(meta, paramDef, async (ps, me) => {
if (ps.wait) {
try {
await this.apOutboxFetchService.fetchOutbox(ps.userId, ps.includeAnnounce);
await this.apOutboxFetchService.fetchOutbox(ps.userId);
} catch (err) {
if (err instanceof IdentifiableError) {
if (err.id === '3fc5a089-cab4-48db-b9f3-f220574b3c0a') throw new ApiError(meta.errors.noSuchUser);
Expand All @@ -100,7 +95,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw (err);
}
} else {
this.apOutboxFetchService.fetchOutbox(ps.userId, ps.includeAnnounce);
this.apOutboxFetchService.fetchOutbox(ps.userId);
}
});
}
Expand Down
19 changes: 16 additions & 3 deletions packages/backend/test/e2e/antennas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,26 @@ describe('アンテナ', () => {
},
{
// https://github.com/misskey-dev/misskey/issues/9025
label: 'ただし、フォロワー限定投稿とDM投稿を含まない。フォロワーであっても。',
// https://github.com/yojo-art/cherrypick/pull/568
label: 'フォロワー限定投稿とDM投稿を含む',
parameters: () => ({}),
posts: [
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'public' }), included: true },
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'home' }), included: true },
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'followers' }) },
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'specified', visibleUserIds: [alice.id] }) },
{ note: (): Promise<Note> => post(userFollowedByAlice, { text: `${keyword}`, visibility: 'followers' }), included: true },
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, visibility: 'specified', visibleUserIds: [alice.id] }), included: true },
],
},
{
// https://github.com/misskey-dev/misskey/issues/9025
// https://github.com/yojo-art/cherrypick/pull/568
label: 'フォロワー限定投稿とDM投稿を含まない',
parameters: () => ({}),
posts: [
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, visibility: 'public' }), included: true },
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, visibility: 'home' }), included: true },
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, visibility: 'followers' }) },
{ note: (): Promise<Note> => post(bob, { text: `${keyword}`, visibility: 'specified', visibleUserIds: [carol.id] }) },
],
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/cherrypick-js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "cherrypick-js",
"version": "1.2.1",
"version": "1.2.2",
"basedMisskeyVersion": "2024.10.1",
"basedCherrypickVersion": "4.13.0",
"description": "yojo-art SDK for JavaScript",
Expand Down
7 changes: 1 addition & 6 deletions packages/cherrypick-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7550,7 +7550,7 @@ export type operations = {
* @default local
* @enum {string}
*/
origin?: 'combined' | 'local' | 'remote';
origin?: 'combined' | 'local' | 'remote' | 'system';
/**
* @description The local host is represented with `null`.
* @default null
Expand Down Expand Up @@ -12235,11 +12235,6 @@ export type operations = {
* @default false
*/
wait?: boolean;
/**
* @description Outbox取得の際にRenoteも対象にします
* @default false
*/
includeAnnounce?: boolean;
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend-embed/src/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { serverMetadata } from '@/server-metadata.js';
import { postMessageToParentWindow, setIframeId } from '@/post-message.js';
import { serverContext } from '@/server-context.js';

console.log('CherryPick Embed');
console.log('yojo-art Embed');

//#region Embedパラメータの取得・パース
const params = new URLSearchParams(location.search);
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/boot/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { createMainRouter } from '@/router/definition.js';
import { popup } from '@/os.js';

export async function common(createVue: () => App<Element>) {
console.info(`CherryPick v${version}`);
console.info(`yojo-art v${version}`);

if (_DEV_) {
console.warn('Development mode!!!');
Expand Down
Loading

0 comments on commit 4f2fae1

Please sign in to comment.