Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • pleroma/admin-fe
  • linafilippova/admin-fe
  • Exilat_a_Tolosa/admin-fe
  • mkljczk/admin-fe
  • maxf/admin-fe
  • kphrx/admin-fe
  • vaartis/admin-fe
  • ELR/admin-fe
  • eugenijm/admin-fe
  • jp/admin-fe
  • mkfain/admin-fe
  • lorenzoancora/admin-fe
  • alexgleason/admin-fe
  • seanking/admin-fe
  • ilja/admin-fe
15 results
Show changes
Showing
with 638 additions and 183 deletions
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
const urls = [
'http://example.com/media/a688346.jpg',
'http://example.com/media/fb1f4d.jpg'
]
export async function listBannedUrls(page, pageSize, authHost, token) {
return Promise.resolve({ data: { page_size: 1, count: 2, urls }})
}
export async function purgeUrls(urls, ban, authHost, token) {
return Promise.resolve()
}
export async function removeBannedUrls(urls, authHost, token) {
return Promise.resolve()
}
export async function searchBannedUrls(query, page, pageSize, authHost, token) {
return Promise.resolve()
}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
export function uploadMedia({ formData, authHost }) {
return Promise.resolve()
}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
export async function fetchLog(authHost, token, params, page = 1) {
return Promise.resolve()
}
export async function fetchAdmins(authHost, token) {
return Promise.resolve()
}
export async function fetchModerators(authHost, token) {
return Promise.resolve()
}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
export async function getNodeInfo(authHost) { export async function getNodeInfo(authHost) {
const data = { const data = {
metadata: { metadata: {
......
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
export async function fetchPeers(authHost, token) {
const data = ['lain.com', 'heaven.com']
return Promise.resolve({ data })
}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
export async function fetchRelays(authHost, token) {
return Promise.resolve()
}
export async function addRelay(relay_url, authHost, token) {
return Promise.resolve()
}
export async function deleteRelay(relay_url, authHost, token) {
return Promise.resolve()
}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
const reports = [ const reports = [
{ created_at: '2019-05-21T21:35:33.000Z', account: { acct: 'benj', display_name: 'Benjamin Fame', tags: [] }, actor: { acct: 'admin' }, state: 'open', id: '2', content: 'This is a report', statuses: [] }, { created_at: '2019-05-21T21:35:33.000Z', account: { nickname: 'benjamin', tags: [] }, actor: {}, state: 'open', id: '2', content: 'This is a report', statuses: [] },
{ created_at: '2019-05-20T22:45:33.000Z', account: { acct: 'alice', display_name: 'Alice Pool', tags: [] }, actor: { acct: 'admin2' }, state: 'resolved', id: '1', content: 'Please block this user', statuses: [] }, { created_at: '2019-05-20T22:45:33.000Z', account: { nickname: 'alice', tags: [] }, actor: {}, state: 'resolved', id: '1', content: 'Please block this user', statuses: [] },
{ created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys', tags: [] }, actor: { acct: 'admin' }, state: 'closed', id: '3', content: '', statuses: [] }, { created_at: '2019-05-18T13:01:33.000Z', account: { nickname: 'nick_keys', tags: [] }, actor: {}, state: 'closed', id: '3', content: '', statuses: [] },
{ created_at: '2019-05-21T21:35:33.000Z', account: { acct: 'benj', display_name: 'Benjamin Fame', tags: [] }, actor: { acct: 'admin' }, state: 'open', id: '5', content: 'This is a report', statuses: [] }, { created_at: '2019-05-21T21:35:33.000Z', account: { nickname: 'benjamin', tags: [] }, actor: {}, state: 'open', id: '5', content: 'This is a report', statuses: [] },
{ created_at: '2019-05-20T22:45:33.000Z', account: { acct: 'alice', display_name: 'Alice Pool', tags: [] }, actor: { acct: 'admin2' }, state: 'resolved', id: '7', content: 'Please block this user', statuses: [ { created_at: '2019-05-20T22:45:33.000Z', account: { nickname: 'alice', tags: [] }, actor: {}, state: 'resolved', id: '7', content: 'Please block this user', statuses: [
{ account: { display_name: 'Alice Pool', avatar: '' }, visibility: 'public', sensitive: false, id: '11', content: 'Hey!', url: '', created_at: '2019-05-10T21:35:33.000Z' }, { account: { nickname: 'alice', avatar: '' }, visibility: 'public', sensitive: false, id: '11', content: 'Hey!', url: '', created_at: '2019-05-10T21:35:33.000Z' },
{ account: { display_name: 'Alice Pool', avatar: '' }, visibility: 'unlisted', sensitive: true, id: '10', content: 'Bye!', url: '', created_at: '2019-05-10T21:00:33.000Z' } { account: { nickname: 'alice', avatar: '' }, visibility: 'unlisted', sensitive: true, id: '10', content: 'Bye!', url: '', created_at: '2019-05-10T21:00:33.000Z' }
] }, ] },
{ created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys', tags: [] }, actor: { acct: 'admin' }, state: 'closed', id: '6', content: '', statuses: [] }, { created_at: '2019-05-18T13:01:33.000Z', account: { nickname: 'nick_keys', tags: [] }, actor: {}, state: 'closed', id: '6', content: '', statuses: [] },
{ created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys', tags: [] }, actor: { acct: 'admin' }, state: 'closed', id: '4', content: '', statuses: [] } { created_at: '2019-05-18T13:01:33.000Z', account: { nickname: 'nick_keys', tags: [] }, actor: {}, state: 'closed', id: '4', content: '', statuses: [] }
] ]
export async function fetchReports(limit, max_id, authHost, token) { export async function fetchReports(filter, page, pageSize, authHost, token) {
const paginatedReports = max_id.length > 0 ? reports.slice(5) : reports.slice(0, 5) return filter.length > 0
return Promise.resolve({ data: { reports: paginatedReports }}) ? Promise.resolve({ data: { reports: reports.filter(report => report.state === filter) }})
} : Promise.resolve({ data: { reports }})
export async function filterReports(filter, limit, max_id, authHost, token) {
const filteredReports = reports.filter(report => report.state === filter)
const paginatedReports = max_id.length > 0 ? filteredReports.slice(5) : filteredReports.slice(0, 5)
return Promise.resolve({ data: { reports: paginatedReports }})
} }
export async function changeState(state, id, authHost, token) { export async function changeState(reportsData, authHost, token) {
const report = reports.find(report => report.id === id) return Promise.resolve({ data: '' })
return Promise.resolve({ data: { ...report, state }})
} }
export async function changeStatusScope(id, sensitive, visibility, authHost, token) { export async function createNote(content, reportID, authHost, token) {
const status = reports[4].statuses[0] return Promise.resolve()
return Promise.resolve({ data: { ...status, sensitive, visibility }})
} }
export async function deleteStatus(statusId, authHost, token) { export async function deleteNote(noteID, reportID, authHost, token) {
return Promise.resolve() return Promise.resolve()
} }
// export async function changeStatusScope(id, sensitive, visibility, authHost, token) {
// const status = reports[4].statuses[0]
// return Promise.resolve({ data: { ...status, sensitive, visibility }})
// }
// export async function deleteStatus(statusId, authHost, token) {
// return Promise.resolve()
// }
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
const configsWithTagPolicy = {
configs: [{
group: ':pleroma',
key: ':mrf',
value: [
{ tuple: [':policies', ['Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy', 'Pleroma.Web.ActivityPub.MRF.TagPolicy']] },
{ tuple: [':transparency', true] },
{ tuple: [':transparency_exclusions', []] }
] },
{
group: ':pleroma',
key: ':media_proxy',
value: [
{ tuple: [':enabled', true] },
{ tuple: [':invalidation', [
{ tuple: [':provider', 'Pleroma.Web.MediaProxy.Invalidation.Script'] },
{ tuple: [':enabled', true] }
]] }
] }],
need_reboot: false
}
const configAfterUpdate = {
configs: [{
db: [':policies'],
group: ':pleroma',
key: ':mrf',
value: [{ tuple: [':policies', ['Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy', 'Pleroma.Web.ActivityPub.MRF.TagPolicy']] }]
}],
need_reboot: false
}
export async function fetchSettings(authHost, token) {
return Promise.resolve({ data: configsWithTagPolicy })
}
export async function getInstanceDocument(name, authHost, token) {
return Promise.resolve({ data: '<h1>Instance panel</h1>' })
}
export async function updateSettings(configs, authHost, token) {
return Promise.resolve({ data: configAfterUpdate })
}
export async function deleteInstanceDocument(name, authHost, token) {
return Promise.resolve()
}
export async function fetchDescription(authHost, token) {
return Promise.resolve()
}
export async function updateInstanceDocument(name, formData, authHost, token) {
return Promise.resolve()
}
export async function removeSettings(configs, authHost, token) {
return Promise.resolve()
}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
export async function changeStatusScope(id, sensitive, visibility, authHost, token) {
return Promise.resolve()
}
export async function deleteStatus(id, authHost, token) {
return Promise.resolve()
}
export async function fetchStatus(id, authHost, token) {
const data = {
account: {
id: '9n1bySks25olxWrku0',
avatar: 'http://localhost:4000/images/avi.png',
nickname: 'dolin',
tags: ['mrf_tag:media-strip', 'mrf_tag:sandbox', 'mrf_tag:disable-any-subscription', 'mrf_tag:media-force-nsfw'],
url: 'http://localhost:4000/users/dolin'
},
content: 'pizza makes everything better',
created_at: '2020-05-22T17:34:34.000Z',
id: '9vJOO3iFPyjNaEhJ5s',
media_attachments: [],
poll: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
url: 'http://localhost:4000/notice/9vJOO3iFPyjNaEhJ5s'
}
return Promise.resolve({ data })
}
export async function fetchStatusesByInstance({ instance, authHost, token, pageSize, page }) {
let data
if (pageSize === 1) {
data = page === 1 || page === 2
? [{
'account': {
'avatar': 'http://localhost:4000/images/avi.png',
'nickname': 'sky',
'url': 'http://localhost:4000/users/sky'
},
'content': 'A nice young couple contacted us from Brazil to decorate their newly acquired apartment.',
'created_at': '2020-01-31T18:20:01.000Z',
'id': '9rZIr0Jzao5Gjgfmro',
'sensitive': false,
'url': 'http://localhost:4000/objects/7af9abbd-fb6c-4318-aeb7-6636c138ac98',
'visibility': 'unlisted'
}]
: []
} else {
data = [
{
'account': {
'avatar': 'http://localhost:4000/images/avi.png',
'nickname': 'sky',
'url': 'http://localhost:4000/users/sky'
},
'content': 'i love parks&rec',
'created_at': '2020-04-12T18:20:01.000Z',
'id': 'o5Gjgfmro9rZIr0Jza',
'sensitive': false,
'url': 'http://localhost:4000/objects/7af9abbd-aeb7-6636c138ac98-fb6c-4318',
'visibility': 'unlisted'
},
{
'account': {
'avatar': 'http://localhost:4000/images/avi.png',
'nickname': 'sky',
'url': 'http://localhost:4000/users/sky'
},
'content': 'the happiest man ever',
'created_at': '2019-11-23T12:56:18.000Z',
'id': '9pFoVfWMU3A96Rzq3k',
'sensitive': false,
'url': 'http://localhost:4000/objects/449c90fe-c457-4c64-baf2-fe6d0a59ca25',
'visibility': 'unlisted'
}]
}
return Promise.resolve({ data })
}
export async function fetchStatusesCount(instance, authHost, token) {
const data = instance === 'heaven.com'
? {
'status_visibility':
{ 'direct': 1, 'private': 2, 'public': 3, 'unlisted': 0 }
}
: {
'status_visibility':
{ 'direct': 4, 'private': 10, 'public': 4, 'unlisted': 10 }
}
return Promise.resolve({ data })
}
export async function fetchStatuses({ godmode, localOnly, authHost, token, pageSize, page }) {
return Promise.resolve()
}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
import userChats from './chat'
export let users = [ export let users = [
{ active: true, deactivated: false, id: '2', nickname: 'allis', local: true, external: false, roles: { admin: true, moderator: false }, tags: [] }, { is_confirmed: true, is_approved: true, is_active: true, id: '2', nickname: 'allis', local: true, external: false, roles: { admin: true, moderator: false }, tags: [], actor_type: 'Person' },
{ active: true, deactivated: false, id: '10', nickname: 'bob', local: false, external: true, roles: { admin: false, moderator: false }, tags: ['sandbox'] }, { is_confirmed: true, is_approved: true, is_active: true, id: '10', nickname: 'bob', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['mrf_tag:sandbox'], actor_type: 'Person' },
{ active: false, deactivated: true, id: 'abc', nickname: 'john', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['strip_media'] } { is_confirmed: true, is_approved: false, is_active: true, id: '567', nickname: 'ded', local: false, external: true, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Person' },
{ is_confirmed: true, is_approved: true, is_active: false, id: 'abc', nickname: 'john', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['mrf_tag:media-strip'], actor_type: 'Person' },
{ is_confirmed: true, is_approved: false, is_active: true, id: '100', nickname: 'sally', local: true, external: false, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Service' },
{ is_confirmed: true, is_approved: false, is_active: true, id: '123', nickname: 'bot', local: true, external: false, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Application' }
]
const userProfile = { avatar: 'avatar.jpg', nickname: 'allis', id: '2', tags: [], roles: { admin: true, moderator: false }, local: true, external: false }
const userStatuses = [
{ account: { id: '9n1bySks25olxWrku0', nickname: 'dolin' }, content: 'pizza makes everything better', id: '9vJOO3iFPyjNaEhJ5s', created_at: '2020-05-22T17:34:34.000Z', visibility: 'public' },
{ account: { id: '9n1bySks25olxWrku0', nickname: 'dolin' }, content: 'pizza time', id: '9vJPD5XKOdzQ0bvGLY', created_at: '2020-05-22T17:34:34.000Z', visibility: 'public' },
{ account: { id: '9n1bySks25olxWrku0', nickname: 'dolin' }, content: 'what is yout favorite pizza?', id: '9jop82OBXeFPYulVjM', created_at: '2020-05-22T17:34:34.000Z', visibility: 'public' }
] ]
const filterUsers = (str) => { export async function fetchUser(id, authHost, token) {
const filters = str.split(',').filter(item => item.length > 0) return Promise.resolve({ data: userProfile })
if (filters.length === 0) { }
return users
} export async function fetchUserCredentials(nickname, authHost, token) {
const applyFilters = (acc, filters, users) => { return Promise.resolve({ data: {}})
if (filters.length === 0) { }
return acc
} export async function fetchUsers(filters, actorTypeFilters, authHost, token, page = 1) {
const filteredUsers = users.filter(user => user[filters[0]])
const newAcc = [...filteredUsers]
return applyFilters(newAcc, filters.slice(1), filteredUsers)
}
return applyFilters([], filters, users)
}
export async function fetchUsers(filters, authHost, token, page = 1) {
const filteredUsers = filterUsers(filters)
return Promise.resolve({ data: { return Promise.resolve({ data: {
users: filteredUsers, users,
count: filteredUsers.length, count: users.length,
page_size: 50 page_size: 50
}}) }})
} }
export async function getPasswordResetToken(nickname, authHost, token) { export async function fetchUserStatuses(id, authHost, godmode, token) {
return Promise.resolve({ data: { token: 'g05lxnBJQnL', link: 'http://url/api/pleroma/password_reset/g05lxnBJQnL' }}) return Promise.resolve({ data: userStatuses })
}
export async function fetchUserChats(id, authHost, godmode, token) {
return Promise.resolve({ data: userChats })
} }
export async function toggleUserActivation(nickname, authHost, token) { export async function getPasswordResetToken(nickname, authHost, token) {
const response = users.find(user => user.nickname === nickname) return Promise.resolve({ data: { token: 'g05lxnBJQnL', link: 'http://url/api/pleroma/password_reset/g05lxnBJQnL' }})
return Promise.resolve({ data: { ...response, deactivated: !response.deactivated }})
} }
export async function searchUsers(query, filters, authHost, token, page = 1) { export async function searchUsers(query, filters, actorTypeFilters, authHost, token, page = 1) {
const filteredUsers = filterUsers(filters) const response = users.filter(user => user.nickname === query)
const response = filteredUsers.filter(user => user.nickname === query)
return Promise.resolve({ data: { return Promise.resolve({ data: {
users: response, users: response,
count: response.length, count: response.length,
...@@ -48,21 +57,45 @@ export async function searchUsers(query, filters, authHost, token, page = 1) { ...@@ -48,21 +57,45 @@ export async function searchUsers(query, filters, authHost, token, page = 1) {
}}) }})
} }
export async function addRight(nickname, right, authHost, token) { export async function activateUsers(nicknames, authHost, token) {
const response = nicknames.map(nickname => {
const currentUser = users.find(user => user.nickname === nickname)
return { ...currentUser, is_active: true }
})
return Promise.resolve({ data: response })
}
export async function addRight(nicknames, right, authHost, token) {
return Promise.resolve({ data: return Promise.resolve({ data:
{ [`is_${right}`]: true } { [`is_${right}`]: true }
}) })
} }
export async function deactivateUsers(nicknames, authHost, token) {
const response = nicknames.map(nickname => {
const currentUser = users.find(user => user.nickname === nickname)
return { ...currentUser, is_active: false }
})
return Promise.resolve({ data: response })
}
export async function approveUserAccount(nicknames, authHost, token) {
const response = nicknames.map(nickname => {
const currentUser = users.find(user => user.nickname === nickname)
return { ...currentUser, is_approved: true }
})
return Promise.resolve({ data: response })
}
export async function deleteRight(nickname, right, authHost, token) { export async function deleteRight(nickname, right, authHost, token) {
return Promise.resolve({ data: return Promise.resolve({ data:
{ [`is_${right}`]: false } { [`is_${right}`]: false }
}) })
} }
export async function deleteUser(nickname, authHost, token) { export async function deleteUsers(nicknames, authHost, token) {
return Promise.resolve({ data: return Promise.resolve({ data:
nickname nicknames
}) })
} }
...@@ -75,7 +108,27 @@ export async function untagUser(nickname, tag, authHost, token) { ...@@ -75,7 +108,27 @@ export async function untagUser(nickname, tag, authHost, token) {
} }
export async function createNewAccount(nickname, email, password, authHost, token) { export async function createNewAccount(nickname, email, password, authHost, token) {
const newUser = { active: true, deactivated: false, id: '15', nickname, local: true, external: false, roles: { admin: false, moderator: false }, tags: [] } const newUser = { active: true, is_active: true, id: '15', nickname, local: true, external: false, roles: { admin: false, moderator: false }, tags: [] }
users = [...users, newUser] users = [...users, newUser]
return Promise.resolve() return Promise.resolve()
} }
export async function updateUserCredentials(nickname, credentials, authHost, token) {
return Promise.resolve()
}
export async function disableMfa(nickname, authHost, token) {
return Promise.resolve()
}
export async function forcePasswordReset(nicknames, authHost, token) {
return Promise.resolve()
}
export async function confirmUserEmail(nicknames, authHost, token) {
return Promise.resolve()
}
export async function resendConfirmationEmail(nicknames, authHost, token) {
return Promise.resolve()
}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import { baseName } from './utils'
export async function needReboot(authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/need_reboot`,
method: 'get',
headers: authHeaders(token)
})
}
export async function restartApp(authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/restart`,
method: 'get',
headers: authHeaders(token)
})
}
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import { baseName } from './utils'
export async function deleteChatMessage(chat_id, message_id, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/chats/${chat_id}/messages/${message_id}`,
method: 'delete',
headers: authHeaders(token)
})
}
export async function fetchChat(id, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/chats/${id}`,
method: 'get',
headers: authHeaders(token)
})
}
export async function fetchChatMessages(id, maxId, authHost, token) {
const url = maxId
? `/api/pleroma/admin/chats/${id}/messages?max_id=${maxId}`
: `/api/pleroma/admin/chats/${id}/messages`
return await request({
baseURL: baseName(authHost),
url,
method: 'get',
headers: authHeaders(token)
})
}
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
import request from '@/utils/request' import request from '@/utils/request'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import { baseName } from './utils' import { baseName } from './utils'
import _ from 'lodash' export async function addNewEmojiFile(packName, file, shortcode, filename, host, token) {
const data = new FormData()
if (filename.trim() !== '') {
data.set('filename', filename)
}
if (shortcode.trim() !== '') {
data.set('shortcode', shortcode)
}
data.set('file', file)
export async function deletePack(host, token, name) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${name}`, url: `/api/pleroma/emoji/packs/files?name=${packName}`,
method: 'delete', method: 'post',
headers: authHeaders(token) headers: authHeaders(token),
data
}) })
} }
export async function reloadEmoji(host, token) { export function addressOfEmojiInPack(host, packName, name) {
return `${baseName(host)}/emoji/${encodeUri(packName)}/${name}`
}
export async function createPack(host, token, packName) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: '/api/pleroma/admin/reload_emoji', url: `/api/pleroma/emoji/pack?name=${packName}`,
method: 'post', method: 'post',
headers: authHeaders(token) headers: authHeaders(token)
}) })
} }
export async function importFromFS(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/import_from_fs', url: `/api/pleroma/emoji/packs/files?name=${packName}&shortcode=${shortcode}`,
method: 'post', method: 'delete',
headers: authHeaders(token) headers: authHeaders(token)
}) })
} }
export async function createPack(host, token, name) { export async function deletePack(host, token, packName) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${name}`, url: `/api/pleroma/emoji/pack?name=${packName}`,
method: 'put', method: 'delete',
headers: authHeaders(token) headers: authHeaders(token)
}) })
} }
export async function listPacks(host) { export async function downloadFrom(instanceAddress, packName, as, host, token) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/`, url: '/api/pleroma/emoji/packs/download',
method: 'get' method: 'post',
headers: authHeaders(token),
data: as.trim() === ''
? { url: baseName(instanceAddress), name: packName }
: { url: baseName(instanceAddress), name: packName, as },
timeout: 0
}) })
} }
export async function listRemotePacks(host, token, instance) { 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/list_from`, url: `/api/pleroma/emoji/pack?name=${packName}&page=${page}&page_size=${pageSize}`,
method: 'post', method: 'get',
headers: authHeaders(token), headers: authHeaders(token)
data: { instance_address: baseName(instance) }
}) })
} }
export async function downloadFrom(host, instance_address, pack_name, as, token) { export async function importFromFS(host, token) {
if (as.trim() === '') {
as = null
}
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: '/api/pleroma/emoji/packs/download_from', url: '/api/pleroma/emoji/packs/import',
method: 'post', method: 'get',
headers: authHeaders(token), headers: authHeaders(token)
data: { instance_address: baseName(instance_address), pack_name, as },
timeout: 0
}) })
} }
export async function savePackMetadata(host, token, name, new_data) { export async function listPacks(page, pageSize, host, token) {
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${name}/update_metadata`, url: `/api/pleroma/emoji/packs?page=${page}&page_size=${pageSize}`,
method: 'post', method: 'get',
headers: authHeaders(token), headers: authHeaders(token)
data: { name, new_data },
timeout: 0 // This might take a long time
}) })
} }
function fileUpdateFormData(d) { export async function listRemotePacks(instance, page, pageSize, host, token) {
const data = new FormData() return await request({
baseURL: baseName(host),
_.each(d, (v, k) => { url: `/api/pleroma/emoji/packs/remote?url=${baseName(instance)}&page=${page}&page_size=${pageSize}`,
data.set(k, v) method: 'get',
headers: authHeaders(token)
}) })
return data
} }
export async function updatePackFile(host, token, args) { export async function reloadEmoji(host, token) {
let data = null
switch (args.action) {
case 'add': {
const { shortcode, file, fileName } = args
data = fileUpdateFormData({
action: 'add',
shortcode: shortcode,
file: file
})
if (fileName.trim() !== '') {
data.set('filename', fileName)
}
break
}
case 'update': {
const { oldName, newName, newFilename } = args
data = fileUpdateFormData({
action: 'update',
shortcode: oldName,
new_shortcode: newName,
new_filename: newFilename
})
break
}
case 'remove': {
const { name } = args
data = fileUpdateFormData({
action: 'remove',
shortcode: name
})
break
}
}
const { packName } = args
return await request({ return await request({
baseURL: baseName(host), baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}/update_file`, url: '/api/pleroma/admin/reload_emoji',
method: 'post', method: 'post',
headers: authHeaders(token)
})
}
export async function savePackMetadata(host, token, packName, metadata) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/pack?name=${packName}`,
method: 'patch',
headers: authHeaders(token), headers: authHeaders(token),
data: data, data: { metadata },
timeout: 0 timeout: 0 // This might take a long time
}) })
} }
export function addressOfEmojiInPack(host, packName, name) { export async function updateEmojiFile(packName, shortcode, newShortcode, newFilename, force, host, token) {
return `${baseName(host)}/emoji/${packName}/${name}` return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/files?name=${packName}`,
method: 'patch',
headers: authHeaders(token),
data: { shortcode, new_shortcode: newShortcode, new_filename: newFilename, force }
})
} }
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {} const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
const encodeUri = (name) => encodeURIComponent(name)
export const initialSettings = [
{
group: 'pleroma',
key: ':instance',
value: [
{ 'tuple': [':name', 'Pleroma'] },
{ 'tuple': [':email', 'example@example.com'] },
{ 'tuple': [':notify_email', 'noreply@example.com'] },
{ 'tuple': [':description', 'A Pleroma instance, an alternative fediverse server'] },
{ 'tuple': [':limit', 5000] },
{ 'tuple': [':remote_limit', 100000] },
{ 'tuple': [':upload_limit', 16 * 1048576] },
{ 'tuple': [':avatar_upload_limit', 2 * 1048576] },
{ 'tuple': [':background_upload_limit', 4 * 1048576] },
{ 'tuple': [':banner_upload_limit', 4 * 1048576] },
{ 'tuple': [':poll_limits', [
{ 'tuple': [':max_options', 20] },
{ 'tuple': [':max_option_chars', 200] },
{ 'tuple': [':min_expiration', 0] },
{ 'tuple': [':max_expiration', 365 * 86400] }
]] },
{ 'tuple': [':registrations_open', true] },
{ 'tuple': [':invites_enabled', false] },
{ 'tuple': [':account_activation_required', false] },
{ 'tuple': [':federating', true] },
{ 'tuple': [':federation_reachability_timeout_days', 7] },
{ 'tuple':
[':federation_publisher_modules', ['Pleroma.Web.ActivityPub.Publisher', 'Pleroma.Web.Websub', 'Pleroma.Web.Salmon']] },
{ 'tuple': [':allow_relay', true] },
{ 'tuple': [':rewrite_policy', 'Pleroma.Web.ActivityPub.MRF.NoOpPolicy'] },
{ 'tuple': [':public', true] },
{ 'tuple': [':managed_config', true] },
{ 'tuple': [':static_dir', 'instance/static/'] },
{ 'tuple': [':allowed_post_formats', ['text/plain', 'text/html', 'text/markdown', 'text/bbcode']] },
{ 'tuple': [':mrf_transparency', true] },
{ 'tuple': [':extended_nickname_format', false] },
{ 'tuple': [':max_pinned_statuses', 1] },
{ 'tuple': [':no_attachment_links', false] },
{ 'tuple': [':max_report_comment_size', 1000] },
{ 'tuple': [':safe_dm_mentions', false] },
{ 'tuple': [':healthcheck', false] },
{ 'tuple': [':remote_post_retention_days', 90] },
{ 'tuple': [':skip_thread_containment', true] },
{ 'tuple': [':limit_to_local_content', ':unauthenticated'] },
{ 'tuple': [':dynamic_configuration', true] },
{ 'tuple': [':max_account_fields', 10] },
{ 'tuple': [':max_remote_account_fields', 20] },
{ 'tuple': [':account_field_name_length', 255] },
{ 'tuple': [':account_field_value_length', 255] },
{ 'tuple': [':external_user_synchronization', true] },
{ 'tuple': [':user_bio_length', 5000] },
{ 'tuple': [':user_name_length', 100] }
]
},
{
group: 'mime',
key: ':types',
value: {
'application/activity+json': ['activity+json'],
'application/jrd+json': ['jrd+json'],
'application/ld+json': ['activity+json'],
'application/xml': ['xml'],
'application/xrd+xml': ['xrd+xml']
}
},
{
group: 'cors_plug',
key: ':max_age',
value: 86400
},
{
group: 'cors_plug',
key: ':methods',
value: ['POST', 'PUT', 'DELETE', 'GET', 'PATCH', 'OPTIONS']
},
{
group: 'cors_plug',
key: ':expose',
value: [
'Link',
'X-RateLimit-Reset',
'X-RateLimit-Limit',
'X-RateLimit-Remaining',
'X-Request-Id',
'Idempotency-Key'
]
},
{
group: 'cors_plug',
key: ':credentials',
value: true
},
{
group: 'cors_plug',
key: ':headers',
value: ['Authorization', 'Content-Type', 'Idempotency-Key']
},
{
group: 'tesla',
key: ':adapter',
value: 'Tesla.Adapter.Hackney'
},
{
group: 'pleroma',
key: ':markup',
value: [
{ 'tuple': [':allow_inline_images', true] },
{ 'tuple': [':allow_headings', false] },
{ 'tuple': [':allow_tables', false] },
{ 'tuple': [':allow_fonts', false] },
{ 'tuple': [':scrub_policy', [
'Pleroma.HTML.Transform.MediaProxy',
'Pleroma.HTML.Scrubber.Default'
]] }
]
}
]
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
import request from '@/utils/request' import request from '@/utils/request'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import { baseName } from './utils' import { baseName } from './utils'
...@@ -13,14 +16,13 @@ export async function generateInviteToken(max_use, expires_at, authHost, token) ...@@ -13,14 +16,13 @@ export async function generateInviteToken(max_use, expires_at, authHost, token)
} }
export async function inviteViaEmail(email, name, authHost, token) { export async function inviteViaEmail(email, name, authHost, token) {
const url = name.length > 0 const data = name.length > 0 ? { email, name } : { email }
? `/api/pleroma/admin/users/email_invite?email=${email}&name=${name}`
: `/api/pleroma/admin/users/email_invite?email=${email}`
return await request({ return await request({
baseURL: baseName(authHost), baseURL: baseName(authHost),
url, url: '/api/pleroma/admin/users/email_invite',
method: 'post', method: 'post',
headers: authHeaders(token) headers: authHeaders(token),
data
}) })
} }
......
// SPDX-FileCopyrightText: 2017-2019 PanJiaChen <https://github.com/PanJiaChen/vue-element-admin>
// SPDX-License-Identifier: MIT
//
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
import request from '@/utils/request' import request from '@/utils/request'
import { baseName } from './utils' import { baseName } from './utils'
...@@ -9,7 +15,7 @@ export async function loginByUsername(username, password, authHost) { ...@@ -9,7 +15,7 @@ export async function loginByUsername(username, password, authHost) {
data: { data: {
client_name: `AdminFE_${Math.random()}`, client_name: `AdminFE_${Math.random()}`,
redirect_uris: `${window.location.origin}/oauth-callback`, redirect_uris: `${window.location.origin}/oauth-callback`,
scopes: 'read write follow' scopes: 'read write follow push admin'
} }
}) })
......
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import { baseName } from './utils'
export async function listBannedUrls(page, pageSize, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/media_proxy_caches?page=${page}&page_size=${pageSize}`,
method: 'get',
headers: authHeaders(token)
})
}
export async function purgeUrls(urls, ban, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/media_proxy_caches/purge`,
method: 'post',
headers: authHeaders(token),
data: { urls, ban }
})
}
export async function removeBannedUrls(urls, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/media_proxy_caches/delete`,
method: 'post',
headers: authHeaders(token),
data: { urls }
})
}
export async function searchBannedUrls(query, page, pageSize, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/media_proxy_caches?query=${query}&page=${page}&page_size=${pageSize}`,
method: 'get',
headers: authHeaders(token)
})
}
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
import { getToken } from '@/utils/auth'
import { baseName } from './utils'
const UPLOAD_URL = '/api/v1/media'
export function uploadMedia({ formData, authHost }) {
const url = baseName(authHost) + UPLOAD_URL
return fetch(url, {
body: formData,
method: 'POST',
headers: authHeaders()
})
.then((data) => data.json())
}
const authHeaders = () => {
return { 'Authorization': `Bearer ${getToken()}` }
}
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
import _ from 'lodash' import _ from 'lodash'
import request from '@/utils/request' import request from '@/utils/request'
......
// SPDX-FileCopyrightText: 2019-2022 Pleroma Authors <https://pleroma.social>
// SPDX-License-Identifier: AGPL-3.0-only
import request from '@/utils/request' import request from '@/utils/request'
import { baseName } from './utils' import { baseName } from './utils'
......