fix DMs converting to public notes when the audience can't be resolved
This commit is contained in:
parent
c2e52f6ae7
commit
24bc1c653d
2 changed files with 17 additions and 10 deletions
|
|
@ -42,6 +42,19 @@ export class ApAudienceService {
|
|||
others.map(id => limit(() => this.apPersonService.resolvePerson(id, resolver).catch(() => null))),
|
||||
)).filter(x => x != null);
|
||||
|
||||
// If no audience is specified, then assume public
|
||||
if (
|
||||
toGroups.public.length === 0 && toGroups.followers.length === 0 &&
|
||||
ccGroups.public.length === 0 && ccGroups.followers.length === 0 &&
|
||||
others.length === 0
|
||||
) {
|
||||
return {
|
||||
visibility: 'public',
|
||||
mentionedUsers: [],
|
||||
visibleUsers: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (toGroups.public.length > 0) {
|
||||
return {
|
||||
visibility: 'public',
|
||||
|
|
|
|||
|
|
@ -239,15 +239,12 @@ export class ApNoteService {
|
|||
}
|
||||
|
||||
const noteAudience = await this.apAudienceService.parseAudience(actor, note.to, note.cc, resolver);
|
||||
let visibility = noteAudience.visibility;
|
||||
const visibility = noteAudience.visibility;
|
||||
const visibleUsers = noteAudience.visibleUsers;
|
||||
|
||||
// Audience (to, cc) が指定されてなかった場合
|
||||
if (visibility === 'specified' && visibleUsers.length === 0) {
|
||||
if (typeof value === 'string') { // 入力がstringならばresolverでGETが発生している
|
||||
// こちらから匿名GET出来たものならばpublic
|
||||
visibility = 'public';
|
||||
}
|
||||
throw new IdentifiableError('dc2ad0d1-36bf-41f5-8e4c-a4d265a28387', `failed to create note ${entryUri}: could not resolve any recipients`);
|
||||
}
|
||||
|
||||
const processErrors: string[] = [];
|
||||
|
|
@ -430,15 +427,12 @@ export class ApNoteService {
|
|||
//#endregion
|
||||
|
||||
const noteAudience = await this.apAudienceService.parseAudience(actor, note.to, note.cc, resolver);
|
||||
let visibility = noteAudience.visibility;
|
||||
const visibility = noteAudience.visibility;
|
||||
const visibleUsers = noteAudience.visibleUsers;
|
||||
|
||||
// Audience (to, cc) が指定されてなかった場合
|
||||
if (visibility === 'specified' && visibleUsers.length === 0) {
|
||||
if (typeof value === 'string') { // 入力がstringならばresolverでGETが発生している
|
||||
// こちらから匿名GET出来たものならばpublic
|
||||
visibility = 'public';
|
||||
}
|
||||
throw new IdentifiableError('dc2ad0d1-36bf-41f5-8e4c-a4d265a28387', `failed to create note ${entryUri}: could not resolve any recipients`);
|
||||
}
|
||||
|
||||
const processErrors: string[] = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue