-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/deno-runtime' into feat/videoconf-handler
- Loading branch information
Showing
17 changed files
with
245 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { App } from '@rocket.chat/apps-engine/definition/App.ts'; | ||
import { AppObjectRegistry } from '../../AppObjectRegistry.ts'; | ||
|
||
export default function handleGetStatus(): Promise<boolean> { | ||
const app = AppObjectRegistry.get<App>('app'); | ||
|
||
if (typeof app?.getStatus !== 'function') { | ||
throw new Error('App must contain a getStatus function', { | ||
cause: 'invalid_app', | ||
}); | ||
} | ||
|
||
return app.getStatus(); | ||
} |
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 |
---|---|---|
|
@@ -16,3 +16,4 @@ export default async function handleInitialize(): Promise<boolean> { | |
|
||
return true; | ||
} | ||
|
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,18 @@ | ||
import type { App } from '@rocket.chat/apps-engine/definition/App.ts'; | ||
import { AppObjectRegistry } from '../../AppObjectRegistry.ts'; | ||
import { AppAccessorsInstance } from '../../lib/accessors/mod.ts'; | ||
|
||
export default async function handleOnDisable(): Promise<boolean> { | ||
const app = AppObjectRegistry.get<App>('app'); | ||
|
||
if (typeof app?.onDisable !== 'function') { | ||
throw new Error('App must contain an onDisable function', { | ||
cause: 'invalid_app', | ||
}); | ||
} | ||
|
||
await app.onDisable(AppAccessorsInstance.getConfigurationModify()); | ||
|
||
return true; | ||
} | ||
|
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,16 @@ | ||
import type { App } from '@rocket.chat/apps-engine/definition/App.ts'; | ||
|
||
import { AppObjectRegistry } from '../../AppObjectRegistry.ts'; | ||
import { AppAccessorsInstance } from '../../lib/accessors/mod.ts'; | ||
|
||
export default function handleOnEnable(): Promise<boolean> { | ||
const app = AppObjectRegistry.get<App>('app'); | ||
|
||
if (typeof app?.onEnable !== 'function') { | ||
throw new Error('App must contain an onEnable function', { | ||
cause: 'invalid_app', | ||
}); | ||
} | ||
|
||
return app.onEnable(AppAccessorsInstance.getEnvironmentRead(), AppAccessorsInstance.getConfigurationModify()); | ||
} |
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,29 @@ | ||
import type { App } from '@rocket.chat/apps-engine/definition/App.ts'; | ||
import { AppObjectRegistry } from '../../AppObjectRegistry.ts'; | ||
import { AppAccessorsInstance } from '../../lib/accessors/mod.ts'; | ||
|
||
export default async function handleOnInstall(params: unknown): Promise<boolean> { | ||
const app = AppObjectRegistry.get<App>('app'); | ||
|
||
if (typeof app?.onInstall !== 'function') { | ||
throw new Error('App must contain an onInstall function', { | ||
cause: 'invalid_app', | ||
}); | ||
} | ||
|
||
if (!Array.isArray(params)) { | ||
throw new Error('Invalid params', { cause: 'invalid_param_type' }); | ||
} | ||
|
||
const [context] = params as [Record<string, unknown>]; | ||
|
||
await app.onInstall( | ||
context, | ||
AppAccessorsInstance.getReader(), | ||
AppAccessorsInstance.getHttp(), | ||
AppAccessorsInstance.getPersistence(), | ||
AppAccessorsInstance.getModifier(), | ||
); | ||
|
||
return true; | ||
} |
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,21 @@ | ||
import type { App } from '@rocket.chat/apps-engine/definition/App.ts'; | ||
import { AppObjectRegistry } from '../../AppObjectRegistry.ts'; | ||
import { AppAccessorsInstance } from '../../lib/accessors/mod.ts'; | ||
|
||
export default function handleOnPreSettingUpdate(params: unknown): Promise<object> { | ||
const app = AppObjectRegistry.get<App>('app'); | ||
|
||
if (typeof app?.onPreSettingUpdate !== 'function') { | ||
throw new Error('App must contain an onPreSettingUpdate function', { | ||
cause: 'invalid_app', | ||
}); | ||
} | ||
|
||
if (!Array.isArray(params)) { | ||
throw new Error('Invalid params', { cause: 'invalid_param_type' }); | ||
} | ||
|
||
const [setting] = params as [Record<string, unknown>]; | ||
|
||
return app.onPreSettingUpdate(setting, AppAccessorsInstance.getConfigurationModify(), AppAccessorsInstance.getReader(), AppAccessorsInstance.getHttp()); | ||
} |
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,23 @@ | ||
import type { App } from '@rocket.chat/apps-engine/definition/App.ts'; | ||
import { AppObjectRegistry } from '../../AppObjectRegistry.ts'; | ||
import { AppAccessorsInstance } from '../../lib/accessors/mod.ts'; | ||
|
||
export default async function handleOnSettingUpdated(params: unknown): Promise<boolean> { | ||
const app = AppObjectRegistry.get<App>('app'); | ||
|
||
if (typeof app?.onSettingUpdated !== 'function') { | ||
throw new Error('App must contain an onSettingUpdated function', { | ||
cause: 'invalid_app', | ||
}); | ||
} | ||
|
||
if (!Array.isArray(params)) { | ||
throw new Error('Invalid params', { cause: 'invalid_param_type' }); | ||
} | ||
|
||
const [setting] = params as [Record<string, unknown>]; | ||
|
||
await app.onSettingUpdated(setting, AppAccessorsInstance.getConfigurationModify(), AppAccessorsInstance.getReader(), AppAccessorsInstance.getHttp()); | ||
|
||
return true; | ||
} |
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,29 @@ | ||
import type { App } from '@rocket.chat/apps-engine/definition/App.ts'; | ||
import { AppObjectRegistry } from '../../AppObjectRegistry.ts'; | ||
import { AppAccessorsInstance } from '../../lib/accessors/mod.ts'; | ||
|
||
export default async function handleOnUninstall(params: unknown): Promise<boolean> { | ||
const app = AppObjectRegistry.get<App>('app'); | ||
|
||
if (typeof app?.onUninstall !== 'function') { | ||
throw new Error('App must contain an onUninstall function', { | ||
cause: 'invalid_app', | ||
}); | ||
} | ||
|
||
if (!Array.isArray(params)) { | ||
throw new Error('Invalid params', { cause: 'invalid_param_type' }); | ||
} | ||
|
||
const [context] = params as [Record<string, unknown>]; | ||
|
||
await app.onUninstall( | ||
context, | ||
AppAccessorsInstance.getReader(), | ||
AppAccessorsInstance.getHttp(), | ||
AppAccessorsInstance.getPersistence(), | ||
AppAccessorsInstance.getModifier(), | ||
); | ||
|
||
return true; | ||
} |
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,24 @@ | ||
import type { App } from '@rocket.chat/apps-engine/definition/App.ts'; | ||
import { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus.ts'; | ||
|
||
import { AppObjectRegistry } from '../../AppObjectRegistry.ts'; | ||
|
||
export default async function handleSetStatus(params: unknown): Promise<null> { | ||
if (!Array.isArray(params) || !Object.values(AppStatus).includes(params[0])) { | ||
throw new Error('Invalid params', { cause: 'invalid_param_type' }); | ||
} | ||
|
||
const [status] = params as [AppStatus]; | ||
|
||
const app = AppObjectRegistry.get<App>('app'); | ||
|
||
if (!app || typeof app['setStatus'] !== 'function') { | ||
throw new Error('App must contain a setStatus function', { | ||
cause: 'invalid_app', | ||
}); | ||
} | ||
|
||
await app['setStatus'](status); | ||
|
||
return null; | ||
} |
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
Oops, something went wrong.