added attchments
This commit is contained in:
@@ -117,6 +117,13 @@ export async function fetchPortalSummary() {
|
||||
return apiFetch('/portal/summary')
|
||||
}
|
||||
|
||||
export async function previewBbcode(body) {
|
||||
return apiFetch('/preview', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ body }),
|
||||
})
|
||||
}
|
||||
|
||||
export async function fetchSetting(key) {
|
||||
// TODO: Prefer fetchSettings() when multiple settings are needed.
|
||||
const cacheBust = Date.now()
|
||||
@@ -256,6 +263,90 @@ export async function updateThreadSolved(threadId, solved) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function listAttachmentsByThread(threadId) {
|
||||
return getCollection(`/attachments?thread=/api/threads/${threadId}`)
|
||||
}
|
||||
|
||||
export async function listAttachmentsByPost(postId) {
|
||||
return getCollection(`/attachments?post=/api/posts/${postId}`)
|
||||
}
|
||||
|
||||
export async function uploadAttachment({ threadId, postId, file }) {
|
||||
const body = new FormData()
|
||||
if (threadId) body.append('thread', `/api/threads/${threadId}`)
|
||||
if (postId) body.append('post', `/api/posts/${postId}`)
|
||||
body.append('file', file)
|
||||
return apiFetch('/attachments', {
|
||||
method: 'POST',
|
||||
body,
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteAttachment(id) {
|
||||
return apiFetch(`/attachments/${id}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
|
||||
export async function listAttachmentGroups() {
|
||||
return getCollection('/attachment-groups')
|
||||
}
|
||||
|
||||
export async function createAttachmentGroup(payload) {
|
||||
return apiFetch('/attachment-groups', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateAttachmentGroup(id, payload) {
|
||||
return apiFetch(`/attachment-groups/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteAttachmentGroup(id) {
|
||||
return apiFetch(`/attachment-groups/${id}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
|
||||
export async function reorderAttachmentGroups(parentId, orderedIds) {
|
||||
return apiFetch('/attachment-groups/reorder', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ parentId, orderedIds }),
|
||||
})
|
||||
}
|
||||
|
||||
export async function listAttachmentExtensions() {
|
||||
return getCollection('/attachment-extensions')
|
||||
}
|
||||
|
||||
export async function listAttachmentExtensionsPublic() {
|
||||
return getCollection('/attachment-extensions/public')
|
||||
}
|
||||
|
||||
export async function createAttachmentExtension(payload) {
|
||||
return apiFetch('/attachment-extensions', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateAttachmentExtension(id, payload) {
|
||||
return apiFetch(`/attachment-extensions/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteAttachmentExtension(id) {
|
||||
return apiFetch(`/attachment-extensions/${id}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
|
||||
export async function listPostsByThread(threadId) {
|
||||
return getCollection(`/posts?thread=/api/threads/${threadId}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user