Skip to content

Commit

Permalink
add telegram_thread_id
Browse files Browse the repository at this point in the history
  • Loading branch information
nsano-rururu committed Dec 3, 2023
1 parent 1e24987 commit 43571b8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/config/alert/ConfigAlertTelegram.vue
Expand Up @@ -39,6 +39,11 @@
</el-radio>
</el-radio-group>
</praeco-form-item>

<praeco-form-item label="Thread Id" prop="telegramThreadId">
<el-input-number id="telegramThreadId" v-model="telegramThreadId" :disabled="viewOnly" />
<label>Unique identifier for the target thread of supergroup/forum using telegram message_thread_id.</label>
</praeco-form-item>
</div>
</template>

Expand Down Expand Up @@ -103,6 +108,18 @@ export default {
this.$store.commit('config/alert/UPDATE_TELEGRAM_PARSE_MODE', value);
}
},
telegramThreadId: {
get() {
return this.$store.state.config.alert.telegramThreadId;
},
set(value) {
this.$store.commit(
'config/alert/UPDATE_TELEGRAM_THREAD_ID',
value
);
}
},
},
methods: {
Expand Down
5 changes: 5 additions & 0 deletions src/store/config/alert.js
Expand Up @@ -345,6 +345,7 @@ function initialState() {
telegramProxyLogin: '',
telegramProxyPass: '',
telegramParseMode: 'markdown',
telegramThreadId: '',

/* Tencent SMS */
tencentSmsSecretId: '',
Expand Down Expand Up @@ -1953,6 +1954,10 @@ export default {
state.telegramParseMode = telegramParseMode;
},

UPDATE_TELEGRAM_THREAD_ID(state, telegramThreadId) {
state.telegramThreadId = telegramThreadId;
},

/* Tencent SMS */
UPDATE_TENCENT_SMS_SECRET_ID(state, tencentSmsSecretId) {
state.tencentSmsSecretId = tencentSmsSecretId;
Expand Down
5 changes: 5 additions & 0 deletions src/store/config/index.js
Expand Up @@ -327,6 +327,7 @@ export default {
commit('alert/UPDATE_TELEGRAM_PROXY', config.telegram_proxy);
commit('alert/UPDATE_TELEGRAM_PROXY_LOGIN', config.telegram_proxy_login);
commit('alert/UPDATE_TELEGRAM_PROXY_PASS', config.telegram_proxy_pass);
commit('alert/UPDATE_TELEGRAM_THREAD_ID', config.telegram_thread_id);

if (config.telegram_parse_mode) {
commit('alert/UPDATE_TELEGRAM_PARSE_MODE', config.telegram_parse_mode);
Expand Down Expand Up @@ -1851,6 +1852,10 @@ export default {
config.telegram_parse_mode = state.alert.telegramParseMode;
}

if (state.alert.telegramThreadId) {
config.telegram_thread_id = state.alert.telegramThreadId;
}

return config;
},

Expand Down
1 change: 1 addition & 0 deletions tests/unit/mockData/alert/ruleDataTelegram003.js
Expand Up @@ -23,6 +23,7 @@ telegram_proxy: hostname:8080
telegram_proxy_login: user
telegram_proxy_pass: password
telegram_room_id: http://testserver
telegram_thread_id: 123456789
timeframe:
minutes: 5
timestamp_field: '@timestamp'
Expand Down
1 change: 1 addition & 0 deletions tests/unit/specs/alert/ConfigYamlTelegram003.spec.js
Expand Up @@ -37,6 +37,7 @@ telegram_proxy: "hostname:8080"
telegram_proxy_login: "user"
telegram_proxy_pass: "password"
telegram_room_id: "http://testserver"
telegram_thread_id: 123456789
terms_size: 50
timeframe:
minutes: 5
Expand Down

0 comments on commit 43571b8

Please sign in to comment.