mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02:00
Merge pull request #3148 from Dokploy/2938-not-all-ntfy-topics-need-access-tokens
feat: update notification handling to make accessToken optional
This commit is contained in:
@@ -103,7 +103,7 @@ export const notificationSchema = z.discriminatedUnion("type", [
|
|||||||
type: z.literal("ntfy"),
|
type: z.literal("ntfy"),
|
||||||
serverUrl: z.string().min(1, { message: "Server URL is required" }),
|
serverUrl: z.string().min(1, { message: "Server URL is required" }),
|
||||||
topic: z.string().min(1, { message: "Topic is required" }),
|
topic: z.string().min(1, { message: "Topic is required" }),
|
||||||
accessToken: z.string().min(1, { message: "Access Token is required" }),
|
accessToken: z.string().optional(),
|
||||||
priority: z.number().min(1).max(5).default(3),
|
priority: z.number().min(1).max(5).default(3),
|
||||||
})
|
})
|
||||||
.merge(notificationBaseSchema),
|
.merge(notificationBaseSchema),
|
||||||
@@ -303,7 +303,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
dokployRestart: notification.dokployRestart,
|
dokployRestart: notification.dokployRestart,
|
||||||
databaseBackup: notification.databaseBackup,
|
databaseBackup: notification.databaseBackup,
|
||||||
type: notification.notificationType,
|
type: notification.notificationType,
|
||||||
accessToken: notification.ntfy?.accessToken,
|
accessToken: notification.ntfy?.accessToken || "",
|
||||||
topic: notification.ntfy?.topic,
|
topic: notification.ntfy?.topic,
|
||||||
priority: notification.ntfy?.priority,
|
priority: notification.ntfy?.priority,
|
||||||
serverUrl: notification.ntfy?.serverUrl,
|
serverUrl: notification.ntfy?.serverUrl,
|
||||||
@@ -432,7 +432,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
dokployRestart: dokployRestart,
|
dokployRestart: dokployRestart,
|
||||||
databaseBackup: databaseBackup,
|
databaseBackup: databaseBackup,
|
||||||
serverUrl: data.serverUrl,
|
serverUrl: data.serverUrl,
|
||||||
accessToken: data.accessToken,
|
accessToken: data.accessToken || "",
|
||||||
topic: data.topic,
|
topic: data.topic,
|
||||||
priority: data.priority,
|
priority: data.priority,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
@@ -1001,8 +1001,12 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
<Input
|
<Input
|
||||||
placeholder="AzxcvbnmKjhgfdsa..."
|
placeholder="AzxcvbnmKjhgfdsa..."
|
||||||
{...field}
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
<FormDescription>
|
||||||
|
Optional. Leave blank for public topics.
|
||||||
|
</FormDescription>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
@@ -1258,7 +1262,7 @@ export const HandleNotifications = ({ notificationId }: Props) => {
|
|||||||
await testNtfyConnection({
|
await testNtfyConnection({
|
||||||
serverUrl: data.serverUrl,
|
serverUrl: data.serverUrl,
|
||||||
topic: data.topic,
|
topic: data.topic,
|
||||||
accessToken: data.accessToken,
|
accessToken: data.accessToken || "",
|
||||||
priority: data.priority,
|
priority: data.priority,
|
||||||
});
|
});
|
||||||
} else if (data.type === "lark") {
|
} else if (data.type === "lark") {
|
||||||
|
|||||||
1
apps/dokploy/drizzle/0124_certain_cloak.sql
Normal file
1
apps/dokploy/drizzle/0124_certain_cloak.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "ntfy" ALTER COLUMN "accessToken" DROP NOT NULL;
|
||||||
6831
apps/dokploy/drizzle/meta/0124_snapshot.json
Normal file
6831
apps/dokploy/drizzle/meta/0124_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -869,6 +869,13 @@
|
|||||||
"when": 1764525308939,
|
"when": 1764525308939,
|
||||||
"tag": "0123_cloudy_piledriver",
|
"tag": "0123_cloudy_piledriver",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 124,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1764571454170,
|
||||||
|
"tag": "0124_certain_cloak",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ export const ntfy = pgTable("ntfy", {
|
|||||||
.$defaultFn(() => nanoid()),
|
.$defaultFn(() => nanoid()),
|
||||||
serverUrl: text("serverUrl").notNull(),
|
serverUrl: text("serverUrl").notNull(),
|
||||||
topic: text("topic").notNull(),
|
topic: text("topic").notNull(),
|
||||||
accessToken: text("accessToken").notNull(),
|
accessToken: text("accessToken"),
|
||||||
priority: integer("priority").notNull().default(3),
|
priority: integer("priority").notNull().default(3),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ export const apiCreateNtfy = notificationsSchema
|
|||||||
.extend({
|
.extend({
|
||||||
serverUrl: z.string().min(1),
|
serverUrl: z.string().min(1),
|
||||||
topic: z.string().min(1),
|
topic: z.string().min(1),
|
||||||
accessToken: z.string().min(1),
|
accessToken: z.string().optional(),
|
||||||
priority: z.number().min(1),
|
priority: z.number().min(1),
|
||||||
})
|
})
|
||||||
.required();
|
.required();
|
||||||
@@ -395,7 +395,7 @@ export const apiSendTest = notificationsSchema
|
|||||||
serverUrl: z.string(),
|
serverUrl: z.string(),
|
||||||
topic: z.string(),
|
topic: z.string(),
|
||||||
appToken: z.string(),
|
appToken: z.string(),
|
||||||
accessToken: z.string(),
|
accessToken: z.string().optional(),
|
||||||
priority: z.number(),
|
priority: z.number(),
|
||||||
})
|
})
|
||||||
.partial();
|
.partial();
|
||||||
|
|||||||
@@ -498,7 +498,7 @@ export const createNtfyNotification = async (
|
|||||||
.values({
|
.values({
|
||||||
serverUrl: input.serverUrl,
|
serverUrl: input.serverUrl,
|
||||||
topic: input.topic,
|
topic: input.topic,
|
||||||
accessToken: input.accessToken,
|
accessToken: input.accessToken ?? null,
|
||||||
priority: input.priority,
|
priority: input.priority,
|
||||||
})
|
})
|
||||||
.returning()
|
.returning()
|
||||||
@@ -569,7 +569,7 @@ export const updateNtfyNotification = async (
|
|||||||
.set({
|
.set({
|
||||||
serverUrl: input.serverUrl,
|
serverUrl: input.serverUrl,
|
||||||
topic: input.topic,
|
topic: input.topic,
|
||||||
accessToken: input.accessToken,
|
accessToken: input.accessToken ?? null,
|
||||||
priority: input.priority,
|
priority: input.priority,
|
||||||
})
|
})
|
||||||
.where(eq(ntfy.ntfyId, input.ntfyId));
|
.where(eq(ntfy.ntfyId, input.ntfyId));
|
||||||
|
|||||||
@@ -159,7 +159,9 @@ export const sendNtfyNotification = async (
|
|||||||
const response = await fetch(`${connection.serverUrl}/${connection.topic}`, {
|
const response = await fetch(`${connection.serverUrl}/${connection.topic}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${connection.accessToken}`,
|
...(connection.accessToken && {
|
||||||
|
Authorization: `Bearer ${connection.accessToken}`,
|
||||||
|
}),
|
||||||
"X-Priority": connection.priority?.toString() || "3",
|
"X-Priority": connection.priority?.toString() || "3",
|
||||||
"X-Title": title,
|
"X-Title": title,
|
||||||
"X-Tags": tags,
|
"X-Tags": tags,
|
||||||
|
|||||||
Reference in New Issue
Block a user