fix(files): allow uploading to root when another user has same name (#15)
CD — Deployment / deploy (push) Successful in 43s
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:
+34
-3
@@ -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",
|
||||
})
|
||||
: "—";
|
||||
|
||||
@@ -157,6 +157,10 @@ const en: Record<string, string> = {
|
||||
"{level} · jusqu'au {date}": "{level} · until {date}",
|
||||
"Aucun autre membre à ajouter.": "No other member to add.",
|
||||
|
||||
"Modification impossible.": "Unable to edit.",
|
||||
"Épinglage impossible.": "Unable to pin.",
|
||||
"Envoi du message impossible.": "Unable to send the message.",
|
||||
|
||||
// --- Discussion de dossier --------------------------------------------
|
||||
"Compte supprimé": "Deleted account",
|
||||
"Supprimer le message": "Delete message",
|
||||
@@ -178,6 +182,16 @@ const en: Record<string, string> = {
|
||||
"Écrire un message… (Entrée pour envoyer, Maj+Entrée pour retour à la ligne)":
|
||||
"Write a message… (Enter to send, Shift+Enter for a new line)",
|
||||
"Votre message": "Your message",
|
||||
"(modifié)": "(edited)",
|
||||
"Modifier le message": "Edit message",
|
||||
"Épingler le message": "Pin message",
|
||||
"Désépingler le message": "Unpin message",
|
||||
"Messages épinglés": "Pinned messages",
|
||||
|
||||
// --- Explorateur / drag & drop -----------------------------------------
|
||||
"Déposez vos fichiers ici": "Drop your files here",
|
||||
"{count} fichier(s) déposé(s) dans {name}.": "{count} file(s) uploaded to {name}.",
|
||||
"{count} fichier(s) déposé(s) dans ce dossier.": "{count} file(s) uploaded to this folder.",
|
||||
|
||||
// --- Visionneuse -------------------------------------------------------
|
||||
"Lecture impossible.": "Unable to read.",
|
||||
|
||||
Reference in New Issue
Block a user