Skip to content

User Loader functionality for Viber adapter - #34

Draft
DimitriosGkegkas wants to merge 6 commits into
chrispanag:mainfrom
DimitriosGkegkas:main
Draft

User Loader functionality for Viber adapter #34
DimitriosGkegkas wants to merge 6 commits into
chrispanag:mainfrom
DimitriosGkegkas:main

Conversation

@DimitriosGkegkas

Copy link
Copy Markdown
Collaborator
  • Added User loader in viber adaptor

  • Also change the type of the tracking data to be more broad

@chrispanag

Copy link
Copy Markdown
Owner

what did we have before? Beforehand was it using an in memory loader or something like that? Or it didn't provide the user at all?

@DimitriosGkegkas

Copy link
Copy Markdown
Collaborator Author

what did we have before? Beforehand was it using an in memory loader or something like that? Or it didn't provide the user at all?

We only had the IUser data and we return just the sender attributes not even a database user object.
It still uses this function to return a IUser when an userLoader is not provided

function convertViberSenderToUser(sender: IViberSender): IUser {
    return {
        id: sender.id,
        firstName: sender.name,
        lastName: sender.name,
        data: {
            country: sender.country,
            avatar: sender.avatar,
            api_version: sender.api_version,
            language: sender.language
        }
    };
}

export function addTextRule<U extends User<any>>(
module: Module<U>,
action: (user: U, payload?: IPayload, ...args: any[]) => Promise<any>,
action: (user: U, payload: IPayload, ...args: any[]) => Promise<any>,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what will the payload be like there?

authToken: string;
welcomeMessage?: Record<string, unknown>;
userLoader?: (userData: IUser) => Promise<U>;
webhookHanlers?: IViberWebhookHandlers;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: webhookHanlers -> webhookHandlers

public sender;

private welcomeMessage?: Record<string, unknown>;
private webhookHanlers?: IViberWebhookHandlers;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo webhookHanlers -> webhookHandlers

return;
case 'unsubscribed':
console.log('unsubscribed');
if (webhooks?.unsubscribeWebhook) webhooks.unsubscribeWebhook(body);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add brackets ({}) on all ifs

@chrispanag chrispanag left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't references to @ebonydevcopy be changed to @ebenos?

{
"name": "@ebenos/framework",
"version": "4.0.0-alpha.29",
"name": "@ebonydevcopy/framework",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't these references be changed here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this pull request is just to keep track of the changes in the copy package. I'll make a new one with the correct changes for review and merging OTD

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

@DimitriosGkegkas
DimitriosGkegkas marked this pull request as draft February 28, 2022 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants