Skip to content

Commit 1bd10b7

Browse files
committed
Add role to User
1 parent 1f5e00d commit 1bd10b7

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
### Added
9+
- Added optional `role` to `User` interface, must be either `"bot"`, `"channel"`, or `"user"`
10+
11+
## [0.9.15]
12+
### Added
13+
- First version to be tracked on CHANGELOG.md

src/directLine.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface UnknownMedia{
4848
contentType: string,
4949
contentUrl: string,
5050
name?: string,
51-
thumbnailUrl?: string
51+
thumbnailUrl?: string
5252
}
5353

5454
export type CardActionTypes = "openUrl" | "imBack" | "postBack" | "playAudio" | "playVideo" | "showImage" | "downloadFile" | "signin" | "call";
@@ -193,10 +193,13 @@ export interface AnimationCard {
193193
export type KnownMedia = Media | HeroCard | Thumbnail | Signin | OAuth | Receipt | AudioCard | VideoCard | AnimationCard | FlexCard | AdaptiveCard;
194194
export type Attachment = KnownMedia | UnknownMedia;
195195

196+
export type UserRole = "bot" | "channel" | "user";
197+
196198
export interface User {
197199
id: string,
198200
name?: string,
199-
iconUrl?: string
201+
iconUrl?: string,
202+
role?: UserRole
200203
}
201204

202205
export interface IActivity {
@@ -311,21 +314,21 @@ export class DirectLine implements IBotConnection {
311314
constructor(options: DirectLineOptions) {
312315
this.secret = options.secret;
313316
this.token = options.secret || options.token;
314-
this.webSocket = (options.webSocket === undefined ? true : options.webSocket) && typeof WebSocket !== 'undefined' && WebSocket !== undefined;
317+
this.webSocket = (options.webSocket === undefined ? true : options.webSocket) && typeof WebSocket !== 'undefined' && WebSocket !== undefined;
315318

316319
if (options.domain)
317320
this.domain = options.domain;
318321
if (options.conversationId) {
319322
this.conversationId = options.conversationId;
320323
}
321324
if (options.watermark) {
322-
if (this.webSocket)
325+
if (this.webSocket)
323326
console.warn("Watermark was ignored: it is not supported using websockets at the moment");
324327
else
325328
this.watermark = options.watermark;
326329
}
327330
if (options.streamUrl) {
328-
if (options.token && options.conversationId)
331+
if (options.token && options.conversationId)
329332
this.streamUrl = options.streamUrl;
330333
else
331334
console.warn("streamUrl was ignored: you need to provide a token and a conversationid");
@@ -368,7 +371,7 @@ export class DirectLine implements IBotConnection {
368371
}
369372
}
370373
else {
371-
return Observable.of(connectionStatus);
374+
return Observable.of(connectionStatus);
372375
}
373376
})
374377
.filter(connectionStatus => connectionStatus != ConnectionStatus.Uninitialized && connectionStatus != ConnectionStatus.Connecting)
@@ -399,8 +402,8 @@ export class DirectLine implements IBotConnection {
399402

400403
private startConversation() {
401404
//if conversationid is set here, it means we need to call the reconnect api, else it is a new conversation
402-
const url = this.conversationId
403-
? `${this.domain}/conversations/${this.conversationId}?watermark=${this.watermark}`
405+
const url = this.conversationId
406+
? `${this.domain}/conversations/${this.conversationId}?watermark=${this.watermark}`
404407
: `${this.domain}/conversations`;
405408
const method = this.conversationId ? "GET" : "POST";
406409

@@ -475,7 +478,7 @@ export class DirectLine implements IBotConnection {
475478
this.tokenRefreshSubscription.unsubscribe();
476479
this.connectionStatus$.next(ConnectionStatus.Ended);
477480
}
478-
481+
479482
getSessionId(): Observable<string> {
480483
// If we're not connected to the bot, get connected
481484
// Will throw an error if we are not connected
@@ -484,7 +487,7 @@ export class DirectLine implements IBotConnection {
484487
.flatMap(_ =>
485488
Observable.ajax({
486489
method: "GET",
487-
url: `${this.domain}/session/getsessionid`,
490+
url: `${this.domain}/session/getsessionid`,
488491
withCredentials: true,
489492
timeout,
490493
headers: {

0 commit comments

Comments
 (0)