feat(decorators): TelegrafEntity added

This commit is contained in:
Aleksandr Bukhalo
2020-03-19 16:54:34 +03:00
parent 55c6f939a4
commit 8bd20131a1
5 changed files with 42 additions and 0 deletions

View File

@@ -62,6 +62,11 @@ export class TelegrafExplorer implements OnModuleInit {
this.handleTelegrafHelp(instance, key, telegraf);
} else if (this.metadataAccessor.isTelegrafSettings(instance[key])) {
this.handleTelegrafSettings(instance, key, telegraf);
} else if (this.metadataAccessor.isTelegrafEntity(instance[key])) {
const metadata = this.metadataAccessor.getTelegrafEntityMetadata(
instance[key],
);
this.handleTelegrafEntity(instance, key, telegraf, metadata);
}
},
);
@@ -127,4 +132,14 @@ export class TelegrafExplorer implements OnModuleInit {
// @ts-ignore
telegraf.settings(instance[key].bind(instance));
}
handleTelegrafEntity(
instance: object,
key: string,
telegraf: Telegraf<ContextMessageUpdate>,
metadata: any,
) {
// @ts-ignore
telegraf.entity(metadata.entity, instance[key].bind(instance));
}
}