mirror of
https://github.com/hexastack/hexabot
synced 2024-11-24 04:53:41 +00:00
fix: event consistent naming
This commit is contained in:
parent
5362380926
commit
b94c0eb9a5
@ -43,7 +43,7 @@ export class LabelRepository extends BaseRepository<
|
||||
*/
|
||||
async postCreate(created: LabelDocument): Promise<void> {
|
||||
this.eventEmitter.emit(
|
||||
'hook:chatbot:label:create',
|
||||
'hook:label:create',
|
||||
created,
|
||||
async (result: Record<string, any>) => {
|
||||
await this.model.updateOne(
|
||||
@ -82,6 +82,6 @@ export class LabelRepository extends BaseRepository<
|
||||
const labels = await this.find(
|
||||
typeof _criteria === 'string' ? { _id: _criteria } : _criteria,
|
||||
);
|
||||
this.eventEmitter.emit('hook:chatbot:label:delete', labels);
|
||||
this.eventEmitter.emit('hook:label:delete', labels);
|
||||
}
|
||||
}
|
||||
|
@ -45,16 +45,16 @@ export class SubscriberRepository extends BaseRepository<
|
||||
/**
|
||||
* Emits events related to the creation of a new subscriber.
|
||||
*
|
||||
* @param _created - The newly created subscriber document.
|
||||
* @param created - The newly created subscriber document.
|
||||
*/
|
||||
async postCreate(_created: SubscriberDocument): Promise<void> {
|
||||
async postCreate(created: SubscriberDocument): Promise<void> {
|
||||
this.eventEmitter.emit(
|
||||
'hook:stats:entry',
|
||||
'new_users',
|
||||
'New users',
|
||||
_created,
|
||||
created,
|
||||
);
|
||||
this.eventEmitter.emit('hook:chatbot:subscriber:create', _created);
|
||||
this.eventEmitter.emit('hook:subscriber:create', created);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +81,7 @@ export class SubscriberRepository extends BaseRepository<
|
||||
const subscriberUpdates: SubscriberUpdateDto = updates?.['$set'];
|
||||
|
||||
this.eventEmitter.emit(
|
||||
'hook:chatbot:subscriber:update:before',
|
||||
'hook:subscriber:update:before',
|
||||
criteria,
|
||||
subscriberUpdates,
|
||||
);
|
||||
@ -122,7 +122,7 @@ export class SubscriberRepository extends BaseRepository<
|
||||
>,
|
||||
updated: Subscriber,
|
||||
) {
|
||||
this.eventEmitter.emit('hook:chatbot:subscriber:update:after', updated);
|
||||
this.eventEmitter.emit('hook:subscriber:update:after', updated);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,7 +110,7 @@ export class SubscriberStub extends BaseSchema {
|
||||
|
||||
@Prop({
|
||||
type: Object,
|
||||
default: { vars: {} }, //TODO: add this to the migration
|
||||
default: { vars: {} },
|
||||
})
|
||||
context?: SubscriberContext;
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
export interface SubscriberContext {
|
||||
[key: string]: any;
|
||||
vars?: { [key: string]: any };
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ export class BlockService extends BaseService<Block, BlockPopulate, BlockFull> {
|
||||
subscriberContext: SubscriberContext,
|
||||
settings: Settings,
|
||||
): string {
|
||||
const vars = { ...subscriberContext.vars, ...context.vars };
|
||||
const vars = { ...(subscriberContext?.vars || {}), ...context.vars };
|
||||
// Replace context tokens with their values
|
||||
Object.keys(vars).forEach((key) => {
|
||||
if (typeof vars[key] === 'string' && vars[key].indexOf(':') !== -1) {
|
||||
|
@ -287,7 +287,7 @@ export class ChatService {
|
||||
*
|
||||
* @param subscriber - The end user (subscriber)
|
||||
*/
|
||||
@OnEvent('hook:chatbot:subscriber:create')
|
||||
@OnEvent('hook:subscriber:create')
|
||||
onSubscriberCreate(subscriber: Subscriber) {
|
||||
this.websocketGateway.broadcastSubscriberNew(subscriber);
|
||||
}
|
||||
@ -297,7 +297,7 @@ export class ChatService {
|
||||
*
|
||||
* @param subscriber - The end user (subscriber)
|
||||
*/
|
||||
@OnEvent('hook:chatbot:subscriber:update:after')
|
||||
@OnEvent('hook:subscriber:update:after')
|
||||
onSubscriberUpdate(subscriber: Subscriber) {
|
||||
this.websocketGateway.broadcastSubscriberUpdate(subscriber);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { MenuStub, Menu } from '../menu.schema';
|
||||
import { Menu, MenuStub } from '../menu.schema';
|
||||
|
||||
export enum MenuType {
|
||||
web_url = 'web_url',
|
||||
|
Loading…
Reference in New Issue
Block a user