Skip to content

Commit

Permalink
Merge branch 'develop' into fix-subnote-translate
Browse files Browse the repository at this point in the history
  • Loading branch information
penginn-net authored Dec 26, 2024
2 parents 3042ebd + 0acc86a commit c3e4c96
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 58 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_YOJO.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ xxxx-xx-xx
### Client
- Fix: ノート詳細画面でリアクション出来ない [#584](https://github.com/yojo-art/cherrypick/pull/584)
- 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)

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

/**
* outboxから投稿を取得します
*/
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,20 +105,26 @@ 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, includeAnnounce, 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[], includeAnnounce:boolean, 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) {
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 };
}
}
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkNoteDetailed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<button v-if="appearNote.reactionAcceptance !== 'likeOnly' && appearNote.myReaction == null && defaultStore.state.showLikeButtonInNoteFooter" ref="heartReactButton" v-vibrate="defaultStore.state.vibrateSystem ? [30, 50, 50] : []" v-tooltip="i18n.ts.like" :class="$style.noteFooterButton" class="_button" @click="heartReact()">
<i class="ti ti-heart"></i>
</button>
<button v-if="defaultStore.state.showDoReactionButtonInNoteFooter" ref="reactButton" v-vibrate="defaultStore.state.vibrateSystem ? [30, 50, 50] : []" v-tooltip="appearNote.reactionAcceptance === 'likeOnly' && appearNote.myReaction != null ? i18n.ts.unlike : appearNote.myReaction != null ? i18n.ts.editReaction : appearNote.reactionAcceptance === 'likeOnly' ? i18n.ts.like : i18n.ts.doReaction" :class="$style.noteFooterButton" class="_button" @click.stop="toggleReact()">
<button v-if="defaultStore.state.showDoReactionButtonInNoteFooter" ref="reactButton" v-vibrate="defaultStore.state.vibrateSystem ? [30, 50, 50] : []" v-tooltip="appearNote.reactionAcceptance === 'likeOnly' && appearNote.myReaction != null ? i18n.ts.unlike : appearNote.myReaction != null ? i18n.ts.editReaction : appearNote.reactionAcceptance === 'likeOnly' ? i18n.ts.like : i18n.ts.doReaction" :class="$style.noteFooterButton" class="_button" @click.stop="react()">
<i v-if="appearNote.reactionAcceptance === 'likeOnly' && appearNote.myReaction != null" class="ti ti-heart-filled" style="color: var(--MI_THEME-love);"></i>
<i v-else-if="appearNote.myReaction != null" class="ti ti-mood-edit" style="color: var(--MI_THEME-accent);"></i>
<i v-else-if="appearNote.reactionAcceptance === 'likeOnly'" class="ti ti-heart"></i>
Expand Down
Loading

0 comments on commit c3e4c96

Please sign in to comment.