refactor: Use global output with slack actions
This commit is contained in:
@@ -21,14 +21,11 @@ const findMessage = async ($: IGlobalVariable, options: FindMessageOptions) => {
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const message: IActionOutput = {
|
||||
data: {
|
||||
raw: data?.messages.matches[0],
|
||||
},
|
||||
error: response?.httpError || (!data.ok && data),
|
||||
};
|
||||
if (!data.ok && data) {
|
||||
throw new Error(JSON.stringify(response.data));
|
||||
}
|
||||
|
||||
return message;
|
||||
$.actionOutput.data.raw = data?.messages.matches[0];
|
||||
};
|
||||
|
||||
export default findMessage;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { IGlobalVariable, IActionOutput } from '@automatisch/types';
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const postMessage = async (
|
||||
$: IGlobalVariable,
|
||||
@@ -12,18 +12,11 @@ const postMessage = async (
|
||||
|
||||
const response = await $.http.post('/chat.postMessage', params);
|
||||
|
||||
const message: IActionOutput = {
|
||||
data: {
|
||||
raw: response?.data?.message,
|
||||
},
|
||||
error: response?.httpError,
|
||||
};
|
||||
|
||||
if (response.data.ok === false) {
|
||||
message.error = response.data;
|
||||
throw new Error(JSON.stringify(response.data));
|
||||
}
|
||||
|
||||
return message;
|
||||
$.actionOutput.data.raw = response?.data?.message;
|
||||
};
|
||||
|
||||
export default postMessage;
|
||||
|
Reference in New Issue
Block a user