diff options
| author | HJ <30-hj@users.noreply.git.pleroma.social> | 2019-12-18 00:51:41 +0000 |
|---|---|---|
| committer | HJ <30-hj@users.noreply.git.pleroma.social> | 2019-12-18 00:51:41 +0000 |
| commit | f7029a27eb9def00c80929b2c2cfb1d22d29bbfe (patch) | |
| tree | 5b4c4940b670921e36f574e61167144dec9908c8 /src/services/api | |
| parent | b739edb5090a81f477cb78081f40504a3e341abd (diff) | |
| parent | 4e4c4af422c400d016e4605f8bcf699f7154a8b4 (diff) | |
Merge branch '716' into 'develop'
Fix "Deactivation of remote accounts from frontend does not work"
Closes #716
See merge request pleroma/pleroma-fe!1006
Diffstat (limited to 'src/services/api')
| -rw-r--r-- | src/services/api/api.service.js | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 7eb0547e..a69fa53c 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -1,4 +1,4 @@ -import { each, map, concat, last } from 'lodash' +import { each, map, concat, last, get } from 'lodash' import { parseStatus, parseUser, parseNotification, parseAttachment } from '../entity_normalizer/entity_normalizer.service.js' import 'whatwg-fetch' import { RegistrationError, StatusCodeError } from '../errors/errors' @@ -12,7 +12,8 @@ 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 ACTIVATE_USER_URL = '/api/pleroma/admin/users/activate' +const DEACTIVATE_USER_URL = '/api/pleroma/admin/users/deactivate' const ADMIN_USERS_URL = '/api/pleroma/admin/users' const SUGGESTIONS_URL = '/api/v1/suggestions' const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings' @@ -450,20 +451,26 @@ const deleteRight = ({ right, credentials, ...user }) => { }) } -const setActivationStatus = ({ status, credentials, ...user }) => { - const screenName = user.screen_name - const body = { - status: status - } - - const headers = authHeaders(credentials) - headers['Content-Type'] = 'application/json' +const activateUser = ({ credentials, screen_name: nickname }) => { + return promisedRequest({ + url: ACTIVATE_USER_URL, + method: 'PATCH', + credentials, + payload: { + nicknames: [nickname] + } + }).then(response => get(response, 'users.0')) +} - return fetch(ACTIVATION_STATUS_URL(screenName), { - method: 'PUT', - headers: headers, - body: JSON.stringify(body) - }) +const deactivateUser = ({ credentials, screen_name: nickname }) => { + return promisedRequest({ + url: DEACTIVATE_USER_URL, + method: 'PATCH', + credentials, + payload: { + nicknames: [nickname] + } + }).then(response => get(response, 'users.0')) } const deleteUser = ({ credentials, ...user }) => { @@ -979,7 +986,8 @@ const apiService = { deleteUser, addRight, deleteRight, - setActivationStatus, + activateUser, + deactivateUser, register, getCaptcha, updateAvatar, |
