refactor: introduce bindThis decorator to bind this automaticaly
This commit is contained in:
@@ -23,6 +23,7 @@ import { ClipEntityService } from '@/core/entities/ClipEntityService.js';
|
||||
import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js';
|
||||
import type { ChannelsRepository, ClipsRepository, GalleryPostsRepository, NotesRepository, PagesRepository, UserProfilesRepository, UsersRepository } from '@/models/index.js';
|
||||
import { deepClone } from '@/misc/clone.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import manifest from './manifest.json' assert { type: 'json' };
|
||||
import { FeedService } from './FeedService.js';
|
||||
import { UrlPreviewService } from './UrlPreviewService.js';
|
||||
@@ -80,9 +81,10 @@ export class ClientServerService {
|
||||
@Inject('queue:objectStorage') public objectStorageQueue: ObjectStorageQueue,
|
||||
@Inject('queue:webhookDeliver') public webhookDeliverQueue: WebhookDeliverQueue,
|
||||
) {
|
||||
this.createServer = this.createServer.bind(this);
|
||||
//this.createServer = this.createServer.bind(this);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
private async manifestHandler(reply: FastifyReply) {
|
||||
const res = deepClone(manifest);
|
||||
|
||||
@@ -96,6 +98,7 @@ export class ClientServerService {
|
||||
return (res);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public createServer(fastify: FastifyInstance, options: FastifyPluginOptions, done: (err?: Error) => void) {
|
||||
/* TODO
|
||||
//#region Bull Dashboard
|
||||
|
@@ -7,6 +7,7 @@ import type { Config } from '@/config.js';
|
||||
import type { User } from '@/models/entities/User.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
||||
@Injectable()
|
||||
export class FeedService {
|
||||
@@ -31,6 +32,7 @@ export class FeedService {
|
||||
) {
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async packFeed(user: User) {
|
||||
const author = {
|
||||
link: `${this.config.url}/@${user.username}`,
|
||||
|
@@ -9,6 +9,7 @@ import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import { query } from '@/misc/prelude/url.js';
|
||||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
||||
@Injectable()
|
||||
export class UrlPreviewService {
|
||||
@@ -28,6 +29,7 @@ export class UrlPreviewService {
|
||||
this.logger = this.loggerService.getLogger('url-preview');
|
||||
}
|
||||
|
||||
@bindThis
|
||||
private wrap(url?: string): string | null {
|
||||
return url != null
|
||||
? url.match(/^https?:\/\//)
|
||||
@@ -39,6 +41,7 @@ export class UrlPreviewService {
|
||||
: null;
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async handle(
|
||||
request: FastifyRequest<{ Querystring: { url: string; lang: string; } }>,
|
||||
reply: FastifyReply,
|
||||
|
Reference in New Issue
Block a user