feat: Convert all app files to JS
This commit is contained in:
3
packages/backend/src/apps/telegram-bot/actions/index.js
Normal file
3
packages/backend/src/apps/telegram-bot/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import sendMessage from './send-message/index.js';
|
||||
|
||||
export default [sendMessage];
|
@@ -1,3 +0,0 @@
|
||||
import sendMessage from './send-message';
|
||||
|
||||
export default [sendMessage];
|
@@ -1,5 +1,5 @@
|
||||
import qs from 'qs';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Send message',
|
||||
@@ -9,15 +9,16 @@ export default defineAction({
|
||||
{
|
||||
label: 'Chat ID',
|
||||
key: 'chatId',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Unique identifier for the target chat or username of the target channel (in the format @channelusername).',
|
||||
description:
|
||||
'Unique identifier for the target chat or username of the target channel (in the format @channelusername).',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Message text',
|
||||
key: 'text',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Text of the message to be sent, 1-4096 characters.',
|
||||
variables: true,
|
||||
@@ -25,10 +26,11 @@ export default defineAction({
|
||||
{
|
||||
label: 'Disable notification?',
|
||||
key: 'disableNotification',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
value: false,
|
||||
description: 'Sends the message silently. Users will receive a notification with no sound.',
|
||||
description:
|
||||
'Sends the message silently. Users will receive a notification with no sound.',
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
@@ -1,12 +1,12 @@
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'token',
|
||||
label: 'Bot token',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
@@ -0,0 +1,8 @@
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,9 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,6 +1,4 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
const { data } = await $.http.get('/getMe');
|
||||
const { result: me } = data;
|
||||
|
@@ -0,0 +1,15 @@
|
||||
import { URL } from 'node:url';
|
||||
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data?.token) {
|
||||
const token = $.auth.data.token;
|
||||
requestConfig.baseURL = new URL(
|
||||
`/bot${token}`,
|
||||
requestConfig.baseURL
|
||||
).toString();
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -1,13 +0,0 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
import { URL } from 'node:url';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if ($.auth.data?.token) {
|
||||
const token = $.auth.data.token as string;
|
||||
requestConfig.baseURL = (new URL(`/bot${token}`, requestConfig.baseURL)).toString();
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -1,7 +1,7 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Telegram',
|
Reference in New Issue
Block a user