diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2023-08-08 16:57:16 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-08-09 10:05:56 +0000 |
commit | 387b93a6bcfbf0f64120e2cb08bf0abd30295c25 (patch) | |
tree | a0d42076d2def80adeeaa119dbf7ba0f10e9d1e6 /src | |
parent | f9cb9a4b3a478ced71baff82920e27493b475fc0 (diff) |
add a reminders service
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/services/remindersService.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/services/remindersService.js b/src/services/remindersService.js new file mode 100644 index 000000000..f73071e86 --- /dev/null +++ b/src/services/remindersService.js @@ -0,0 +1,73 @@ +/** + * @copyright Copyright (c) 2023 Maksim Sukharev <antreesy.web@gmail.com> + * + * @author Maksim Sukharev <antreesy.web@gmail.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/>. + * + */ + +import axios from '@nextcloud/axios' +import { generateOcsUrl } from '@nextcloud/router' + +/** + * Sets the reminder with defined timestamp on the message for the user + * + * @param {string} token The conversation token + * @param {number} messageId The id of selected message + * @return {object} The axios response + */ +const getMessageReminder = async function(token, messageId) { + return axios.get(generateOcsUrl('apps/spreed/api/v1/chat/{token}/{messageId}/reminder', { + token, + messageId, + })) +} + +/** + * Sets the reminder with defined timestamp on the message for the user + * + * @param {string} token The conversation token + * @param {number} messageId The id of selected message + * @param {number} timestamp The timestamp of reminder (in seconds) + * @return {object} The axios response + */ +const setMessageReminder = async function(token, messageId, timestamp) { + return axios.post(generateOcsUrl('apps/spreed/api/v1/chat/{token}/{messageId}/reminder', { + token, + messageId, + }), { timestamp }) +} + +/** + * Removes the reminder from the message + * + * @param {string} token The conversation token + * @param {number} messageId The id of selected message + * @return {object} The axios response + */ +const removeMessageReminder = async function(token, messageId) { + return axios.delete(generateOcsUrl('apps/spreed/api/v1/chat/{token}/{messageId}/reminder', { + token, + messageId, + })) +} + +export { + getMessageReminder, + setMessageReminder, + removeMessageReminder, +} |