-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(channels): custom channels (#425)
* feat(channels): custom channels * fixes * migration * down migrate * fix * add tests * remove client action source * fix * fix * fix * bump client package * bump packages
- Loading branch information
1 parent
d7f4f69
commit a818301
Showing
25 changed files
with
310 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import { uuid } from '@botpress/messaging-base' | ||
import { Endpoint } from '@botpress/messaging-channels' | ||
|
||
/** | ||
* Indicates whether an action is performed due to a request made by | ||
* - a conduit (we receive a request from an external service such as Telegram) | ||
* - a client (using the http api with a clientId and clientToken) | ||
* - a socket (using a websocket connection) | ||
* | ||
* Knowing this allows messaging to avoid redundantly | ||
* streaming back an event to the service that made the request. | ||
*/ | ||
export interface ActionSource { | ||
endpoint?: Endpoint | ||
client?: { id: uuid } | ||
socket?: { id: string } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { getTableId, Migration } from '@botpress/messaging-engine' | ||
|
||
export class CustomChannelsMigration extends Migration { | ||
meta = { | ||
name: CustomChannelsMigration.name, | ||
description: 'Modifies the msg_tunnels table to support custom channels', | ||
version: '1.1.7' | ||
} | ||
|
||
async valid() { | ||
return true | ||
} | ||
|
||
async applied() { | ||
return this.trx.schema.hasColumn(getTableId('msg_tunnels'), 'customChannelName') | ||
} | ||
|
||
async up() { | ||
await this.trx.schema.alterTable(getTableId('msg_tunnels'), (table) => { | ||
table.uuid('channelId').nullable().alter() | ||
table.string('customChannelName').nullable() | ||
table.unique(['clientId', 'customChannelName']) | ||
}) | ||
} | ||
|
||
async down() { | ||
await this.trx(getTableId('msg_tunnels')).whereNull('channelId').del() | ||
|
||
await this.trx.schema.alterTable(getTableId('msg_tunnels'), (table) => { | ||
table.uuid('channelId').notNullable().alter() | ||
table.dropUnique(['clientId', 'customChannelName']) | ||
table.dropColumn('customChannelName') | ||
}) | ||
} | ||
} |
Oops, something went wrong.