-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathYouTrackLinkerApp.ts
61 lines (50 loc) · 2.69 KB
/
YouTrackLinkerApp.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import {
IConfigurationExtend,
IConfigurationModify,
IEnvironmentRead,
IHttp,
ILogger,
IMessageBuilder,
IPersistence,
IRead,
} from '@rocket.chat/apps-engine/definition/accessors';
import { App } from '@rocket.chat/apps-engine/definition/App';
import { IMessage, IPreMessageSentModify, IPreMessageUpdatedModify } from '@rocket.chat/apps-engine/definition/messages';
import { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';
import { ISetting } from '@rocket.chat/apps-engine/definition/settings';
import { MessageHandler } from './src/handler/MessageHandler';
import { Settings } from './src/settings/Settings';
export class YouTrackLinkerApp extends App implements IPreMessageSentModify, IPreMessageUpdatedModify {
private readonly settings: Settings = new Settings();
private readonly messageHandler: MessageHandler;
constructor(info: IAppInfo, logger: ILogger) {
super(info, logger);
this.messageHandler = new MessageHandler(this.settings);
}
public async checkPreMessageSentModify(message: IMessage, read: IRead, http: IHttp): Promise<boolean> {
return this.messageHandler.checkPreMessageModify(message, read, http);
}
public async checkPreMessageUpdatedModify(message: IMessage, read: IRead, http: IHttp): Promise<boolean> {
return this.messageHandler.checkPreMessageModify(message, read, http);
}
// tslint:disable-next-line:max-line-length
public async executePreMessageSentModify(message: IMessage, builder: IMessageBuilder, read: IRead, http: IHttp, persistence: IPersistence): Promise<IMessage> {
return this.messageHandler.executePreMessageModify(message, builder, read, http, persistence);
}
// tslint:disable-next-line:max-line-length
public async executePreMessageUpdatedModify(message: IMessage, builder: IMessageBuilder, read: IRead, http: IHttp, persistence: IPersistence): Promise<IMessage> {
return this.messageHandler.executePreMessageModify(message, builder, read, http, persistence);
}
public async onEnable(environmentRead: IEnvironmentRead, configModify: IConfigurationModify): Promise<boolean> {
await this.settings.setFrom(environmentRead.getSettings());
return true;
}
// tslint:disable-next-line:max-line-length
public async onSettingUpdated(setting: ISetting, configModify: IConfigurationModify, read: IRead, http: IHttp): Promise<void> {
this.settings.onUpdate(setting);
}
// tslint:disable-next-line:max-line-length
protected async extendConfiguration(configuration: IConfigurationExtend, environmentRead: IEnvironmentRead): Promise<void> {
await this.settings.init(configuration.settings);
}
}