diff options
Diffstat (limited to 'apps/user_status/src/services/statusService.js')
-rw-r--r-- | apps/user_status/src/services/statusService.js | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/apps/user_status/src/services/statusService.js b/apps/user_status/src/services/statusService.js index f4bda930303..6504411c996 100644 --- a/apps/user_status/src/services/statusService.js +++ b/apps/user_status/src/services/statusService.js @@ -1,23 +1,6 @@ /** - * @copyright Copyright (c) 2020 Georg Ehrke - * - * @author Georg Ehrke <oc.list@georgehrke.com> - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ import HttpClient from '@nextcloud/axios' @@ -36,6 +19,19 @@ const fetchCurrentStatus = async () => { } /** + * Fetches the current user-status + * + * @param {string} userId Id of the user to fetch the status + * @return {Promise<object>} + */ +const fetchBackupStatus = async (userId) => { + const url = generateOcsUrl('apps/user_status/api/v1/statuses/{userId}', { userId: '_' + userId }) + const response = await HttpClient.get(url) + + return response.data.ocs.data +} + +/** * Sets the status * * @param {string} statusType The status (online / away / dnd / invisible) @@ -90,10 +86,25 @@ const clearMessage = async () => { await HttpClient.delete(url) } +/** + * Revert the automated status + * + * @param {string} messageId ID of the message to revert + * @return {Promise<object>} + */ +const revertToBackupStatus = async (messageId) => { + const url = generateOcsUrl('apps/user_status/api/v1/user_status/revert/{messageId}', { messageId }) + const response = await HttpClient.delete(url) + + return response.data.ocs.data +} + export { fetchCurrentStatus, + fetchBackupStatus, setStatus, setCustomMessage, setPredefinedMessage, clearMessage, + revertToBackupStatus, } |