Update API urls to support special chars in pack names

This commit is contained in:
Angelina Filippova 2020-08-16 21:37:46 +03:00
parent f0e0047e92
commit 462ca3bf4b

View file

@ -14,7 +14,7 @@ export async function addNewEmojiFile(packName, file, shortcode, filename, host,
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}/files`, url: `/api/pleroma/emoji/packs/files?name=${packName}`,
method: 'post', method: 'post',
headers: authHeaders(token), headers: authHeaders(token),
data data
@ -28,7 +28,7 @@ export function addressOfEmojiInPack(host, packName, name) {
export async function createPack(host, token, packName) { export async function createPack(host, token, packName) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}`, url: `/api/pleroma/emoji/packs/create?name=${packName}`,
method: 'post', method: 'post',
headers: authHeaders(token) headers: authHeaders(token)
}) })
@ -37,7 +37,7 @@ export async function createPack(host, token, packName) {
export async function deleteEmojiFile(packName, shortcode, host, token) { export async function deleteEmojiFile(packName, shortcode, host, token) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}/files?shortcode=${shortcode}`, url: `/api/pleroma/emoji/packs/files?name=${packName}&shortcode=${shortcode}`,
method: 'delete', method: 'delete',
headers: authHeaders(token) headers: authHeaders(token)
}) })
@ -46,7 +46,7 @@ export async function deleteEmojiFile(packName, shortcode, host, token) {
export async function deletePack(host, token, packName) { export async function deletePack(host, token, packName) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}`, url: `/api/pleroma/emoji/packs/delete?name=${packName}`,
method: 'delete', method: 'delete',
headers: authHeaders(token) headers: authHeaders(token)
}) })
@ -68,7 +68,7 @@ export async function downloadFrom(instanceAddress, packName, as, host, token) {
export async function fetchPack(packName, page, pageSize, host, token) { export async function fetchPack(packName, page, pageSize, host, token) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}?page=${page}&page_size=${pageSize}`, url: `/api/pleroma/emoji/packs/show?name=${packName}&page=${page}&page_size=${pageSize}`,
method: 'get', method: 'get',
headers: authHeaders(token) headers: authHeaders(token)
}) })
@ -113,7 +113,7 @@ export async function reloadEmoji(host, token) {
export async function savePackMetadata(host, token, packName, metadata) { export async function savePackMetadata(host, token, packName, metadata) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}`, url: `/api/pleroma/emoji/packs/update?name=${packName}`,
method: 'patch', method: 'patch',
headers: authHeaders(token), headers: authHeaders(token),
data: { metadata }, data: { metadata },
@ -124,7 +124,7 @@ export async function savePackMetadata(host, token, packName, metadata) {
export async function updateEmojiFile(packName, shortcode, newShortcode, newFilename, force, host, token) { export async function updateEmojiFile(packName, shortcode, newShortcode, newFilename, force, host, token) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}/files`, url: `/api/pleroma/emoji/packs/files?name=${packName}`,
method: 'patch', method: 'patch',
headers: authHeaders(token), headers: authHeaders(token),
data: { shortcode, new_shortcode: newShortcode, new_filename: newFilename, force } data: { shortcode, new_shortcode: newShortcode, new_filename: newFilename, force }