2021-07-13 13:16:31 -07:00
|
|
|
import { fetchRelationships } from 'soapbox/actions/accounts';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { importFetchedAccount, importFetchedStatuses } from 'soapbox/actions/importer';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import api from '../api';
|
2020-08-23 10:48:45 -07:00
|
|
|
|
2020-12-29 20:17:03 -08:00
|
|
|
export const ADMIN_CONFIG_FETCH_REQUEST = 'ADMIN_CONFIG_FETCH_REQUEST';
|
|
|
|
export const ADMIN_CONFIG_FETCH_SUCCESS = 'ADMIN_CONFIG_FETCH_SUCCESS';
|
|
|
|
export const ADMIN_CONFIG_FETCH_FAIL = 'ADMIN_CONFIG_FETCH_FAIL';
|
|
|
|
|
2020-08-23 10:48:45 -07:00
|
|
|
export const ADMIN_CONFIG_UPDATE_REQUEST = 'ADMIN_CONFIG_UPDATE_REQUEST';
|
|
|
|
export const ADMIN_CONFIG_UPDATE_SUCCESS = 'ADMIN_CONFIG_UPDATE_SUCCESS';
|
|
|
|
export const ADMIN_CONFIG_UPDATE_FAIL = 'ADMIN_CONFIG_UPDATE_FAIL';
|
|
|
|
|
2020-08-24 15:18:53 -07:00
|
|
|
export const ADMIN_REPORTS_FETCH_REQUEST = 'ADMIN_REPORTS_FETCH_REQUEST';
|
|
|
|
export const ADMIN_REPORTS_FETCH_SUCCESS = 'ADMIN_REPORTS_FETCH_SUCCESS';
|
|
|
|
export const ADMIN_REPORTS_FETCH_FAIL = 'ADMIN_REPORTS_FETCH_FAIL';
|
|
|
|
|
2020-12-31 16:24:52 -08:00
|
|
|
export const ADMIN_REPORTS_PATCH_REQUEST = 'ADMIN_REPORTS_PATCH_REQUEST';
|
|
|
|
export const ADMIN_REPORTS_PATCH_SUCCESS = 'ADMIN_REPORTS_PATCH_SUCCESS';
|
|
|
|
export const ADMIN_REPORTS_PATCH_FAIL = 'ADMIN_REPORTS_PATCH_FAIL';
|
|
|
|
|
2020-12-29 13:55:04 -08:00
|
|
|
export const ADMIN_USERS_FETCH_REQUEST = 'ADMIN_USERS_FETCH_REQUEST';
|
|
|
|
export const ADMIN_USERS_FETCH_SUCCESS = 'ADMIN_USERS_FETCH_SUCCESS';
|
|
|
|
export const ADMIN_USERS_FETCH_FAIL = 'ADMIN_USERS_FETCH_FAIL';
|
|
|
|
|
2020-12-29 16:22:31 -08:00
|
|
|
export const ADMIN_USERS_DELETE_REQUEST = 'ADMIN_USERS_DELETE_REQUEST';
|
|
|
|
export const ADMIN_USERS_DELETE_SUCCESS = 'ADMIN_USERS_DELETE_SUCCESS';
|
|
|
|
export const ADMIN_USERS_DELETE_FAIL = 'ADMIN_USERS_DELETE_FAIL';
|
|
|
|
|
|
|
|
export const ADMIN_USERS_APPROVE_REQUEST = 'ADMIN_USERS_APPROVE_REQUEST';
|
|
|
|
export const ADMIN_USERS_APPROVE_SUCCESS = 'ADMIN_USERS_APPROVE_SUCCESS';
|
|
|
|
export const ADMIN_USERS_APPROVE_FAIL = 'ADMIN_USERS_APPROVE_FAIL';
|
|
|
|
|
2020-12-31 15:54:08 -08:00
|
|
|
export const ADMIN_USERS_DEACTIVATE_REQUEST = 'ADMIN_USERS_DEACTIVATE_REQUEST';
|
|
|
|
export const ADMIN_USERS_DEACTIVATE_SUCCESS = 'ADMIN_USERS_DEACTIVATE_SUCCESS';
|
|
|
|
export const ADMIN_USERS_DEACTIVATE_FAIL = 'ADMIN_USERS_DEACTIVATE_FAIL';
|
|
|
|
|
2020-12-31 20:20:31 -08:00
|
|
|
export const ADMIN_STATUS_DELETE_REQUEST = 'ADMIN_STATUS_DELETE_REQUEST';
|
|
|
|
export const ADMIN_STATUS_DELETE_SUCCESS = 'ADMIN_STATUS_DELETE_SUCCESS';
|
|
|
|
export const ADMIN_STATUS_DELETE_FAIL = 'ADMIN_STATUS_DELETE_FAIL';
|
|
|
|
|
2021-01-18 18:59:07 -08:00
|
|
|
export const ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST = 'ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST';
|
|
|
|
export const ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS = 'ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS';
|
|
|
|
export const ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL = 'ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL';
|
|
|
|
|
2021-01-01 10:50:13 -08:00
|
|
|
export const ADMIN_LOG_FETCH_REQUEST = 'ADMIN_LOG_FETCH_REQUEST';
|
|
|
|
export const ADMIN_LOG_FETCH_SUCCESS = 'ADMIN_LOG_FETCH_SUCCESS';
|
|
|
|
export const ADMIN_LOG_FETCH_FAIL = 'ADMIN_LOG_FETCH_FAIL';
|
|
|
|
|
2021-03-15 19:50:16 -07:00
|
|
|
export const ADMIN_USERS_TAG_REQUEST = 'ADMIN_USERS_TAG_REQUEST';
|
|
|
|
export const ADMIN_USERS_TAG_SUCCESS = 'ADMIN_USERS_TAG_SUCCESS';
|
|
|
|
export const ADMIN_USERS_TAG_FAIL = 'ADMIN_USERS_TAG_FAIL';
|
|
|
|
|
|
|
|
export const ADMIN_USERS_UNTAG_REQUEST = 'ADMIN_USERS_UNTAG_REQUEST';
|
|
|
|
export const ADMIN_USERS_UNTAG_SUCCESS = 'ADMIN_USERS_UNTAG_SUCCESS';
|
|
|
|
export const ADMIN_USERS_UNTAG_FAIL = 'ADMIN_USERS_UNTAG_FAIL';
|
|
|
|
|
2021-07-13 10:34:58 -07:00
|
|
|
export const ADMIN_ADD_PERMISSION_GROUP_REQUEST = 'ADMIN_ADD_PERMISSION_GROUP_REQUEST';
|
|
|
|
export const ADMIN_ADD_PERMISSION_GROUP_SUCCESS = 'ADMIN_ADD_PERMISSION_GROUP_SUCCESS';
|
|
|
|
export const ADMIN_ADD_PERMISSION_GROUP_FAIL = 'ADMIN_ADD_PERMISSION_GROUP_FAIL';
|
2021-07-13 10:21:12 -07:00
|
|
|
|
2021-07-13 10:34:58 -07:00
|
|
|
export const ADMIN_REMOVE_PERMISSION_GROUP_REQUEST = 'ADMIN_REMOVE_PERMISSION_GROUP_REQUEST';
|
|
|
|
export const ADMIN_REMOVE_PERMISSION_GROUP_SUCCESS = 'ADMIN_REMOVE_PERMISSION_GROUP_SUCCESS';
|
|
|
|
export const ADMIN_REMOVE_PERMISSION_GROUP_FAIL = 'ADMIN_REMOVE_PERMISSION_GROUP_FAIL';
|
2021-07-13 10:21:12 -07:00
|
|
|
|
2021-11-26 21:36:17 -08:00
|
|
|
export const ADMIN_USERS_SUGGEST_REQUEST = 'ADMIN_USERS_SUGGEST_REQUEST';
|
|
|
|
export const ADMIN_USERS_SUGGEST_SUCCESS = 'ADMIN_USERS_SUGGEST_SUCCESS';
|
|
|
|
export const ADMIN_USERS_SUGGEST_FAIL = 'ADMIN_USERS_SUGGEST_FAIL';
|
|
|
|
|
|
|
|
export const ADMIN_USERS_UNSUGGEST_REQUEST = 'ADMIN_USERS_UNSUGGEST_REQUEST';
|
|
|
|
export const ADMIN_USERS_UNSUGGEST_SUCCESS = 'ADMIN_USERS_UNSUGGEST_SUCCESS';
|
|
|
|
export const ADMIN_USERS_UNSUGGEST_FAIL = 'ADMIN_USERS_UNSUGGEST_FAIL';
|
|
|
|
|
2021-07-13 10:21:12 -07:00
|
|
|
const nicknamesFromIds = (getState, ids) => ids.map(id => getState().getIn(['accounts', id, 'acct']));
|
|
|
|
|
2020-12-29 20:17:03 -08:00
|
|
|
export function fetchConfig() {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
dispatch({ type: ADMIN_CONFIG_FETCH_REQUEST });
|
|
|
|
return api(getState)
|
|
|
|
.get('/api/pleroma/admin/config')
|
|
|
|
.then(({ data }) => {
|
|
|
|
dispatch({ type: ADMIN_CONFIG_FETCH_SUCCESS, configs: data.configs, needsReboot: data.need_reboot });
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: ADMIN_CONFIG_FETCH_FAIL, error });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-12-29 21:25:07 -08:00
|
|
|
export function updateConfig(configs) {
|
2020-08-23 10:48:45 -07:00
|
|
|
return (dispatch, getState) => {
|
2020-12-29 21:25:07 -08:00
|
|
|
dispatch({ type: ADMIN_CONFIG_UPDATE_REQUEST, configs });
|
2020-08-23 10:48:45 -07:00
|
|
|
return api(getState)
|
2020-12-29 21:25:07 -08:00
|
|
|
.post('/api/pleroma/admin/config', { configs })
|
2021-07-28 15:06:21 -07:00
|
|
|
.then(({ data }) => {
|
|
|
|
dispatch({ type: ADMIN_CONFIG_UPDATE_SUCCESS, configs: data.configs, needsReboot: data.need_reboot });
|
2020-08-23 10:48:45 -07:00
|
|
|
}).catch(error => {
|
2021-07-28 15:06:21 -07:00
|
|
|
dispatch({ type: ADMIN_CONFIG_UPDATE_FAIL, error, configs });
|
2020-08-23 10:48:45 -07:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2020-08-24 15:18:53 -07:00
|
|
|
|
|
|
|
export function fetchReports(params) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
dispatch({ type: ADMIN_REPORTS_FETCH_REQUEST, params });
|
|
|
|
return api(getState)
|
2020-08-24 16:00:09 -07:00
|
|
|
.get('/api/pleroma/admin/reports', { params })
|
2020-12-31 12:29:31 -08:00
|
|
|
.then(({ data: { reports } }) => {
|
2021-01-18 12:58:30 -08:00
|
|
|
reports.forEach(report => {
|
|
|
|
dispatch(importFetchedAccount(report.account));
|
|
|
|
dispatch(importFetchedAccount(report.actor));
|
|
|
|
dispatch(importFetchedStatuses(report.statuses));
|
|
|
|
});
|
2020-12-31 12:29:31 -08:00
|
|
|
dispatch({ type: ADMIN_REPORTS_FETCH_SUCCESS, reports, params });
|
2020-08-24 15:18:53 -07:00
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: ADMIN_REPORTS_FETCH_FAIL, error, params });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2020-12-29 13:55:04 -08:00
|
|
|
|
2020-12-31 16:24:52 -08:00
|
|
|
function patchReports(ids, state) {
|
|
|
|
const reports = ids.map(id => ({ id, state }));
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
dispatch({ type: ADMIN_REPORTS_PATCH_REQUEST, reports });
|
|
|
|
return api(getState)
|
|
|
|
.patch('/api/pleroma/admin/reports', { reports })
|
|
|
|
.then(() => {
|
|
|
|
dispatch({ type: ADMIN_REPORTS_PATCH_SUCCESS, reports });
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: ADMIN_REPORTS_PATCH_FAIL, error, reports });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
export function closeReports(ids) {
|
|
|
|
return patchReports(ids, 'closed');
|
|
|
|
}
|
|
|
|
|
2021-07-13 18:14:15 -07:00
|
|
|
export function fetchUsers(filters = [], page = 1, query, pageSize = 50) {
|
2020-12-29 13:55:04 -08:00
|
|
|
return (dispatch, getState) => {
|
2021-07-13 15:27:11 -07:00
|
|
|
const params = { filters: filters.join(), page, page_size: pageSize };
|
2021-07-13 18:14:15 -07:00
|
|
|
if (query) params.query = query;
|
2021-07-13 15:27:11 -07:00
|
|
|
|
|
|
|
dispatch({ type: ADMIN_USERS_FETCH_REQUEST, filters, page, pageSize });
|
2020-12-29 13:55:04 -08:00
|
|
|
return api(getState)
|
|
|
|
.get('/api/pleroma/admin/users', { params })
|
2021-07-13 13:16:31 -07:00
|
|
|
.then(({ data: { users, count, page_size: pageSize } }) => {
|
|
|
|
dispatch(fetchRelationships(users.map(user => user.id)));
|
2021-07-13 15:27:11 -07:00
|
|
|
dispatch({ type: ADMIN_USERS_FETCH_SUCCESS, users, count, pageSize, filters, page });
|
2021-07-13 15:01:31 -07:00
|
|
|
return { users, count, pageSize };
|
2020-12-29 13:55:04 -08:00
|
|
|
}).catch(error => {
|
2021-07-13 15:27:11 -07:00
|
|
|
dispatch({ type: ADMIN_USERS_FETCH_FAIL, error, filters, page, pageSize });
|
2020-12-29 13:55:04 -08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2020-12-29 16:22:31 -08:00
|
|
|
|
2021-07-13 16:11:11 -07:00
|
|
|
export function deactivateUsers(accountIds) {
|
2020-12-31 15:54:08 -08:00
|
|
|
return (dispatch, getState) => {
|
2021-07-13 16:11:11 -07:00
|
|
|
const nicknames = nicknamesFromIds(getState, accountIds);
|
|
|
|
dispatch({ type: ADMIN_USERS_DEACTIVATE_REQUEST, accountIds });
|
2020-12-31 15:54:08 -08:00
|
|
|
return api(getState)
|
|
|
|
.patch('/api/pleroma/admin/users/deactivate', { nicknames })
|
|
|
|
.then(({ data: { users } }) => {
|
2021-07-13 16:11:11 -07:00
|
|
|
dispatch({ type: ADMIN_USERS_DEACTIVATE_SUCCESS, users, accountIds });
|
2020-12-31 15:54:08 -08:00
|
|
|
}).catch(error => {
|
2021-07-13 16:11:11 -07:00
|
|
|
dispatch({ type: ADMIN_USERS_DEACTIVATE_FAIL, error, accountIds });
|
2020-12-31 15:54:08 -08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-13 16:11:11 -07:00
|
|
|
export function deleteUsers(accountIds) {
|
2020-12-29 16:22:31 -08:00
|
|
|
return (dispatch, getState) => {
|
2021-07-13 16:11:11 -07:00
|
|
|
const nicknames = nicknamesFromIds(getState, accountIds);
|
|
|
|
dispatch({ type: ADMIN_USERS_DELETE_REQUEST, accountIds });
|
2020-12-29 16:22:31 -08:00
|
|
|
return api(getState)
|
|
|
|
.delete('/api/pleroma/admin/users', { data: { nicknames } })
|
|
|
|
.then(({ data: nicknames }) => {
|
2021-07-13 16:11:11 -07:00
|
|
|
dispatch({ type: ADMIN_USERS_DELETE_SUCCESS, nicknames, accountIds });
|
2020-12-29 16:22:31 -08:00
|
|
|
}).catch(error => {
|
2021-07-13 16:11:11 -07:00
|
|
|
dispatch({ type: ADMIN_USERS_DELETE_FAIL, error, accountIds });
|
2020-12-29 16:22:31 -08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-13 16:11:11 -07:00
|
|
|
export function approveUsers(accountIds) {
|
2020-12-29 16:22:31 -08:00
|
|
|
return (dispatch, getState) => {
|
2021-07-13 16:11:11 -07:00
|
|
|
const nicknames = nicknamesFromIds(getState, accountIds);
|
|
|
|
dispatch({ type: ADMIN_USERS_APPROVE_REQUEST, accountIds });
|
2020-12-29 16:22:31 -08:00
|
|
|
return api(getState)
|
|
|
|
.patch('/api/pleroma/admin/users/approve', { nicknames })
|
|
|
|
.then(({ data: { users } }) => {
|
2021-07-13 16:11:11 -07:00
|
|
|
dispatch({ type: ADMIN_USERS_APPROVE_SUCCESS, users, accountIds });
|
2020-12-29 16:22:31 -08:00
|
|
|
}).catch(error => {
|
2021-07-13 16:11:11 -07:00
|
|
|
dispatch({ type: ADMIN_USERS_APPROVE_FAIL, error, accountIds });
|
2020-12-29 16:22:31 -08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2020-12-31 20:20:31 -08:00
|
|
|
|
|
|
|
export function deleteStatus(id) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
dispatch({ type: ADMIN_STATUS_DELETE_REQUEST, id });
|
|
|
|
return api(getState)
|
|
|
|
.delete(`/api/pleroma/admin/statuses/${id}`)
|
|
|
|
.then(() => {
|
|
|
|
dispatch({ type: ADMIN_STATUS_DELETE_SUCCESS, id });
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: ADMIN_STATUS_DELETE_FAIL, error, id });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2021-01-01 10:50:13 -08:00
|
|
|
|
2021-01-18 18:59:07 -08:00
|
|
|
export function toggleStatusSensitivity(id, sensitive) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
dispatch({ type: ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST, id });
|
|
|
|
return api(getState)
|
|
|
|
.put(`/api/pleroma/admin/statuses/${id}`, { sensitive: !sensitive })
|
|
|
|
.then(() => {
|
|
|
|
dispatch({ type: ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS, id });
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL, error, id });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-01 10:50:13 -08:00
|
|
|
export function fetchModerationLog(params) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
dispatch({ type: ADMIN_LOG_FETCH_REQUEST });
|
|
|
|
return api(getState)
|
|
|
|
.get('/api/pleroma/admin/moderation_log', { params })
|
|
|
|
.then(({ data }) => {
|
|
|
|
dispatch({ type: ADMIN_LOG_FETCH_SUCCESS, items: data.items, total: data.total });
|
|
|
|
return data;
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: ADMIN_LOG_FETCH_FAIL, error });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2021-03-15 19:50:16 -07:00
|
|
|
|
|
|
|
export function tagUsers(accountIds, tags) {
|
|
|
|
return (dispatch, getState) => {
|
2021-07-13 10:21:12 -07:00
|
|
|
const nicknames = nicknamesFromIds(getState, accountIds);
|
2021-03-15 19:50:16 -07:00
|
|
|
dispatch({ type: ADMIN_USERS_TAG_REQUEST, accountIds, tags });
|
|
|
|
return api(getState)
|
|
|
|
.put('/api/v1/pleroma/admin/users/tag', { nicknames, tags })
|
|
|
|
.then(() => {
|
|
|
|
dispatch({ type: ADMIN_USERS_TAG_SUCCESS, accountIds, tags });
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: ADMIN_USERS_TAG_FAIL, error, accountIds, tags });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function untagUsers(accountIds, tags) {
|
|
|
|
return (dispatch, getState) => {
|
2021-07-13 10:21:12 -07:00
|
|
|
const nicknames = nicknamesFromIds(getState, accountIds);
|
2021-03-15 19:50:16 -07:00
|
|
|
dispatch({ type: ADMIN_USERS_UNTAG_REQUEST, accountIds, tags });
|
|
|
|
return api(getState)
|
|
|
|
.delete('/api/v1/pleroma/admin/users/tag', { data: { nicknames, tags } })
|
|
|
|
.then(() => {
|
|
|
|
dispatch({ type: ADMIN_USERS_UNTAG_SUCCESS, accountIds, tags });
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: ADMIN_USERS_UNTAG_FAIL, error, accountIds, tags });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2021-07-13 10:21:12 -07:00
|
|
|
|
2021-07-13 10:26:56 -07:00
|
|
|
export function verifyUser(accountId) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
return dispatch(tagUsers([accountId], ['verified']));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unverifyUser(accountId) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
return dispatch(untagUsers([accountId], ['verified']));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-13 10:21:12 -07:00
|
|
|
export function addPermission(accountIds, permissionGroup) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const nicknames = nicknamesFromIds(getState, accountIds);
|
2021-07-13 10:34:58 -07:00
|
|
|
dispatch({ type: ADMIN_ADD_PERMISSION_GROUP_REQUEST, accountIds, permissionGroup });
|
2021-07-13 10:21:12 -07:00
|
|
|
return api(getState)
|
|
|
|
.post(`/api/v1/pleroma/admin/users/permission_group/${permissionGroup}`, { nicknames })
|
|
|
|
.then(({ data }) => {
|
2021-07-13 10:34:58 -07:00
|
|
|
dispatch({ type: ADMIN_ADD_PERMISSION_GROUP_SUCCESS, accountIds, permissionGroup, data });
|
2021-07-13 10:21:12 -07:00
|
|
|
}).catch(error => {
|
2021-07-13 10:34:58 -07:00
|
|
|
dispatch({ type: ADMIN_ADD_PERMISSION_GROUP_FAIL, error, accountIds, permissionGroup });
|
2021-07-13 10:21:12 -07:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function removePermission(accountIds, permissionGroup) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const nicknames = nicknamesFromIds(getState, accountIds);
|
2021-07-13 10:34:58 -07:00
|
|
|
dispatch({ type: ADMIN_REMOVE_PERMISSION_GROUP_REQUEST, accountIds, permissionGroup });
|
2021-07-13 10:21:12 -07:00
|
|
|
return api(getState)
|
|
|
|
.delete(`/api/v1/pleroma/admin/users/permission_group/${permissionGroup}`, { data: { nicknames } })
|
|
|
|
.then(({ data }) => {
|
2021-07-13 10:34:58 -07:00
|
|
|
dispatch({ type: ADMIN_REMOVE_PERMISSION_GROUP_SUCCESS, accountIds, permissionGroup, data });
|
2021-07-13 10:21:12 -07:00
|
|
|
}).catch(error => {
|
2021-07-13 10:34:58 -07:00
|
|
|
dispatch({ type: ADMIN_REMOVE_PERMISSION_GROUP_FAIL, error, accountIds, permissionGroup });
|
2021-07-13 10:21:12 -07:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function promoteToAdmin(accountId) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
return Promise.all([
|
|
|
|
dispatch(addPermission([accountId], 'admin')),
|
|
|
|
dispatch(removePermission([accountId], 'moderator')),
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function promoteToModerator(accountId) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
return Promise.all([
|
|
|
|
dispatch(removePermission([accountId], 'admin')),
|
|
|
|
dispatch(addPermission([accountId], 'moderator')),
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function demoteToUser(accountId) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
return Promise.all([
|
|
|
|
dispatch(removePermission([accountId], 'admin')),
|
|
|
|
dispatch(removePermission([accountId], 'moderator')),
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
}
|
2021-11-26 21:36:17 -08:00
|
|
|
|
|
|
|
export function suggestUsers(accountIds) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const nicknames = nicknamesFromIds(getState, accountIds);
|
|
|
|
dispatch({ type: ADMIN_USERS_SUGGEST_REQUEST, accountIds });
|
|
|
|
return api(getState)
|
|
|
|
.patch('/api/pleroma/admin/users/suggest', { nicknames })
|
|
|
|
.then(({ data: { users } }) => {
|
|
|
|
dispatch({ type: ADMIN_USERS_SUGGEST_SUCCESS, users, accountIds });
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: ADMIN_USERS_SUGGEST_FAIL, error, accountIds });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unsuggestUsers(accountIds) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const nicknames = nicknamesFromIds(getState, accountIds);
|
|
|
|
dispatch({ type: ADMIN_USERS_UNSUGGEST_REQUEST, accountIds });
|
|
|
|
return api(getState)
|
|
|
|
.patch('/api/pleroma/admin/users/unsuggest', { nicknames })
|
|
|
|
.then(({ data: { users } }) => {
|
|
|
|
dispatch({ type: ADMIN_USERS_UNSUGGEST_SUCCESS, users, accountIds });
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: ADMIN_USERS_UNSUGGEST_FAIL, error, accountIds });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|