Skip to content

Commit 905b828

Browse files
authored
fix crontab task (#19)
1 parent 19ae5b0 commit 905b828

2 files changed

Lines changed: 90 additions & 57 deletions

File tree

electron/main/ipc-handlers.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ function transformCronJob(job: GatewayCronJob) {
150150
// Build lastRun from state
151151
const lastRun = job.state?.lastRunAtMs
152152
? {
153-
time: new Date(job.state.lastRunAtMs).toISOString(),
154-
success: job.state.lastStatus === 'ok',
155-
error: job.state.lastError,
156-
duration: job.state.lastDurationMs,
157-
}
153+
time: new Date(job.state.lastRunAtMs).toISOString(),
154+
success: job.state.lastStatus === 'ok',
155+
error: job.state.lastError,
156+
duration: job.state.lastDurationMs,
157+
}
158158
: undefined;
159159

160160
// Build nextRun from state
@@ -208,6 +208,12 @@ function registerCronHandlers(gatewayManager: GatewayManager): void {
208208
}) => {
209209
try {
210210
// Transform frontend input to Gateway cron.add format
211+
// For Discord, the recipient must be prefixed with "channel:" or "user:"
212+
const recipientId = input.target.channelId;
213+
const deliveryTo = input.target.channelType === 'discord' && recipientId
214+
? `channel:${recipientId}`
215+
: recipientId;
216+
211217
const gatewayInput = {
212218
name: input.name,
213219
schedule: { kind: 'cron', expr: input.schedule },
@@ -218,6 +224,7 @@ function registerCronHandlers(gatewayManager: GatewayManager): void {
218224
delivery: {
219225
mode: 'announce',
220226
channel: input.target.channelType,
227+
to: deliveryTo,
221228
},
222229
};
223230
const result = await gatewayManager.rpc('cron.add', gatewayInput);

0 commit comments

Comments
 (0)