Compare commits

...

3 Commits

8 changed files with 30 additions and 29 deletions

View File

@ -26,7 +26,7 @@ export default async (actor: CacheableRemoteUser, activity: IUpdate): Promise<st
await updatePerson(actor.uri!, resolver, object);
return `ok: Person updated`;
} else if (getApType(object) === 'Question') {
await updateQuestion(object).catch(e => console.log(e));
await updateQuestion(object, resolver).catch(e => console.log(e));
return `ok: Question updated`;
} else {
return `skip: Unknown type: ${getApType(object)}`;

View File

@ -271,7 +271,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
});
//#endregion
await updateFeatured(user!.id).catch(err => logger.error(err));
await updateFeatured(user!.id, resolver).catch(err => logger.error(err));
return user!;
}
@ -384,7 +384,7 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint
followerSharedInbox: person.sharedInbox || (person.endpoints ? person.endpoints.sharedInbox : undefined),
});
await updateFeatured(exist.id).catch(err => logger.error(err));
await updateFeatured(exist.id, resolver).catch(err => logger.error(err));
}
/**
@ -462,14 +462,14 @@ export function analyzeAttachments(attachments: IObject | IObject[] | undefined)
return { fields, services };
}
export async function updateFeatured(userId: User['id']) {
export async function updateFeatured(userId: User['id'], resolver?: Resolver) {
const user = await Users.findOneByOrFail({ id: userId });
if (!Users.isRemoteUser(user)) return;
if (!user.featured) return;
logger.info(`Updating the featured: ${user.uri}`);
const resolver = new Resolver();
if (resolver == null) resolver = new Resolver();
// Resolve to (Ordered)Collection Object
const collection = await resolver.resolveCollection(user.featured);

View File

@ -40,7 +40,7 @@ export async function extractPollFromQuestion(source: string | IObject, resolver
* @param uri URI of AP Question object
* @returns true if updated
*/
export async function updateQuestion(value: any) {
export async function updateQuestion(value: any, resolver?: Resolver) {
const uri = typeof value === 'string' ? value : value.id;
// URIがこのサーバーを指しているならスキップ
@ -55,7 +55,7 @@ export async function updateQuestion(value: any) {
//#endregion
// resolve new Question object
const resolver = new Resolver();
if (resolver == null) resolver = new Resolver();
const question = await resolver.resolve(value) as IQuestion;
apLogger.debug(`fetched question: ${JSON.stringify(question, null, 2)}`);

View File

@ -60,25 +60,19 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
let to: string[] = [];
let cc: string[] = [];
if (note.channelId) {
to = [{ type: 'Group', name: note.channelId }];
cc = [`${attributedTo}/followers`, 'https://www.w3.org/ns/activitystreams#Public'].concat(mentions);
if (note.visibility === 'public') {
to = ['https://www.w3.org/ns/activitystreams#Public'];
cc = [`${attributedTo}/followers`].concat(mentions);
} else if (note.visibility === 'home') {
to = [`${attributedTo}/followers`];
cc = ['https://www.w3.org/ns/activitystreams#Public'].concat(mentions);
} else if (note.visibility === 'followers') {
to = [`${attributedTo}/followers`];
cc = mentions;
} else {
if (note.visibility === 'public') {
to = ['https://www.w3.org/ns/activitystreams#Public'];
cc = [`${attributedTo}/followers`].concat(mentions);
} else if (note.visibility === 'home') {
to = [`${attributedTo}/followers`];
cc = ['https://www.w3.org/ns/activitystreams#Public'].concat(mentions);
} else if (note.visibility === 'followers') {
to = [`${attributedTo}/followers`];
cc = mentions;
} else {
to = mentions;
}
to = mentions;
}
const mentionedUsers = note.mentions.length > 0 ? await Users.findBy({
id: In(note.mentions),
}) : [];

View File

@ -19,9 +19,11 @@ import renderFollow from '@/remote/activitypub/renderer/follow.js';
export default class Resolver {
private history: Set<string>;
private user?: ILocalUser;
private recursionLimit?: number;
constructor() {
constructor(recursionLimit = 100) {
this.history = new Set();
this.recursionLimit = recursionLimit;
}
public getHistory(): string[] {
@ -59,7 +61,9 @@ export default class Resolver {
if (this.history.has(value)) {
throw new Error('cannot resolve already resolved one');
}
if (this.recursionLimit && this.history.size > this.recursionLimit) {
throw new Error('hit recursion limit');
}
this.history.add(value);
const host = extractDbHost(value);

View File

@ -148,9 +148,10 @@ export default async (user: { id: User['id']; username: User['username']; host:
if (data.localOnly == null) data.localOnly = false;
if (data.channel != null) data.visibility = 'public';
if (data.channel != null) data.visibleUsers = [];
if (data.channel != null) data.localOnly = true;
// サイレンス
if (user.isSilenced && data.visibility === 'public') {
if (user.isSilenced && data.visibility === 'public' && data.channel == null) {
data.visibility = 'home';
}
@ -175,12 +176,12 @@ export default async (user: { id: User['id']; username: User['username']; host:
}
// ローカルのみをRenoteしたらローカルのみにする
if (data.renote && data.renote.localOnly) {
if (data.renote && data.renote.localOnly && data.channel == null) {
data.localOnly = true;
}
// ローカルのみにリプライしたらローカルのみにする
if (data.reply && data.reply.localOnly) {
if (data.reply && data.reply.localOnly && data.channel == null) {
data.localOnly = true;
}

View File

@ -256,6 +256,7 @@ if (props.reply && props.reply.text != null) {
if (props.channel) {
visibility = 'public';
localOnly = true; // TODO:
}
//
@ -760,7 +761,7 @@ onMounted(() => {
margin-left: 0 !important;
}
}
> .local-only {
margin: 0 0 0 12px;
opacity: 0.7;

View File

@ -236,6 +236,7 @@ export default defineComponent({
if (this.channel) {
this.visibility = 'public';
this.localOnly = true; // TODO:
}
//