refactor: introduce bindThis decorator to bind this automaticaly

This commit is contained in:
syuilo
2022-12-04 15:03:09 +09:00
parent e73581f715
commit bbb49457f9
199 changed files with 969 additions and 96 deletions

View File

@@ -11,6 +11,7 @@ import { CreateNotificationService } from '@/core/CreateNotificationService.js';
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js';
import { bindThis } from '@/decorators.js';
@Injectable()
export class PollService {
@@ -40,6 +41,7 @@ export class PollService {
) {
}
@bindThis
public async vote(user: CacheableUser, note: Note, choice: number) {
const poll = await this.pollsRepository.findOneBy({ noteId: note.id });
@@ -99,6 +101,7 @@ export class PollService {
});
}
@bindThis
public async deliverQuestionUpdate(noteId: Note['id']) {
const note = await this.notesRepository.findOneBy({ id: noteId });
if (note == null) throw new Error('note not found');