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

Add role to User #79

Merged
merged 1 commit into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Added optional `role` to `User` interface, must be either `"bot"`, `"channel"`, or `"user"`

## [0.9.15]
### Added
- First version to be tracked on CHANGELOG.md
23 changes: 13 additions & 10 deletions src/directLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface UnknownMedia{
contentType: string,
contentUrl: string,
name?: string,
thumbnailUrl?: string
thumbnailUrl?: string
}

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

export type UserRole = "bot" | "channel" | "user";

export interface User {
id: string,
name?: string,
iconUrl?: string
iconUrl?: string,
role?: UserRole
}

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

if (options.domain)
this.domain = options.domain;
if (options.conversationId) {
this.conversationId = options.conversationId;
}
if (options.watermark) {
if (this.webSocket)
if (this.webSocket)
console.warn("Watermark was ignored: it is not supported using websockets at the moment");
else
this.watermark = options.watermark;
}
if (options.streamUrl) {
if (options.token && options.conversationId)
if (options.token && options.conversationId)
this.streamUrl = options.streamUrl;
else
console.warn("streamUrl was ignored: you need to provide a token and a conversationid");
Expand Down Expand Up @@ -368,7 +371,7 @@ export class DirectLine implements IBotConnection {
}
}
else {
return Observable.of(connectionStatus);
return Observable.of(connectionStatus);
}
})
.filter(connectionStatus => connectionStatus != ConnectionStatus.Uninitialized && connectionStatus != ConnectionStatus.Connecting)
Expand Down Expand Up @@ -399,8 +402,8 @@ export class DirectLine implements IBotConnection {

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

Expand Down Expand Up @@ -475,7 +478,7 @@ export class DirectLine implements IBotConnection {
this.tokenRefreshSubscription.unsubscribe();
this.connectionStatus$.next(ConnectionStatus.Ended);
}

getSessionId(): Observable<string> {
// If we're not connected to the bot, get connected
// Will throw an error if we are not connected
Expand All @@ -484,7 +487,7 @@ export class DirectLine implements IBotConnection {
.flatMap(_ =>
Observable.ajax({
method: "GET",
url: `${this.domain}/session/getsessionid`,
url: `${this.domain}/session/getsessionid`,
withCredentials: true,
timeout,
headers: {
Expand Down