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

Call fetch description and migrate to db

parent 0bc114ff
No related branches found
No related tags found
1 merge request!65Update server configuration
...@@ -2,6 +2,15 @@ import request from '@/utils/request' ...@@ -2,6 +2,15 @@ import request from '@/utils/request'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import { baseName } from './utils' import { baseName } from './utils'
export async function fetchDescription(authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/config/descriptions`,
method: 'get',
headers: authHeaders(token)
})
}
export async function fetchSettings(authHost, token) { export async function fetchSettings(authHost, token) {
return await request({ return await request({
baseURL: baseName(authHost), baseURL: baseName(authHost),
...@@ -11,6 +20,15 @@ export async function fetchSettings(authHost, token) { ...@@ -11,6 +20,15 @@ export async function fetchSettings(authHost, token) {
}) })
} }
export async function migrateToDB(authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/config/migrate_to_db`,
method: 'get',
headers: authHeaders(token)
})
}
export async function updateSettings(configs, authHost, token) { export async function updateSettings(configs, authHost, token) {
return await request({ return await request({
baseURL: baseName(authHost), baseURL: baseName(authHost),
......
import { fetchSettings, updateSettings, uploadMedia } from '@/api/settings' import { fetchDescription, fetchSettings, migrateToDB, updateSettings, uploadMedia } from '@/api/settings'
import { filterIgnored, parseTuples, valueHasTuples, wrapConfig } from './normalizers' import { filterIgnored, parseTuples, valueHasTuples, wrapConfig } from './normalizers'
const settings = { const settings = {
state: { state: {
description: [],
settings: { settings: {
'activitypub': {}, ':activitypub': {},
'adapter': {}, ':adapter': {},
'admin_token': {}, ':admin_token': {},
'assets': { mascots: {}}, ':assets': { mascots: {}},
'auth': {}, ':auth': {},
'auto_linker': { opts: {}}, ':auto_linker': { opts: {}},
'backends': {}, ':backends': {},
'chat': {}, ':chat': {},
'console': { colors: {}}, ':console': { colors: {}},
'credentials': {}, ':credentials': {},
'database': {}, ':database': {},
'ecto_repos': {}, ':ecto_repos': {},
'email_notifications': { digest: {}}, ':email_notifications': { digest: {}},
'emoji': { groups: {}}, ':emoji': { groups: {}},
'enabled': {}, ':enabled': {},
'ex_syslogger': {}, ':ex_syslogger': {},
'expose': {}, ':expose': {},
'fetch_initial_posts': {}, ':fetch_initial_posts': {},
'format_encoders': {}, ':format_encoders': {},
'frontend_configurations': { pleroma_fe: {}, masto_fe: {}}, ':frontend_configurations': { pleroma_fe: {}, masto_fe: {}},
'gopher': {}, ':gopher': {},
'hackney_pools': { federation: {}, media: {}, upload: {}}, ':hackney_pools': { federation: {}, media: {}, upload: {}},
'handler': {}, ':handler': {},
'headers': {}, ':headers': {},
'http': { adapter: {}}, ':http': { adapter: {}},
'http_security': {}, ':http_security': {},
'instance': { poll_limits: {}}, ':instance': { poll_limits: {}},
'level': {}, ':level': {},
'ldap': {}, ':ldap': {},
'markup': {}, ':markup': {},
'max_age': {}, ':max_age': {},
'media_proxy': { proxy_opts: {}}, ':media_proxy': { proxy_opts: {}},
'meta': {}, ':meta': {},
'methods': {}, ':methods': {},
'mrf_hellthread': {}, ':mrf_hellthread': {},
'mrf_keyword': { replace: {}}, ':mrf_keyword': { replace: {}},
'mrf_mention': {}, ':mrf_mention': {},
'mrf_normalize_markup': {}, ':mrf_normalize_markup': {},
'mrf_rejectnonpublic': {}, ':mrf_rejectnonpublic': {},
'mrf_simple': {}, ':mrf_simple': {},
'mrf_subchain': { match_actor: {}}, ':mrf_subchain': { match_actor: {}},
'mrf_user_allowlist': {}, ':mrf_user_allowlist': {},
'mrf_vocabulary': {}, ':mrf_vocabulary': {},
'oauth2': {}, ':oauth2': {},
'password_authenticator': {}, ':password_authenticator': {},
'Pleroma.Captcha': {}, 'Pleroma.Captcha': {},
'Pleroma.Captcha.Kocaptcha': {}, 'Pleroma.Captcha.Kocaptcha': {},
'Pleroma.Emails.Mailer': {}, 'Pleroma.Emails.Mailer': {},
...@@ -67,22 +68,22 @@ const settings = { ...@@ -67,22 +68,22 @@ const settings = {
{ http: false, url: {}, render_errors: {}, pubsub: {}}, { http: false, url: {}, render_errors: {}, pubsub: {}},
'Pleroma.Web.Federator.RetryQueue': {}, 'Pleroma.Web.Federator.RetryQueue': {},
'Pleroma.Web.Metadata': {}, 'Pleroma.Web.Metadata': {},
'port': {}, ':port': {},
'priv_dir': {}, ':priv_dir': {},
'queues': {}, ':queues': {},
'rate_limit': {}, ':rate_limit': {},
'rich_media': {}, ':rich_media': {},
'suggestions': {}, ':suggestions': {},
'types': { value: {}}, ':types': { value: {}},
'Ueberauth': {}, 'Ueberauth': {},
'Ueberauth.Strategy.Facebook.OAuth': {}, 'Ueberauth.Strategy.Facebook.OAuth': {},
'Ueberauth.Strategy.Google.OAuth': {}, 'Ueberauth.Strategy.Google.OAuth': {},
'Ueberauth.Strategy.Microsoft.OAuth': {}, 'Ueberauth.Strategy.Microsoft.OAuth': {},
'Ueberauth.Strategy.Twitter.OAuth': {}, 'Ueberauth.Strategy.Twitter.OAuth': {},
'user': {}, ':user': {},
'uri_schemes': {}, ':uri_schemes': {},
'vapid_details': {}, ':vapid_details': {},
'webhook_url': {} ':webhook_url': {}
}, },
ignoredIfNotEnabled: ['enabled', 'handler', 'password_authenticator', 'port', 'priv_dir'], ignoredIfNotEnabled: ['enabled', 'handler', 'password_authenticator', 'port', 'priv_dir'],
loading: true loading: true
...@@ -91,14 +92,16 @@ const settings = { ...@@ -91,14 +92,16 @@ const settings = {
REWRITE_CONFIG: (state, { tab, data }) => { REWRITE_CONFIG: (state, { tab, data }) => {
state.settings[tab] = data state.settings[tab] = data
}, },
SET_DESCRIPTION: (state, data) => {
state.description = data
},
SET_LOADING: (state, status) => { SET_LOADING: (state, status) => {
state.loading = status state.loading = status
}, },
SET_SETTINGS: (state, data) => { SET_SETTINGS: (state, data) => {
const newSettings = data.reduce((acc, config) => { const newSettings = data.reduce((acc, { key, value }) => {
const key = config.key[0] === ':' ? config.key.substr(1) : config.key const parsedValue = valueHasTuples(key, value) ? { value } : parseTuples(value, key)
const value = valueHasTuples(key, config.value) ? { value: config.value } : parseTuples(config.value, key) acc[key] = { ...acc[key], ...parsedValue }
acc[key] = { ...acc[key], ...value }
return acc return acc
}, state.settings) }, state.settings)
state.settings = newSettings state.settings = newSettings
...@@ -115,9 +118,18 @@ const settings = { ...@@ -115,9 +118,18 @@ const settings = {
async FetchSettings({ commit, dispatch, getters }) { async FetchSettings({ commit, dispatch, getters }) {
commit('SET_LOADING', true) commit('SET_LOADING', true)
const response = await fetchSettings(getters.authHost, getters.token) const response = await fetchSettings(getters.authHost, getters.token)
const description = await fetchDescription(getters.authHost, getters.token)
if (response.data.configs.length === 0) {
dispatch('MigrateToDB')
dispatch('FetchSettings')
}
commit('SET_DESCRIPTION', description.data)
commit('SET_SETTINGS', response.data.configs) commit('SET_SETTINGS', response.data.configs)
commit('SET_LOADING', false) commit('SET_LOADING', false)
}, },
async MigrateToDB({ getters }) {
await migrateToDB(getters.authHost, getters.token)
},
RewriteConfig({ commit }, { tab, data }) { RewriteConfig({ commit }, { tab, data }) {
commit('REWRITE_CONFIG', { tab, data }) commit('REWRITE_CONFIG', { tab, data })
}, },
......
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