Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

attachments: Reuse base attachments schemas.

joseph5133f34a05c5
diff --git a/web/src/attachments.ts b/web/src/attachments.ts
new file mode 100644
index 00000000000..4c86817768a
--- /dev/null
+++ b/web/src/attachments.ts
@@ -0,0 +1,22 @@
+import {z} from "zod";
+
+const attachments_schema = z.array(
+ z.object({
+ id: z.number(),
+ name: z.string(),
+ path_id: z.string(),
+ size: z.number(),
+ create_time: z.number(),
+ messages: z.array(
+ z.object({
+ id: z.number(),
+ date_sent: z.number(),
+ }),
+ ),
+ }),
+);
+
+export const attachment_api_response_schema = z.object({
+ attachments: attachments_schema,
+ upload_space_used: z.number(),
+});
diff --git a/web/src/attachments_ui.ts b/web/src/attachments_ui.ts
index 82254e8a769..bd749bd16be 100644
--- a/web/src/attachments_ui.ts
+++ b/web/src/attachments_ui.ts
@@ -1,10 +1,11 @@
import $ from "jquery";
-import {z} from "zod";
+import type {z} from "zod";
import render_confirm_delete_attachment from "../templates/confirm_dialog/confirm_delete_attachment.hbs";
import render_settings_upload_space_stats from "../templates/settings/upload_space_stats.hbs";
import render_uploaded_files_list from "../templates/settings/uploaded_files_list.hbs";
+import {attachment_api_response_schema} from "./attachments";
import * as channel from "./channel";
import * as dialog_widget from "./dialog_widget";
import {$t, $t_html} from "./i18n";
@@ -34,25 +35,6 @@ type AttachmentEvent =
upload_space_used: number;
};
-const attachment_api_response_schema = z.object({
- attachments: z.array(
- z.object({
- id: z.number(),
- name: z.string(),
- path_id: z.string(),
- size: z.number(),
- create_time: z.number(),
- messages: z.array(
- z.object({
- id: z.number(),
- date_sent: z.number(),
- }),
- ),
- }),
- ),
- upload_space_used: z.number(),
-});
-
let attachments: Attachment[];
let upload_space_used: z.infer<typeof attachment_api_response_schema>["upload_space_used"];