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 data = response.data;
|
||||||
|
|
||||||
const message: IActionOutput = {
|
if (!data.ok && data) {
|
||||||
data: {
|
throw new Error(JSON.stringify(response.data));
|
||||||
raw: data?.messages.matches[0],
|
}
|
||||||
},
|
|
||||||
error: response?.httpError || (!data.ok && data),
|
|
||||||
};
|
|
||||||
|
|
||||||
return message;
|
$.actionOutput.data.raw = data?.messages.matches[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default findMessage;
|
export default findMessage;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { IGlobalVariable, IActionOutput } from '@automatisch/types';
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
|
||||||
const postMessage = async (
|
const postMessage = async (
|
||||||
$: IGlobalVariable,
|
$: IGlobalVariable,
|
||||||
@@ -12,18 +12,11 @@ const postMessage = async (
|
|||||||
|
|
||||||
const response = await $.http.post('/chat.postMessage', params);
|
const response = await $.http.post('/chat.postMessage', params);
|
||||||
|
|
||||||
const message: IActionOutput = {
|
|
||||||
data: {
|
|
||||||
raw: response?.data?.message,
|
|
||||||
},
|
|
||||||
error: response?.httpError,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (response.data.ok === false) {
|
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;
|
export default postMessage;
|
||||||
|
Reference in New Issue
Block a user