Skip to content
This repository was archived by the owner on Dec 9, 2022. It is now read-only.

Commit 36d59d3

Browse files
committed
Refactor
1 parent c9abca0 commit 36d59d3

File tree

7 files changed

+19
-28
lines changed

7 files changed

+19
-28
lines changed
File renamed without changes.
File renamed without changes.

functions/lang_selector.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DefineFunction, Schema, SlackFunction } from "deno-slack-sdk/mod.ts";
2-
import { reactionToLang } from "./languages.ts";
2+
import { reactionToLang } from "./internals/languages.ts";
33
import { Logger } from "../utils/logger.ts";
44
import { FunctionSourceFile } from "../utils/function_source_file.ts";
55

@@ -10,17 +10,13 @@ export const def = DefineFunction({
1010
source_file: FunctionSourceFile(import.meta.url),
1111
input_parameters: {
1212
properties: {
13-
reaction: {
14-
type: Schema.types.string,
15-
},
13+
reaction: { type: Schema.types.string },
1614
},
1715
required: ["reaction"],
1816
},
1917
output_parameters: {
2018
properties: {
21-
lang: {
22-
type: Schema.types.string,
23-
},
19+
lang: { type: Schema.types.string },
2420
},
2521
required: [],
2622
},

functions/maintenance.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { DefineFunction, Schema, SlackFunction } from "deno-slack-sdk/mod.ts";
22
import { SlackAPI } from "deno-slack-api/mod.ts";
33
import { Logger } from "../utils/logger.ts";
44
import { FunctionSourceFile } from "../utils/function_source_file.ts";
5-
import { findTriggerToUpdate, joinAllChannels } from "./internals.ts";
5+
import {
6+
findTriggerToUpdate,
7+
joinAllChannels,
8+
} from "./internals/trigger_management.ts";
69

710
export const def = DefineFunction({
811
callback_id: "maintain-channel-memberships",

functions/setup.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
createOrUpdateTrigger,
77
findTriggerToUpdate,
88
joinAllChannels,
9-
} from "./internals.ts";
9+
} from "./internals/trigger_management.ts";
1010

1111
export const def = DefineFunction({
1212
callback_id: "manage-reaction-added-event-trigger",
@@ -15,9 +15,9 @@ export const def = DefineFunction({
1515
input_parameters: {
1616
properties: {
1717
interactivity: { type: Schema.slack.types.interactivity },
18-
workflowCallbackId: { type: Schema.types.string },
18+
reacjilatorWorkflowCallbackId: { type: Schema.types.string },
1919
},
20-
required: ["interactivity", "workflowCallbackId"],
20+
required: ["interactivity", "reacjilatorWorkflowCallbackId"],
2121
},
2222
output_parameters: {
2323
properties: {},
@@ -38,7 +38,7 @@ export default SlackFunction(def, async ({
3838
const triggerToUpdate = await findTriggerToUpdate(
3939
client,
4040
logger,
41-
inputs.workflowCallbackId,
41+
inputs.reacjilatorWorkflowCallbackId,
4242
);
4343
logger.info(`triggerToUpdate: ${JSON.stringify(triggerToUpdate)}`);
4444

@@ -62,7 +62,7 @@ export default SlackFunction(def, async ({
6262
["configure-workflow"],
6363
async ({ view, inputs, env, token }) => {
6464
const logger = Logger(env.LOG_LEVEL);
65-
const { workflowCallbackId } = inputs;
65+
const { reacjilatorWorkflowCallbackId } = inputs;
6666
const channelIds = view.state.values.block.channels.selected_channels;
6767

6868
const client = SlackAPI(token);
@@ -71,14 +71,14 @@ export default SlackFunction(def, async ({
7171
const triggerToUpdate = await findTriggerToUpdate(
7272
client,
7373
logger,
74-
inputs.workflowCallbackId,
74+
inputs.reacjilatorWorkflowCallbackId,
7575
);
7676
// If the trigger already exists, we update it.
7777
// Otherwise, we create a new one.
7878
await createOrUpdateTrigger(
7979
client,
8080
logger,
81-
workflowCallbackId,
81+
reacjilatorWorkflowCallbackId,
8282
channelIds,
8383
triggerToUpdate,
8484
);

functions/translator.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,15 @@ export const def = DefineFunction({
1111
source_file: FunctionSourceFile(import.meta.url),
1212
input_parameters: {
1313
properties: {
14-
channelId: {
15-
type: Schema.types.string,
16-
},
17-
messageTs: {
18-
type: Schema.types.string,
19-
},
20-
lang: {
21-
type: Schema.types.string,
22-
},
14+
channelId: { type: Schema.types.string },
15+
messageTs: { type: Schema.types.string },
16+
lang: { type: Schema.types.string },
2317
},
2418
required: ["channelId", "messageTs"],
2519
},
2620
output_parameters: {
2721
properties: {
28-
ts: {
29-
type: Schema.types.string,
30-
},
22+
ts: { type: Schema.types.string },
3123
},
3224
required: [],
3325
},

workflows/setup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const workflow = DefineWorkflow({
1818

1919
workflow.addStep(setupDef, {
2020
interactivity: workflow.inputs.interactivity,
21-
workflowCallbackId: reacjilatorDef.definition.callback_id,
21+
reacjilatorWorkflowCallbackId: reacjilatorDef.definition.callback_id,
2222
});
2323

2424
export default workflow;

0 commit comments

Comments
 (0)