Fix disabled subscriptions still updating tasks

- Filter setSshConfig() to only configure SSH keys for enabled subscriptions
- Remove SSH keys when subscriptions are disabled
- This prevents disabled subscriptions from running scheduled tasks

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-11-20 15:50:35 +00:00
parent 99064bde10
commit 87a1a3d2eb

View File

@ -112,7 +112,9 @@ export default class SubscriptionService {
}
public async setSshConfig() {
const docs = await SubscriptionModel.findAll();
const docs = await SubscriptionModel.findAll({
where: { is_disabled: 0 },
});
await this.sshKeyService.setSshConfig(docs);
}
@ -346,6 +348,14 @@ export default class SubscriptionService {
public async disabled(ids: number[]) {
await SubscriptionModel.update({ is_disabled: 1 }, { where: { id: ids } });
const docs = await SubscriptionModel.findAll({ where: { id: ids } });
// Remove SSH keys for disabled subscriptions
for (const doc of docs) {
if (doc.type === 'private-repo' && doc.pull_type === 'ssh-key') {
const { alias } = doc;
const { host } = formatUrl(doc);
await this.sshKeyService.removeSSHKey(alias, host, doc.proxy);
}
}
await this.setSshConfig();
for (const doc of docs) {
await this.handleTask(doc.get({ plain: true }), false);