{"version":3,"file":"jitsi-meeting.js","sources":["../../../src/io.ox/jitsiReservationManager/jitsi-meeting.js"],"sourcesContent":["/**\n * @copyright Copyright (c) Open-Xchange GmbH, Germany \n * @license AGPL-3.0\n *\n * This code is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with OX App Suite. If not, see .\n *\n * Any use of the work other than as authorized under this license or copyright law is prohibited.\n */\n\nimport Backbone from '@/backbone'\nimport $ from '@/jquery'\n\nimport DisposableView from '@/io.ox/backbone/views/disposable'\nimport { getConference } from '@/io.ox/conference/util'\nimport jitsiApi from '@/io.ox/jitsiReservationManager/api'\nimport { settings as jitsiSettings } from '@/io.ox/jitsiReservationManager/settings'\n\nimport { createIcon } from '@/io.ox/core/components'\nimport ox from '@/ox'\nimport gt from 'gettext'\nimport moment from '@/moment'\nimport { longerThanOneYear } from '@/io.ox/conference/views/util'\n\nconst svgConferenceLogo = $('
').append(createIcon('bi/camera-video.svg'))\nconst svgConferenceErrorLogo = createIcon('bi/exclamation.svg').addClass('conference-logo')\n\nconst MeetingView = DisposableView.extend({\n\n className: 'conference-view zoom',\n\n events: {\n 'click [data-action=\"copy-to-location\"]': 'copyToLocationHandler',\n 'click [data-action=\"copy-to-clipboard\"]': 'copyToClipboard'\n },\n\n initialize (options) {\n this.model = new Backbone.Model({ type: 'jitsi', state: 'done', joinURL: '' })\n this.appointment = options.appointment\n const conference = getConference(this.appointment.get('conferences'))\n this.model.set('joinURL', conference && conference.type === 'jitsi' ? conference.joinURL : '')\n this.listenTo(this.appointment, 'change:rrule', this.onChangeRecurrence)\n this.listenTo(this.appointment, 'create update', this.changeMeeting)\n window.jitsiMeeting = this\n },\n\n getExtendedProps () {\n return this.appointment.get('extendedProperties') || {}\n },\n\n getJoinURL () {\n return this.model && this.model.get('joinURL')\n },\n\n render () {\n this.renderPending()\n this.createMeeting().then(() => this.renderDone()).catch(error => this.renderError(error))\n return this\n },\n\n renderPending () {\n this.$el.append(\n $('
').append(\n svgConferenceLogo,\n // #. %s is a configurable product name of meeting service e.g. Jitsi or Zoom\n // #. Present progressive, indicating an ongoing or current action.\n $.txt(gt('Creating %s conference…', jitsiSettings.get('productName'))),\n createIcon('bi/arrow-clockwise.svg').addClass('animate-spin')\n )\n )\n },\n\n renderDone () {\n // show meeting\n const url = this.getJoinURL()\n // #. %s is a configurable product name of meeting service e.g. Jitsi or Zoom\n const recurrenceWarning = gt('%s conferences expire after 365 days. We recommend to limit the series to one year. Alternatively, you can update the series before the meeting expires.', jitsiSettings.get('productName'))\n this.$el.empty().append(svgConferenceLogo,\n`\n
${gt('Link:')} ${gt.noI18n(url)}
\n
\n ${gt('Copy to location field')}\n ${gt('Copy to clipboard')}\n
\n\n`)\n this.autoCopyToLocation()\n this.onChangeRecurrence()\n },\n\n renderError (errorMessage) {\n const errors = {\n 'Reservation not possible in the past': gt('Reservation not possible in the past')\n }\n this.$el.empty().append(\n svgConferenceErrorLogo,\n $('

').append($.txt(errors[errorMessage] || gt('Error creating meeting')))\n )\n },\n\n copyToClipboard () {\n navigator.clipboard.writeText(this.getJoinURL())\n },\n\n copyToLocationHandler (e) {\n e.preventDefault()\n this.copyToLocation()\n },\n\n autoCopyToLocation () {\n if (!jitsiSettings.get('autoCopyToLocation')) return\n if (this.appointment.get('location')) return\n this.copyToLocation()\n },\n\n copyToLocation (e) {\n this.appointment.set('location', this.getJoinURL())\n },\n\n getExpirationDate () {\n const rrule = this.appointment.get('rrule')\n if (!rrule) return this.appointment.getMoment('endDate').add(365, 'd').toISOString()\n const until = rrule.match(/UNTIL=([^;]+)/)\n if (!until) return this.appointment.getMoment('startDate').add(365, 'd').toISOString()\n return moment(until[1]).toISOString()\n },\n\n async createMeeting () {\n if (this.getJoinURL()) return this.model.set({ state: 'done' })\n const meetingData = {\n start: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(), /* this.appointment.getMoment('startDate') */\n expires: this.getExpirationDate()\n }\n const meeting = await jitsiApi.createMeeting(meetingData)\n if (meeting.errorCode) throw meeting.message\n this.appointment.set('conferences', [{\n uri: meeting.joinLink,\n feature: 'VIDEO',\n // #. %s is a configurable product name of meeting service e.g. Jitsi or Zoom\n label: gt('%s Conference', jitsiSettings.get('productName')),\n extendedParameters: {\n 'X-OX-TYPE': 'jitsi',\n 'X-OX-ID': meeting.id,\n 'X-OX-OWNER': ox.user_id\n }\n }])\n this.model.set({ joinURL: meeting.joinLink, state: 'done' })\n },\n\n changeMeeting () {\n const meeting = this.model.get('meeting')\n if (!meeting) return\n const data = this.appointment.toJSON()\n // This appointment is an exception of a series - do not change the zoom meeting\n if (data.seriesId && (data.seriesId !== data.id)) return\n // This appointment changed to an exception of a series - do not change the zoom meeting\n if (data.seriesId && (data.seriesId === data.id) && !data.rrule) return\n this.createMeeting()\n },\n\n isDone () {\n return this.getJoinURL() && this.model.get('meeting')\n },\n\n onChangeRecurrence () {\n const rrule = this.appointment.get('rrule')\n this.$el.find('.recurrence-warning').toggleClass('hidden', !longerThanOneYear(rrule))\n }\n})\n\nexport default MeetingView\n"],"names":["svgConferenceLogo","$","createIcon","svgConferenceErrorLogo","MeetingView","DisposableView","options","Backbone","conference","getConference","error","gt","jitsiSettings","url","recurrenceWarning","errorMessage","errors","e","rrule","until","moment","meetingData","meeting","jitsiApi","ox","data","longerThanOneYear"],"mappings":"uxCAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAkCA,MAAMA,EAAoBC,EAAE,+BAA+B,EAAE,OAAOC,EAAW,qBAAqB,CAAC,EAC/FC,EAAyBD,EAAW,oBAAo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