From 506822bed01deb2d2fb98f511902d6801819cbd8 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Mon, 18 Nov 2019 20:29:12 -0500
Subject: [PATCH] replace setActivationStatus api with new one
---
.../moderation_tools/moderation_tools.js | 2 +-
src/services/api/api.service.js | 19 +++++++------------
.../backend_interactor_service.js | 6 +++---
3 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/src/components/moderation_tools/moderation_tools.js b/src/components/moderation_tools/moderation_tools.js
index 8aadc8c5..10a20709 100644
--- a/src/components/moderation_tools/moderation_tools.js
+++ b/src/components/moderation_tools/moderation_tools.js
@@ -73,7 +73,7 @@ const ModerationTools = {
toggleActivationStatus () {
const store = this.$store
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 }
store.commit('updateActivationStatus', { user: this.user, status: status })
})
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 7eb0547e..dbc8320e 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -12,7 +12,7 @@ const CHANGE_EMAIL_URL = '/api/pleroma/change_email'
const CHANGE_PASSWORD_URL = '/api/pleroma/change_password'
const TAG_USER_URL = '/api/pleroma/admin/users/tag'
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 SUGGESTIONS_URL = '/api/v1/suggestions'
const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings'
@@ -450,19 +450,14 @@ const deleteRight = ({ right, credentials, ...user }) => {
})
}
-const setActivationStatus = ({ status, credentials, ...user }) => {
- const screenName = user.screen_name
- const body = {
- status: status
- }
-
+// eslint-disable-next-line camelcase
+const toggleActivationStatus = ({ credentials, screen_name }) => {
const headers = authHeaders(credentials)
headers['Content-Type'] = 'application/json'
- return fetch(ACTIVATION_STATUS_URL(screenName), {
- method: 'PUT',
- headers: headers,
- body: JSON.stringify(body)
+ return fetch(TOGGLE_ACTIVATION_URL(screen_name), {
+ method: 'PATCH',
+ headers: headers
})
}
@@ -979,7 +974,7 @@ const apiService = {
deleteUser,
addRight,
deleteRight,
- setActivationStatus,
+ toggleActivationStatus,
register,
getCaptcha,
updateAvatar,
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index c16bd1f1..e0a15d3b 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -89,8 +89,8 @@ const backendInteractorService = credentials => {
}
// eslint-disable-next-line camelcase
- const setActivationStatus = ({ screen_name }, status) => {
- return apiService.setActivationStatus({ screen_name, status, credentials })
+ const toggleActivationStatus = ({ screen_name }) => {
+ return apiService.toggleActivationStatus({ screen_name, credentials })
}
// eslint-disable-next-line camelcase
@@ -191,7 +191,7 @@ const backendInteractorService = credentials => {
addRight,
deleteRight,
deleteUser,
- setActivationStatus,
+ toggleActivationStatus,
register,
getCaptcha,
updateAvatar,