mirror of
https://github.com/hexastack/hexabot
synced 2024-11-28 06:52:20 +00:00
Merge pull request #125 from Hexastack/fix/event-consistent-naming
fix: event consistent naming
This commit is contained in:
commit
38e0f6a1f3
@ -43,7 +43,7 @@ export class LabelRepository extends BaseRepository<
|
|||||||
*/
|
*/
|
||||||
async postCreate(created: LabelDocument): Promise<void> {
|
async postCreate(created: LabelDocument): Promise<void> {
|
||||||
this.eventEmitter.emit(
|
this.eventEmitter.emit(
|
||||||
'hook:chatbot:label:create',
|
'hook:label:create',
|
||||||
created,
|
created,
|
||||||
async (result: Record<string, any>) => {
|
async (result: Record<string, any>) => {
|
||||||
await this.model.updateOne(
|
await this.model.updateOne(
|
||||||
@ -82,6 +82,6 @@ export class LabelRepository extends BaseRepository<
|
|||||||
const labels = await this.find(
|
const labels = await this.find(
|
||||||
typeof _criteria === 'string' ? { _id: _criteria } : _criteria,
|
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.
|
* 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(
|
this.eventEmitter.emit(
|
||||||
'hook:stats:entry',
|
'hook:stats:entry',
|
||||||
'new_users',
|
'new_users',
|
||||||
'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'];
|
const subscriberUpdates: SubscriberUpdateDto = updates?.['$set'];
|
||||||
|
|
||||||
this.eventEmitter.emit(
|
this.eventEmitter.emit(
|
||||||
'hook:chatbot:subscriber:update:before',
|
'hook:subscriber:update:before',
|
||||||
criteria,
|
criteria,
|
||||||
subscriberUpdates,
|
subscriberUpdates,
|
||||||
);
|
);
|
||||||
@ -122,7 +122,7 @@ export class SubscriberRepository extends BaseRepository<
|
|||||||
>,
|
>,
|
||||||
updated: Subscriber,
|
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({
|
@Prop({
|
||||||
type: Object,
|
type: Object,
|
||||||
default: { vars: {} }, //TODO: add this to the migration
|
default: { vars: {} },
|
||||||
})
|
})
|
||||||
context?: SubscriberContext;
|
context?: SubscriberContext;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export interface SubscriberContext {
|
export interface SubscriberContext {
|
||||||
[key: string]: any;
|
vars?: { [key: string]: any };
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ export class BlockService extends BaseService<Block, BlockPopulate, BlockFull> {
|
|||||||
subscriberContext: SubscriberContext,
|
subscriberContext: SubscriberContext,
|
||||||
settings: Settings,
|
settings: Settings,
|
||||||
): string {
|
): string {
|
||||||
const vars = { ...subscriberContext.vars, ...context.vars };
|
const vars = { ...(subscriberContext?.vars || {}), ...context.vars };
|
||||||
// Replace context tokens with their values
|
// Replace context tokens with their values
|
||||||
Object.keys(vars).forEach((key) => {
|
Object.keys(vars).forEach((key) => {
|
||||||
if (typeof vars[key] === 'string' && vars[key].indexOf(':') !== -1) {
|
if (typeof vars[key] === 'string' && vars[key].indexOf(':') !== -1) {
|
||||||
|
@ -287,7 +287,7 @@ export class ChatService {
|
|||||||
*
|
*
|
||||||
* @param subscriber - The end user (subscriber)
|
* @param subscriber - The end user (subscriber)
|
||||||
*/
|
*/
|
||||||
@OnEvent('hook:chatbot:subscriber:create')
|
@OnEvent('hook:subscriber:create')
|
||||||
onSubscriberCreate(subscriber: Subscriber) {
|
onSubscriberCreate(subscriber: Subscriber) {
|
||||||
this.websocketGateway.broadcastSubscriberNew(subscriber);
|
this.websocketGateway.broadcastSubscriberNew(subscriber);
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ export class ChatService {
|
|||||||
*
|
*
|
||||||
* @param subscriber - The end user (subscriber)
|
* @param subscriber - The end user (subscriber)
|
||||||
*/
|
*/
|
||||||
@OnEvent('hook:chatbot:subscriber:update:after')
|
@OnEvent('hook:subscriber:update:after')
|
||||||
onSubscriberUpdate(subscriber: Subscriber) {
|
onSubscriberUpdate(subscriber: Subscriber) {
|
||||||
this.websocketGateway.broadcastSubscriberUpdate(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).
|
* 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 {
|
export enum MenuType {
|
||||||
web_url = 'web_url',
|
web_url = 'web_url',
|
||||||
|
Loading…
Reference in New Issue
Block a user