diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2022-12-04 15:03:09 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2022-12-04 15:03:09 +0900 |
| commit | bbb49457f9fb5d46402e913c92ebf77722cad6ff (patch) | |
| tree | 8ef285bcbab2c3a4a89d0a624a802d76a2864fed /packages/backend/src/core/RelayService.ts | |
| parent | :art: (diff) | |
| download | sharkey-bbb49457f9fb5d46402e913c92ebf77722cad6ff.tar.gz sharkey-bbb49457f9fb5d46402e913c92ebf77722cad6ff.tar.bz2 sharkey-bbb49457f9fb5d46402e913c92ebf77722cad6ff.zip | |
refactor: introduce bindThis decorator to bind this automaticaly
Diffstat (limited to 'packages/backend/src/core/RelayService.ts')
| -rw-r--r-- | packages/backend/src/core/RelayService.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/backend/src/core/RelayService.ts b/packages/backend/src/core/RelayService.ts index 7951edddcb..5fb853f25a 100644 --- a/packages/backend/src/core/RelayService.ts +++ b/packages/backend/src/core/RelayService.ts @@ -12,6 +12,7 @@ import { DI } from '@/di-symbols.js'; import { deepClone } from '@/misc/clone.js'; const ACTOR_USERNAME = 'relay.actor' as const; +import { bindThis } from '@/decorators.js'; @Injectable() export class RelayService { @@ -32,6 +33,7 @@ export class RelayService { this.relaysCache = new Cache<Relay[]>(1000 * 60 * 10); } + @bindThis private async getRelayActor(): Promise<ILocalUser> { const user = await this.usersRepository.findOneBy({ host: IsNull(), @@ -44,6 +46,7 @@ export class RelayService { return created as ILocalUser; } + @bindThis public async addRelay(inbox: string): Promise<Relay> { const relay = await this.relaysRepository.insert({ id: this.idService.genId(), @@ -59,6 +62,7 @@ export class RelayService { return relay; } + @bindThis public async removeRelay(inbox: string): Promise<void> { const relay = await this.relaysRepository.findOneBy({ inbox, @@ -77,11 +81,13 @@ export class RelayService { await this.relaysRepository.delete(relay.id); } + @bindThis public async listRelay(): Promise<Relay[]> { const relays = await this.relaysRepository.find(); return relays; } + @bindThis public async relayAccepted(id: string): Promise<string> { const result = await this.relaysRepository.update(id, { status: 'accepted', @@ -90,6 +96,7 @@ export class RelayService { return JSON.stringify(result); } + @bindThis public async relayRejected(id: string): Promise<string> { const result = await this.relaysRepository.update(id, { status: 'rejected', @@ -98,6 +105,7 @@ export class RelayService { return JSON.stringify(result); } + @bindThis public async deliverToRelays(user: { id: User['id']; host: null; }, activity: any): Promise<void> { if (activity == null) return; |