fix(backend): mostr.pub, Mitraのユーザーをフォローできない問題を修正 (#11791)
* fix(backend): mostr.pub, Mitraのユーザーをフォローできない問題を修正
* Revert "fix(backend): mostr.pub, Mitraのユーザーをフォローできない問題を修正"
This reverts commit 9685715e64
.
* fix ApResolverService
* Update CHANGELOG.md
* fix test
---------
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
parent
7dc9fe4e24
commit
3bbc2e55b1
|
@ -91,6 +91,7 @@
|
||||||
- Fix: muteがapiからのuser list timeline取得で機能しない問題を修正
|
- Fix: muteがapiからのuser list timeline取得で機能しない問題を修正
|
||||||
- Fix: ジョブキュー管理画面の認証を回避できる問題を修正
|
- Fix: ジョブキュー管理画面の認証を回避できる問題を修正
|
||||||
- Fix: 一部のサーバー内部エラーがスタックトレースを返さないように修正
|
- Fix: 一部のサーバー内部エラーがスタックトレースを返さないように修正
|
||||||
|
- Fix: 一部のリモートユーザーをフォローすることができない問題を修正
|
||||||
|
|
||||||
## 13.14.2
|
## 13.14.2
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { IsNull, Not } from 'typeorm';
|
||||||
import type { MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
import type { MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
||||||
import { InstanceActorService } from '@/core/InstanceActorService.js';
|
import { InstanceActorService } from '@/core/InstanceActorService.js';
|
||||||
import type { NotesRepository, PollsRepository, NoteReactionsRepository, UsersRepository } from '@/models/_.js';
|
import type { NotesRepository, PollsRepository, NoteReactionsRepository, UsersRepository, FollowRequestsRepository } from '@/models/_.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||||
|
@ -32,6 +33,7 @@ export class Resolver {
|
||||||
private notesRepository: NotesRepository,
|
private notesRepository: NotesRepository,
|
||||||
private pollsRepository: PollsRepository,
|
private pollsRepository: PollsRepository,
|
||||||
private noteReactionsRepository: NoteReactionsRepository,
|
private noteReactionsRepository: NoteReactionsRepository,
|
||||||
|
private followRequestsRepository: FollowRequestsRepository,
|
||||||
private utilityService: UtilityService,
|
private utilityService: UtilityService,
|
||||||
private instanceActorService: InstanceActorService,
|
private instanceActorService: InstanceActorService,
|
||||||
private metaService: MetaService,
|
private metaService: MetaService,
|
||||||
|
@ -146,13 +148,24 @@ export class Resolver {
|
||||||
return this.noteReactionsRepository.findOneByOrFail({ id: parsed.id }).then(async reaction =>
|
return this.noteReactionsRepository.findOneByOrFail({ id: parsed.id }).then(async reaction =>
|
||||||
this.apRendererService.addContext(await this.apRendererService.renderLike(reaction, { uri: null })));
|
this.apRendererService.addContext(await this.apRendererService.renderLike(reaction, { uri: null })));
|
||||||
case 'follows':
|
case 'follows':
|
||||||
// rest should be <followee id>
|
return this.followRequestsRepository.findOneBy({ id: parsed.id })
|
||||||
if (parsed.rest == null || !/^\w+$/.test(parsed.rest)) throw new Error('resolveLocal: invalid follow URI');
|
.then(async followRequest => {
|
||||||
|
if (followRequest == null) throw new Error('resolveLocal: invalid follow request ID');
|
||||||
return Promise.all(
|
const [follower, followee] = await Promise.all([
|
||||||
[parsed.id, parsed.rest].map(id => this.usersRepository.findOneByOrFail({ id })),
|
this.usersRepository.findOneBy({
|
||||||
)
|
id: followRequest.followerId,
|
||||||
.then(([follower, followee]) => this.apRendererService.addContext(this.apRendererService.renderFollow(follower as MiLocalUser | MiRemoteUser, followee as MiLocalUser | MiRemoteUser, url)));
|
host: IsNull(),
|
||||||
|
}),
|
||||||
|
this.usersRepository.findOneBy({
|
||||||
|
id: followRequest.followeeId,
|
||||||
|
host: Not(IsNull()),
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
if (follower == null || followee == null) {
|
||||||
|
throw new Error('resolveLocal: follower or followee does not exist');
|
||||||
|
}
|
||||||
|
return this.apRendererService.addContext(this.apRendererService.renderFollow(follower as MiLocalUser | MiRemoteUser, followee as MiLocalUser | MiRemoteUser, url));
|
||||||
|
});
|
||||||
default:
|
default:
|
||||||
throw new Error(`resolveLocal: type ${parsed.type} unhandled`);
|
throw new Error(`resolveLocal: type ${parsed.type} unhandled`);
|
||||||
}
|
}
|
||||||
|
@ -177,6 +190,9 @@ export class ApResolverService {
|
||||||
@Inject(DI.noteReactionsRepository)
|
@Inject(DI.noteReactionsRepository)
|
||||||
private noteReactionsRepository: NoteReactionsRepository,
|
private noteReactionsRepository: NoteReactionsRepository,
|
||||||
|
|
||||||
|
@Inject(DI.followRequestsRepository)
|
||||||
|
private followRequestsRepository: FollowRequestsRepository,
|
||||||
|
|
||||||
private utilityService: UtilityService,
|
private utilityService: UtilityService,
|
||||||
private instanceActorService: InstanceActorService,
|
private instanceActorService: InstanceActorService,
|
||||||
private metaService: MetaService,
|
private metaService: MetaService,
|
||||||
|
@ -196,6 +212,7 @@ export class ApResolverService {
|
||||||
this.notesRepository,
|
this.notesRepository,
|
||||||
this.pollsRepository,
|
this.pollsRepository,
|
||||||
this.noteReactionsRepository,
|
this.noteReactionsRepository,
|
||||||
|
this.followRequestsRepository,
|
||||||
this.utilityService,
|
this.utilityService,
|
||||||
this.instanceActorService,
|
this.instanceActorService,
|
||||||
this.metaService,
|
this.metaService,
|
||||||
|
|
|
@ -15,7 +15,7 @@ import type { LoggerService } from '@/core/LoggerService.js';
|
||||||
import type { MetaService } from '@/core/MetaService.js';
|
import type { MetaService } from '@/core/MetaService.js';
|
||||||
import type { UtilityService } from '@/core/UtilityService.js';
|
import type { UtilityService } from '@/core/UtilityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type { NoteReactionsRepository, NotesRepository, PollsRepository, UsersRepository } from '@/models/_.js';
|
import type { NoteReactionsRepository, NotesRepository, PollsRepository, UsersRepository, FollowRequestsRepository } from '@/models/_.js';
|
||||||
|
|
||||||
type MockResponse = {
|
type MockResponse = {
|
||||||
type: string;
|
type: string;
|
||||||
|
@ -33,6 +33,7 @@ export class MockResolver extends Resolver {
|
||||||
{} as NotesRepository,
|
{} as NotesRepository,
|
||||||
{} as PollsRepository,
|
{} as PollsRepository,
|
||||||
{} as NoteReactionsRepository,
|
{} as NoteReactionsRepository,
|
||||||
|
{} as FollowRequestsRepository,
|
||||||
{} as UtilityService,
|
{} as UtilityService,
|
||||||
{} as InstanceActorService,
|
{} as InstanceActorService,
|
||||||
{} as MetaService,
|
{} as MetaService,
|
||||||
|
|
Loading…
Reference in New Issue