You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.6 KiB

  1. /**
  2. * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
  3. *
  4. * @author Joas Schilling <coding@schilljs.com>
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. import axios from '@nextcloud/axios'
  23. import { generateOcsUrl } from '@nextcloud/router'
  24. import BrowserStorage from './BrowserStorage'
  25. /**
  26. * Sets the attachment folder setting for the user
  27. *
  28. * @param {string} path The name of the folder
  29. * @returns {Object} The axios response
  30. */
  31. const setAttachmentFolder = async function(path) {
  32. return axios.post(generateOcsUrl('apps/spreed/api/v1/settings', 2) + 'user', {
  33. key: 'attachment_folder',
  34. value: path,
  35. })
  36. }
  37. /**
  38. * Sets the read status privacy setting for the user
  39. *
  40. * @param {int} privacy The selected value, either 0 or 1
  41. * @returns {Object} The axios response
  42. */
  43. const setReadStatusPrivacy = async function(privacy) {
  44. return axios.post(generateOcsUrl('apps/spreed/api/v1/settings', 2) + 'user', {
  45. key: 'read_status_privacy',
  46. value: privacy,
  47. })
  48. }
  49. /**
  50. * Save the SIP settings
  51. *
  52. * @param {Array<string>} sipGroups The groups allowed to enable SIP on a conversation
  53. * @param {string} sharedSecret The shared secret which is used by the SIP server to authenticate
  54. * @param {string} dialInInfo The dial-in Information displayed in the email and sidebar
  55. * @returns {Object} The axios response
  56. */
  57. const setSIPSettings = async function(sipGroups, sharedSecret, dialInInfo) {
  58. return axios.post(generateOcsUrl('apps/spreed/api/v1/settings', 2) + 'sip', {
  59. sipGroups,
  60. sharedSecret,
  61. dialInInfo,
  62. })
  63. }
  64. const setPlaySounds = async function(isGuest, enabled) {
  65. const savableValue = enabled ? 'yes' : 'no'
  66. if (!isGuest) {
  67. return axios.post(generateOcsUrl('apps/spreed/api/v1/settings', 2) + 'user', {
  68. key: 'play_sounds',
  69. value: savableValue,
  70. })
  71. } else {
  72. BrowserStorage.setItem('play_sounds', savableValue)
  73. }
  74. }
  75. export {
  76. setAttachmentFolder,
  77. setReadStatusPrivacy,
  78. setSIPSettings,
  79. setPlaySounds,
  80. }