Skip to content

Commit

Permalink
Merge pull request #596 from Hexastack/fix/ts-issue
Browse files Browse the repository at this point in the history
fix: Minor ts issue in subscriber preupdate hook
  • Loading branch information
marrouchi authored Jan 21, 2025
2 parents 9c0a358 + be1a79f commit af936a7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
13 changes: 13 additions & 0 deletions api/src/channel/lib/Handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ export default abstract class ChannelHandler<
event: EventWrapper<any, any, N>,
): 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
*
Expand Down
6 changes: 5 additions & 1 deletion api/src/chat/repositories/subscriber.repository.ts
Original file line number Diff line number Diff line change
@@ -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:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
Expand Down Expand Up @@ -82,6 +82,10 @@ export class SubscriberRepository extends BaseRepository<

const oldSubscriber = await this.findOne(criteria);

if (!oldSubscriber) {
throw new Error('Something went wrong: subscriber does not exist');
}

if (subscriberUpdates.assignedTo !== oldSubscriber?.assignedTo) {
this.eventEmitter.emit(
'hook:subscriber:assign',
Expand Down
8 changes: 6 additions & 2 deletions api/src/chat/schemas/types/attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export type AttachmentRef =
url: string;
};

export interface AttachmentPayload {
/** IMPORTANT: No need to use generic type here */
export interface AttachmentPayload<T extends AttachmentRef = AttachmentRef> {
type: FileType;
payload: AttachmentRef;
payload: T;
}

/** @deprecated */
export type WithUrl<A> = A & { url?: string };

0 comments on commit af936a7

Please sign in to comment.