Skip to content

Commit

Permalink
Merge pull request #73 from RocketChat/chore/replace-tslint-1
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman authored Nov 30, 2021
2 parents c64b658 + df9685b commit 5bb3e22
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 60 deletions.
13 changes: 5 additions & 8 deletions DialogflowApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ export class DialogflowApp
public async executeLivechatBlockActionHandler(
context: UIKitLivechatBlockInteractionContext,
read: IRead,
http: IHttp,
persistence: IPersistence,
_http: IHttp,
_persistence: IPersistence,
modify: IModify,
): Promise<IUIKitResponse> {
const handler = new ExecuteLivechatBlockActionHandler(
this,
context,
read,
http,
persistence,
modify,
);
return await handler.run();
Expand All @@ -59,23 +57,22 @@ export class DialogflowApp
message: ILivechatMessage,
read: IRead,
http: IHttp,
persis: IPersistence,
_persis: IPersistence,
modify: IModify,
): Promise<void> {
const handler = new PostMessageSentHandler(
this,
message,
read,
http,
persis,
modify,
);
await handler.run();
}

public async onSettingUpdated(
setting: ISetting,
configurationModify: IConfigurationModify,
_setting: ISetting,
_configurationModify: IConfigurationModify,
read: IRead,
http: IHttp,
): Promise<void> {
Expand Down
33 changes: 18 additions & 15 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"id": "21b7d3ba-031b-41d9-8ff2-fbbfa081ae90",
"version": "1.2.4",
"requiredApiVersion": "^1.17.0",
"iconFile": "icon.png",
"author": {
"name": "Rocket.Chat",
"homepage": "https://rocket.chat/",
"support": "support@rocket.chat"
},
"name": "Dialogflow",
"nameSlug": "dialogflow",
"classFile": "DialogflowApp.ts",
"description": "Integration between Rocket.Chat and the Dialogflow Chatbot platform",
"implements": ["IPostMessageSent", "IUIKitLivechatInteractionHandler"]
}
"id": "21b7d3ba-031b-41d9-8ff2-fbbfa081ae90",
"version": "1.2.4",
"requiredApiVersion": "^1.17.0",
"iconFile": "icon.png",
"author": {
"name": "Rocket.Chat",
"homepage": "https://rocket.chat/",
"support": "support@rocket.chat"
},
"name": "Dialogflow",
"nameSlug": "dialogflow",
"classFile": "DialogflowApp.ts",
"description": "Integration between Rocket.Chat and the Dialogflow Chatbot platform",
"implements": [
"IPostMessageSent",
"IUIKitLivechatInteractionHandler"
]
}
9 changes: 2 additions & 7 deletions endpoints/FulfillmentsEndpoint.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
HttpStatusCode,
IHttp,
IModify,
IPersistence,
IRead,
} from '@rocket.chat/apps-engine/definition/accessors';
import {
Expand All @@ -23,16 +21,14 @@ export class FulfillmentsEndpoint extends ApiEndpoint {

public async post(
request: IApiRequest,
endpoint: IApiEndpointInfo,
_endpoint: IApiEndpointInfo,
read: IRead,
modify: IModify,
http: IHttp,
persis: IPersistence,
): Promise<IApiResponse> {
this.app.getLogger().info(Logs.ENDPOINT_RECEIVED_REQUEST);

try {
await this.processRequest(read, modify, persis, request);
await this.processRequest(read, modify, request);
return createHttpResponse(
HttpStatusCode.OK,
{ 'Content-Type': Headers.CONTENT_TYPE_JSON },
Expand All @@ -53,7 +49,6 @@ export class FulfillmentsEndpoint extends ApiEndpoint {
private async processRequest(
read: IRead,
modify: IModify,
persis: IPersistence,
request: IApiRequest,
) {
const message: IDialogflowMessage = Dialogflow.parseRequest(
Expand Down
3 changes: 1 addition & 2 deletions endpoints/IncomingEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ export class IncomingEndpoint extends ApiEndpoint {

public async post(
request: IApiRequest,
endpoint: IApiEndpointInfo,
_endpoint: IApiEndpointInfo,
read: IRead,
modify: IModify,
http: IHttp,
// persis: IPersistence,
): Promise<IApiResponse> {
this.app.getLogger().info(Logs.ENDPOINT_RECEIVED_REQUEST);

Expand Down
4 changes: 0 additions & 4 deletions handler/ExecuteLivechatBlockActionHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
IHttp,
IModify,
IPersistence,
IRead,
} from '@rocket.chat/apps-engine/definition/accessors';
import { IApp } from '@rocket.chat/apps-engine/definition/IApp';
Expand All @@ -27,8 +25,6 @@ export class ExecuteLivechatBlockActionHandler {
private readonly app: IApp,
private context: UIKitLivechatBlockInteractionContext,
private read: IRead,
private http: IHttp,
private persistence: IPersistence,
private modify: IModify,
) {}

Expand Down
2 changes: 1 addition & 1 deletion handler/OnSettingUpdatedHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class OnSettingUpdatedHandler {
);
this.app.getLogger().info(Logs.GOOGLE_AUTH_SUCCESS);
} catch (error) {
this.app.getLogger().error(error.message);
this.app.getLogger().error(error);
}
}
}
2 changes: 0 additions & 2 deletions handler/PostMessageSentHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
IHttp,
IModify,
IPersistence,
IRead,
} from '@rocket.chat/apps-engine/definition/accessors';
import { IApp } from '@rocket.chat/apps-engine/definition/IApp';
Expand Down Expand Up @@ -31,7 +30,6 @@ export class PostMessageSentHandler {
private readonly message: ILivechatMessage,
private readonly read: IRead,
private readonly http: IHttp,
private readonly persis: IPersistence,
private readonly modify: IModify,
) {}

Expand Down
8 changes: 4 additions & 4 deletions lib/Dialogflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ class DialogflowClass {
);

const queryInput = {
...(requestType === DialogflowRequestType.EVENT && {
...requestType === DialogflowRequestType.EVENT && {
event: request,
}),
...(requestType === DialogflowRequestType.MESSAGE && {
},
...requestType === DialogflowRequestType.MESSAGE && {
text: { languageCode: LanguageCode.EN, text: request },
}),
},
};

const httpRequestContent: IHttpRequest = createHttpRequest(
Expand Down
12 changes: 2 additions & 10 deletions lib/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,7 @@ export const createMessage = async (
msg.addBlocks(blocks);
}

try {
return await modify.getCreator().finish(msg);
} catch (e) {
console.error(e);
}
return modify.getCreator().finish(msg);
};

export const createLivechatMessage = async (
Expand Down Expand Up @@ -190,11 +186,7 @@ export const createLivechatMessage = async (
msg.addAttachment(attachment);
}

try {
return await modify.getCreator().finish(msg);
} catch (e) {
console.error(e);
}
return modify.getCreator().finish(msg);
};

export const deleteAllActionBlocks = async (
Expand Down
9 changes: 2 additions & 7 deletions lib/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { createMessage } from './Message';

export const updateRoomCustomFields = async (
rid: string,
// eslint-disable-next-line
data: { [k: string]: any },
data: { [k: string]: unknown },
read: IRead,
modify: IModify,
): Promise<void> => {
Expand Down Expand Up @@ -45,11 +44,7 @@ export const updateRoomCustomFields = async (
const roomBuilder = await modify.getUpdater().room(rid, user);
roomBuilder.setCustomFields(customFields);

try {
await modify.getUpdater().finish(roomBuilder);
} catch (error) {
console.error(error);
}
return modify.getUpdater().finish(roomBuilder);
};

export const closeChat = async (modify: IModify, read: IRead, rid: string) => {
Expand Down

0 comments on commit 5bb3e22

Please sign in to comment.