@ebenos/messenger-adapter
Advanced tools
Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.2
import { GenericAdapter, IInteraction } from '@ebenos/framework'; | ||
import { Router } from 'express'; | ||
import { SenderFunction } from './sender'; | ||
import MessengerUser from './MessengerUser'; | ||
import { UserDataFields, MessagingOptions } from './interfaces/messengerAPI'; | ||
@@ -16,3 +15,3 @@ export interface MessengerWebhookOptions { | ||
} | ||
export default class MessengerAdapter<T extends MessengerUser> extends GenericAdapter<MessengerOperations> { | ||
export default class MessengerAdapter extends GenericAdapter<MessengerOperations> { | ||
private webhookKey; | ||
@@ -22,2 +21,3 @@ private pageToken; | ||
private pageId; | ||
private userLoader; | ||
getUserData: (id: string, fields: UserDataFields[]) => Promise<void>; | ||
@@ -27,3 +27,3 @@ operations: MessengerOperations; | ||
webhook: Router; | ||
constructor(options: MessengerWebhookOptions, sendFunction?: SenderFunction, domain?: string); | ||
constructor(options: MessengerWebhookOptions, userLoader?: (id: string) => Promise<any>, sendFunction?: SenderFunction, domain?: string); | ||
initialization(): void; | ||
@@ -30,0 +30,0 @@ private validationEndpoint; |
@@ -13,3 +13,3 @@ "use strict"; | ||
class MessengerAdapter extends framework_1.GenericAdapter { | ||
constructor(options, sendFunction, domain) { | ||
constructor(options, userLoader, sendFunction, domain) { | ||
const { route = '/fb', webhookKey = 'ebony123', pageId, pageToken } = options; | ||
@@ -28,6 +28,12 @@ super(); | ||
this.webhook = express_1.Router(); | ||
if (userLoader) { | ||
this.userLoader = userLoader; | ||
} | ||
else { | ||
this.userLoader = MessengerUser_1.userLoader(this.pageToken); | ||
} | ||
} | ||
initialization() { | ||
const messaging = messaging_1.default({ | ||
userLoader: MessengerUser_1.userLoader(this.pageToken), | ||
userLoader: this.userLoader, | ||
routers: this.routers, | ||
@@ -34,0 +40,0 @@ handlers: this.handlers |
{ | ||
"name": "@ebenos/messenger-adapter", | ||
"version": "4.0.0-alpha.1", | ||
"version": "4.0.0-alpha.2", | ||
"description": "Facebook SendAPI Library for the Ebony framework.", | ||
@@ -49,3 +49,3 @@ "main": "./build/index.js", | ||
], | ||
"gitHead": "04583595fb6aef30da25b21674815e34db7b621b" | ||
"gitHead": "84bdb35abcd71f8a83c40be4b6ce36e493abbf95" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54778
784