replace setActivationStatus api with new one

This commit is contained in:
taehoon 2019-11-18 20:29:12 -05:00
parent b739edb509
commit 506822bed0
3 changed files with 11 additions and 16 deletions

View File

@ -73,7 +73,7 @@ const ModerationTools = {
toggleActivationStatus () { toggleActivationStatus () {
const store = this.$store const store = this.$store
const status = !!this.user.deactivated const status = !!this.user.deactivated
store.state.api.backendInteractor.setActivationStatus(this.user, status).then(response => { store.state.api.backendInteractor.toggleActivationStatus(this.user).then(response => {
if (!response.ok) { return } if (!response.ok) { return }
store.commit('updateActivationStatus', { user: this.user, status: status }) store.commit('updateActivationStatus', { user: this.user, status: status })
}) })

View File

@ -12,7 +12,7 @@ const CHANGE_EMAIL_URL = '/api/pleroma/change_email'
const CHANGE_PASSWORD_URL = '/api/pleroma/change_password' const CHANGE_PASSWORD_URL = '/api/pleroma/change_password'
const TAG_USER_URL = '/api/pleroma/admin/users/tag' const TAG_USER_URL = '/api/pleroma/admin/users/tag'
const PERMISSION_GROUP_URL = (screenName, right) => `/api/pleroma/admin/users/${screenName}/permission_group/${right}` const PERMISSION_GROUP_URL = (screenName, right) => `/api/pleroma/admin/users/${screenName}/permission_group/${right}`
const ACTIVATION_STATUS_URL = screenName => `/api/pleroma/admin/users/${screenName}/activation_status` const TOGGLE_ACTIVATION_URL = screenName => `/api/pleroma/admin/users/${screenName}/toggle_activation`
const ADMIN_USERS_URL = '/api/pleroma/admin/users' const ADMIN_USERS_URL = '/api/pleroma/admin/users'
const SUGGESTIONS_URL = '/api/v1/suggestions' const SUGGESTIONS_URL = '/api/v1/suggestions'
const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings' const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings'
@ -450,19 +450,14 @@ const deleteRight = ({ right, credentials, ...user }) => {
}) })
} }
const setActivationStatus = ({ status, credentials, ...user }) => { // eslint-disable-next-line camelcase
const screenName = user.screen_name const toggleActivationStatus = ({ credentials, screen_name }) => {
const body = {
status: status
}
const headers = authHeaders(credentials) const headers = authHeaders(credentials)
headers['Content-Type'] = 'application/json' headers['Content-Type'] = 'application/json'
return fetch(ACTIVATION_STATUS_URL(screenName), { return fetch(TOGGLE_ACTIVATION_URL(screen_name), {
method: 'PUT', method: 'PATCH',
headers: headers, headers: headers
body: JSON.stringify(body)
}) })
} }
@ -979,7 +974,7 @@ const apiService = {
deleteUser, deleteUser,
addRight, addRight,
deleteRight, deleteRight,
setActivationStatus, toggleActivationStatus,
register, register,
getCaptcha, getCaptcha,
updateAvatar, updateAvatar,

View File

@ -89,8 +89,8 @@ const backendInteractorService = credentials => {
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
const setActivationStatus = ({ screen_name }, status) => { const toggleActivationStatus = ({ screen_name }) => {
return apiService.setActivationStatus({ screen_name, status, credentials }) return apiService.toggleActivationStatus({ screen_name, credentials })
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
@ -191,7 +191,7 @@ const backendInteractorService = credentials => {
addRight, addRight,
deleteRight, deleteRight,
deleteUser, deleteUser,
setActivationStatus, toggleActivationStatus,
register, register,
getCaptcha, getCaptcha,
updateAvatar, updateAvatar,