Skip to content
Snippets Groups Projects
Commit 32432e1f authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Update emoji api functions

parent ee20731a
No related branches found
No related tags found
1 merge request!112Update emoji API
......@@ -2,38 +2,80 @@ import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import { baseName } from './utils'
export async function deletePack(host, token, name) {
export async function addNewEmojiFile(packName, file, shortcode, filename, host, token) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}/files`,
method: 'post',
headers: authHeaders(token),
data: {
file,
shortcode: shortcode.trim() !== '' ? shortcode : null,
filename: filename.trim() !== '' ? filename : null }
})
}
export function addressOfEmojiInPack(host, packName, name) {
return `${baseName(host)}/emoji/${packName}/${name}`
}
export async function createPack(host, token, packName) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}`,
method: 'post',
headers: authHeaders(token)
})
}
export async function deleteEmojiFile(packName, shortcode, host, token) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}/files`,
method: 'delete',
headers: authHeaders(token),
data: { shortcode }
})
}
export async function deletePack(host, token, packName) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${name}`,
url: `/api/pleroma/emoji/packs/${packName}`,
method: 'delete',
headers: authHeaders(token)
})
}
export async function reloadEmoji(host, token) {
export async function downloadFrom(host, instance, packName, as, token) {
if (as.trim() === '') {
as = null
}
return await request({
baseURL: baseName(host),
url: '/api/pleroma/admin/reload_emoji',
url: '/api/pleroma/emoji/packs/download',
method: 'post',
headers: authHeaders(token)
headers: authHeaders(token),
data: { url: baseName(instance), name: packName, as },
timeout: 0
})
}
export async function importFromFS(host, token) {
export async function fetchPack(packName, host, token) {
return await request({
baseURL: baseName(host),
url: '/api/pleroma/emoji/packs/import',
url: `/api/pleroma/emoji/packs/${packName}`,
method: 'get',
headers: authHeaders(token)
})
}
export async function createPack(host, token, name) {
export async function importFromFS(host, token) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${name}`,
method: 'post',
url: '/api/pleroma/emoji/packs/import',
method: 'get',
headers: authHeaders(token)
})
}
......@@ -55,25 +97,19 @@ export async function listRemotePacks(host, token, instance) {
})
}
export async function downloadFrom(host, instance, pack_name, as, token) {
if (as.trim() === '') {
as = null
}
export async function reloadEmoji(host, token) {
return await request({
baseURL: baseName(host),
url: '/api/pleroma/emoji/packs/download',
url: '/api/pleroma/admin/reload_emoji',
method: 'post',
headers: authHeaders(token),
data: { url: baseName(instance), name: pack_name, as },
timeout: 0
headers: authHeaders(token)
})
}
export async function savePackMetadata(host, token, name, metadata) {
export async function savePackMetadata(host, token, packName, metadata) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${name}`,
url: `/api/pleroma/emoji/packs/${packName}`,
method: 'patch',
headers: authHeaders(token),
data: { metadata },
......@@ -81,19 +117,6 @@ export async function savePackMetadata(host, token, name, metadata) {
})
}
export async function addNewEmojiFile(packName, file, shortcode, filename, host, token) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}/files`,
method: 'post',
headers: authHeaders(token),
data: {
file,
shortcode: shortcode.trim() !== '' ? shortcode : null,
filename: filename.trim() !== '' ? filename : null }
})
}
export async function updateEmojiFile(packName, shortcode, newShortcode, newFilename, force, host, token) {
return await request({
baseURL: baseName(host),
......@@ -104,18 +127,4 @@ export async function updateEmojiFile(packName, shortcode, newShortcode, newFile
})
}
export async function deleteEmojiFile(packName, shortcode, host, token) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}/files`,
method: 'delete',
headers: authHeaders(token),
data: { shortcode }
})
}
export function addressOfEmojiInPack(host, packName, name) {
return `${baseName(host)}/emoji/${packName}/${name}`
}
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment