Merge pull request #596 from Hexastack/fix/ts-issue

fix: Minor ts issue in subscriber preupdate hook
This commit is contained in:
Med Marrouchi 2025-01-21 14:36:48 +01:00 committed by GitHub
commit af936a7747
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 3 deletions

View File

@ -235,6 +235,19 @@ export default abstract class ChannelHandler<
event: EventWrapper<any, any, N>, event: EventWrapper<any, any, N>,
): Promise<AttachmentFile | undefined>; ): Promise<AttachmentFile | undefined>;
/**
* Fetch the subscriber profile data
*
* @deprecated
* @param event - The message event received
* @returns {Promise<Subscriber>} - The channel's response, otherwise an error
*/
async getUserData(
event: EventWrapper<any, any, N>,
): Promise<SubscriberCreateDto> {
return await this.getSubscriberData(event);
}
/** /**
* Fetch the subscriber profile data * Fetch the subscriber profile data
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
@ -82,6 +82,10 @@ export class SubscriberRepository extends BaseRepository<
const oldSubscriber = await this.findOne(criteria); const oldSubscriber = await this.findOne(criteria);
if (!oldSubscriber) {
throw new Error('Something went wrong: subscriber does not exist');
}
if (subscriberUpdates.assignedTo !== oldSubscriber?.assignedTo) { if (subscriberUpdates.assignedTo !== oldSubscriber?.assignedTo) {
this.eventEmitter.emit( this.eventEmitter.emit(
'hook:subscriber:assign', 'hook:subscriber:assign',

View File

@ -31,7 +31,11 @@ export type AttachmentRef =
url: string; url: string;
}; };
export interface AttachmentPayload { /** IMPORTANT: No need to use generic type here */
export interface AttachmentPayload<T extends AttachmentRef = AttachmentRef> {
type: FileType; type: FileType;
payload: AttachmentRef; payload: T;
} }
/** @deprecated */
export type WithUrl<A> = A & { url?: string };