Skip to content

Commit

Permalink
apnote
Browse files Browse the repository at this point in the history
  • Loading branch information
Esurio committed Sep 10, 2024
1 parent ca776c6 commit db0a9b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
25 changes: 0 additions & 25 deletions packages/backend/src/core/activitypub/ApInboxService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,30 +354,6 @@ export class ApInboxService {
throw err;
}

let searchableActivity = activity.searchableBy;
let searchable: string[] = [];
if (typeof searchableActivity === 'string') {
if (searchableActivity.includes('https://www.w3.org/ns/activitystreams#Public')) {
searchable = ['public'];
} else if (searchableActivity.includes('kmyblue:Limited') || searchableActivity.includes('as:Limited')) {
searchable = ['limited'];
} else if (searchableActivity.includes('followers')) {
searchable = ['followers'];
} else {
searchable = ['reacted'];
}
} else if (Array.isArray(searchableActivity)) {
if (searchableActivity.some(url => url.includes('https://www.w3.org/ns/activitystreams#Public'))) {
searchable = ['public'];
} else if (searchableActivity.some(url => url.includes('kmyblue:Limited')) || searchableActivity.some(url => url.includes('as:Limited'))) {
searchable = ['limited'];
} else if (searchableActivity.some(url => url.includes('followers'))) {
searchable = ['followers'];
} else {
searchable = ['reacted'];
}
}

if (!await this.noteEntityService.isVisibleForMe(renote, actor.id)) {
return 'skip: invalid actor for this activity';
}
Expand All @@ -403,7 +379,6 @@ export class ApInboxService {
visibility: activityAudience.visibility,
visibleUsers: activityAudience.visibleUsers,
uri,
searchableBy: searchable,
});
} finally {
unlock();
Expand Down
13 changes: 12 additions & 1 deletion packages/backend/src/core/activitypub/models/ApNoteService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { ApEventService } from './ApEventService.js';
import { ApImageService } from './ApImageService.js';
import type { Resolver } from '../ApResolverService.js';
import type { IObject, IPost } from '../type.js';
import search from '@/server/api/endpoints/hashtags/search.js';

@Injectable()
export class ApNoteService {
Expand Down Expand Up @@ -221,6 +222,16 @@ export class ApNoteService {

let isMessaging = note._misskey_talk && visibility === 'specified';

let searchableActivity = toArray(note.searchableBy);
let searchable: string[] = [];
if (searchableActivity.includes('https://www.w3.org/ns/activitystreams#Public')) {
searchable = ['public'];
} else if (searchableActivity.includes('kmyblue:Limited') || searchableActivity.includes('as:Limited')) {
searchable = ['limited'];
} else {
searchable = [];
}

// 添付ファイル
const files: MiDriveFile[] = [];

Expand Down Expand Up @@ -348,7 +359,7 @@ export class ApNoteService {
event,
uri: note.id,
url: url,
searchableBy: note.searchableBy,
searchableBy: note.searchableBy ? searchable : ['public'],
}, silent);
} catch (err: any) {
if (err.name !== 'duplicated') {
Expand Down

0 comments on commit db0a9b7

Please sign in to comment.