Compare commits
No commits in common. "3fe535cd39f5171015f9339375f57fa4982b104c" and "f084c8512ac2cc0baff10dca34412243f6f492c1" have entirely different histories.
3fe535cd39
...
f084c8512a
|
@ -26,7 +26,7 @@ export default async (actor: CacheableRemoteUser, activity: IUpdate): Promise<st
|
||||||
await updatePerson(actor.uri!, resolver, object);
|
await updatePerson(actor.uri!, resolver, object);
|
||||||
return `ok: Person updated`;
|
return `ok: Person updated`;
|
||||||
} else if (getApType(object) === 'Question') {
|
} else if (getApType(object) === 'Question') {
|
||||||
await updateQuestion(object, resolver).catch(e => console.log(e));
|
await updateQuestion(object).catch(e => console.log(e));
|
||||||
return `ok: Question updated`;
|
return `ok: Question updated`;
|
||||||
} else {
|
} else {
|
||||||
return `skip: Unknown type: ${getApType(object)}`;
|
return `skip: Unknown type: ${getApType(object)}`;
|
||||||
|
|
|
@ -271,7 +271,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
await updateFeatured(user!.id, resolver).catch(err => logger.error(err));
|
await updateFeatured(user!.id).catch(err => logger.error(err));
|
||||||
|
|
||||||
return user!;
|
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),
|
followerSharedInbox: person.sharedInbox || (person.endpoints ? person.endpoints.sharedInbox : undefined),
|
||||||
});
|
});
|
||||||
|
|
||||||
await updateFeatured(exist.id, resolver).catch(err => logger.error(err));
|
await updateFeatured(exist.id).catch(err => logger.error(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -462,14 +462,14 @@ export function analyzeAttachments(attachments: IObject | IObject[] | undefined)
|
||||||
return { fields, services };
|
return { fields, services };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateFeatured(userId: User['id'], resolver?: Resolver) {
|
export async function updateFeatured(userId: User['id']) {
|
||||||
const user = await Users.findOneByOrFail({ id: userId });
|
const user = await Users.findOneByOrFail({ id: userId });
|
||||||
if (!Users.isRemoteUser(user)) return;
|
if (!Users.isRemoteUser(user)) return;
|
||||||
if (!user.featured) return;
|
if (!user.featured) return;
|
||||||
|
|
||||||
logger.info(`Updating the featured: ${user.uri}`);
|
logger.info(`Updating the featured: ${user.uri}`);
|
||||||
|
|
||||||
if (resolver == null) resolver = new Resolver();
|
const resolver = new Resolver();
|
||||||
|
|
||||||
// Resolve to (Ordered)Collection Object
|
// Resolve to (Ordered)Collection Object
|
||||||
const collection = await resolver.resolveCollection(user.featured);
|
const collection = await resolver.resolveCollection(user.featured);
|
||||||
|
|
|
@ -40,7 +40,7 @@ export async function extractPollFromQuestion(source: string | IObject, resolver
|
||||||
* @param uri URI of AP Question object
|
* @param uri URI of AP Question object
|
||||||
* @returns true if updated
|
* @returns true if updated
|
||||||
*/
|
*/
|
||||||
export async function updateQuestion(value: any, resolver?: Resolver) {
|
export async function updateQuestion(value: any) {
|
||||||
const uri = typeof value === 'string' ? value : value.id;
|
const uri = typeof value === 'string' ? value : value.id;
|
||||||
|
|
||||||
// URIがこのサーバーを指しているならスキップ
|
// URIがこのサーバーを指しているならスキップ
|
||||||
|
@ -55,7 +55,7 @@ export async function updateQuestion(value: any, resolver?: Resolver) {
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
// resolve new Question object
|
// resolve new Question object
|
||||||
if (resolver == null) resolver = new Resolver();
|
const resolver = new Resolver();
|
||||||
const question = await resolver.resolve(value) as IQuestion;
|
const question = await resolver.resolve(value) as IQuestion;
|
||||||
apLogger.debug(`fetched question: ${JSON.stringify(question, null, 2)}`);
|
apLogger.debug(`fetched question: ${JSON.stringify(question, null, 2)}`);
|
||||||
|
|
||||||
|
|
|
@ -60,19 +60,25 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
|
||||||
let to: string[] = [];
|
let to: string[] = [];
|
||||||
let cc: string[] = [];
|
let cc: string[] = [];
|
||||||
|
|
||||||
if (note.visibility === 'public') {
|
if (note.channelId) {
|
||||||
to = ['https://www.w3.org/ns/activitystreams#Public'];
|
to = [{ type: 'Group', name: note.channelId }];
|
||||||
cc = [`${attributedTo}/followers`].concat(mentions);
|
cc = [`${attributedTo}/followers`, 'https://www.w3.org/ns/activitystreams#Public'].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 {
|
} else {
|
||||||
to = 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 {
|
||||||
|
to = mentions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const mentionedUsers = note.mentions.length > 0 ? await Users.findBy({
|
const mentionedUsers = note.mentions.length > 0 ? await Users.findBy({
|
||||||
id: In(note.mentions),
|
id: In(note.mentions),
|
||||||
}) : [];
|
}) : [];
|
||||||
|
|
|
@ -19,11 +19,9 @@ import renderFollow from '@/remote/activitypub/renderer/follow.js';
|
||||||
export default class Resolver {
|
export default class Resolver {
|
||||||
private history: Set<string>;
|
private history: Set<string>;
|
||||||
private user?: ILocalUser;
|
private user?: ILocalUser;
|
||||||
private recursionLimit?: number;
|
|
||||||
|
|
||||||
constructor(recursionLimit = 100) {
|
constructor() {
|
||||||
this.history = new Set();
|
this.history = new Set();
|
||||||
this.recursionLimit = recursionLimit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHistory(): string[] {
|
public getHistory(): string[] {
|
||||||
|
@ -61,9 +59,7 @@ export default class Resolver {
|
||||||
if (this.history.has(value)) {
|
if (this.history.has(value)) {
|
||||||
throw new Error('cannot resolve already resolved one');
|
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);
|
this.history.add(value);
|
||||||
|
|
||||||
const host = extractDbHost(value);
|
const host = extractDbHost(value);
|
||||||
|
|
|
@ -148,10 +148,9 @@ export default async (user: { id: User['id']; username: User['username']; host:
|
||||||
if (data.localOnly == null) data.localOnly = false;
|
if (data.localOnly == null) data.localOnly = false;
|
||||||
if (data.channel != null) data.visibility = 'public';
|
if (data.channel != null) data.visibility = 'public';
|
||||||
if (data.channel != null) data.visibleUsers = [];
|
if (data.channel != null) data.visibleUsers = [];
|
||||||
if (data.channel != null) data.localOnly = true;
|
|
||||||
|
|
||||||
// サイレンス
|
// サイレンス
|
||||||
if (user.isSilenced && data.visibility === 'public' && data.channel == null) {
|
if (user.isSilenced && data.visibility === 'public') {
|
||||||
data.visibility = 'home';
|
data.visibility = 'home';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,12 +175,12 @@ export default async (user: { id: User['id']; username: User['username']; host:
|
||||||
}
|
}
|
||||||
|
|
||||||
// ローカルのみをRenoteしたらローカルのみにする
|
// ローカルのみをRenoteしたらローカルのみにする
|
||||||
if (data.renote && data.renote.localOnly && data.channel == null) {
|
if (data.renote && data.renote.localOnly) {
|
||||||
data.localOnly = true;
|
data.localOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ローカルのみにリプライしたらローカルのみにする
|
// ローカルのみにリプライしたらローカルのみにする
|
||||||
if (data.reply && data.reply.localOnly && data.channel == null) {
|
if (data.reply && data.reply.localOnly) {
|
||||||
data.localOnly = true;
|
data.localOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,6 @@ if (props.reply && props.reply.text != null) {
|
||||||
|
|
||||||
if (props.channel) {
|
if (props.channel) {
|
||||||
visibility = 'public';
|
visibility = 'public';
|
||||||
localOnly = true; // TODO: チャンネルが連合するようになった折には消す
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公開以外へのリプライ時は元の公開範囲を引き継ぐ
|
// 公開以外へのリプライ時は元の公開範囲を引き継ぐ
|
||||||
|
|
|
@ -236,7 +236,6 @@ export default defineComponent({
|
||||||
|
|
||||||
if (this.channel) {
|
if (this.channel) {
|
||||||
this.visibility = 'public';
|
this.visibility = 'public';
|
||||||
this.localOnly = true; // TODO: チャンネルが連合するようになった折には消す
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公開以外へのリプライ時は元の公開範囲を引き継ぐ
|
// 公開以外へのリプライ時は元の公開範囲を引き継ぐ
|
||||||
|
|
Loading…
Reference in New Issue