Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Loader functionality for Viber adapter #34

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

DimitriosGkegkas
Copy link
Collaborator

  • Added User loader in viber adaptor

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

@chrispanag
Copy link
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
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
        }
    };
}

@@ -79,7 +79,7 @@ export function addBaseLocationRule<U extends User<any>>(

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
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?

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

Choose a reason for hiding this comment

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

typo: webhookHanlers -> webhookHandlers

@@ -31,25 +45,41 @@ export default class ViberAdapter extends GenericAdapter {
public sender;

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

Choose a reason for hiding this comment

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

typo webhookHanlers -> webhookHandlers

console.log('subscribed');
return;
case 'unsubscribed':
console.log('unsubscribed');
if (webhooks?.unsubscribeWebhook) webhooks.unsubscribeWebhook(body);
Copy link
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

Copy link
Owner

@chrispanag chrispanag left a comment

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?

@@ -1,6 +1,6 @@
{
"name": "@ebenos/framework",
"version": "4.0.0-alpha.29",
"name": "@ebonydevcopy/framework",
Copy link
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
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
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