fix(files): allow uploading to root when another user has same name (#15)
CD — Deployment / deploy (push) Successful in 43s

Root is a personal namespace per user, so duplicate checks must scope to the
current owner when uploading at root level. Subfolders keep their existing
uniqueness rules.

Also fixed folder creation at root with the same owner scope.

---------

Co-authored-by: xEsiah <[email protected]>
Reviewed-on: #15
Reviewed-by: Esiah <[email protected]>
Co-authored-by: Gitea Actions <-[email protected]>
This commit was merged in pull request #15.
This commit is contained in:
Gitea Actions
2026-10-22 10:52:23 +00:00
committed by Esiah
co-authored by Esiah
parent cbe33bf563
commit 699c523caa
11 changed files with 713 additions and 37 deletions
+34 -3
View File
@@ -172,6 +172,8 @@ export interface ChatMessage {
last_name: string | null;
body: string;
created_at: string;
edited_at: string | null;
is_pinned: boolean;
has_avatar: boolean;
avatar_updated_at: string | null;
}
@@ -234,6 +236,12 @@ const post = <T>(path: string, payload?: unknown): Promise<T> =>
const patch = <T>(path: string, payload: unknown): Promise<T> =>
request<T>(path, { method: "PATCH", body: JSON.stringify(payload) });
const put = <T>(path: string, payload?: unknown): Promise<T> =>
request<T>(path, {
method: "PUT",
...(payload === undefined ? {} : { body: JSON.stringify(payload) }),
});
const del = <T>(path: string): Promise<T> => request<T>(path, { method: "DELETE" });
const query = (params: Record<string, string | number | null | undefined>): string => {
@@ -362,12 +370,22 @@ export const api = {
// --- Chat d'un dossier ------------------------------------------------
chatMembers: (folderId: string) =>
request<{ members: ChatMember[] }>(`/folders/${encodeURIComponent(folderId)}/chat/members`),
chatMessages: (folderId: string, after = 0, limit = 50) =>
request<{ messages: ChatMessage[] }>(
`/folders/${encodeURIComponent(folderId)}/chat/messages${query({ after, limit })}`,
chatMessages: (folderId: string, after = 0, limit = 50, editedAfter?: string | null) =>
request<{ messages: ChatMessage[]; cursor: string }>(
`/folders/${encodeURIComponent(folderId)}/chat/messages${query({ after, limit, editedAfter })}`,
),
chatSend: (folderId: string, body: string) =>
post<{ message: ChatMessage }>(`/folders/${encodeURIComponent(folderId)}/chat/messages`, { body }),
chatEditMessage: (folderId: string, id: number, body: string) =>
patch<{ message: ChatMessage }>(`/folders/${encodeURIComponent(folderId)}/chat/messages/${id}`, {
body,
}),
chatTogglePin: (folderId: string, id: number) =>
put<{ pinned: boolean }>(
`/folders/${encodeURIComponent(folderId)}/chat/messages/${id}/pin`,
),
chatPins: (folderId: string) =>
request<{ messages: ChatMessage[] }>(`/folders/${encodeURIComponent(folderId)}/chat/pins`),
chatDeleteMessage: (folderId: string, id: number) =>
del<{ ok: boolean }>(`/folders/${encodeURIComponent(folderId)}/chat/messages/${id}`),
chatUnread: () => request<{ unread: Record<string, number> }>("/chat/unread"),
@@ -434,3 +452,16 @@ export const formatBytes = (bytes: number): string => {
export const formatDate = (value: string | null): string =>
value ? new Date(value).toLocaleString(getLocale(), { dateStyle: "medium", timeStyle: "short" }) : "—";
/** Date et heure completes, avec les secondes : utilise au survol d'un mention. */
export const formatDateTimeSeconds = (value: string | null): string =>
value
? new Date(value).toLocaleString(getLocale(), {
day: "2-digit",
month: "short",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
})
: "—";