diff --git a/src/components/NewMessage/NewMessageAbsenceInfo.vue b/src/components/NewMessage/NewMessageAbsenceInfo.vue
index 18dcc62f095..57b0d7f7606 100644
--- a/src/components/NewMessage/NewMessageAbsenceInfo.vue
+++ b/src/components/NewMessage/NewMessageAbsenceInfo.vue
@@ -16,6 +16,7 @@
disable-tooltip />
{{ t('spreed','Replacement: ') }}
@@ -42,6 +43,7 @@
import ChevronUp from 'vue-material-design-icons/ChevronUp.vue'
import { t } from '@nextcloud/l10n'
+import moment from '@nextcloud/moment'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
@@ -105,6 +107,16 @@ export default {
userAbsenceMessage() {
return this.userAbsence.message || this.userAbsence.shortMessage
},
+
+ userAbsencePeriod() {
+ if (!this.userAbsence.startDate || !this.userAbsence.endDate) {
+ return ''
+ }
+ return t('spreed', 'Absence period: {startDate} - {endDate}', {
+ startDate: moment.unix(this.userAbsence.startDate).format('ll'),
+ endDate: moment.unix(this.userAbsence.endDate).format('ll'),
+ })
+ },
},
watch: {
diff --git a/src/services/coreService.ts b/src/services/coreService.ts
index a8f7ceb3781..a9f155905b3 100644
--- a/src/services/coreService.ts
+++ b/src/services/coreService.ts
@@ -8,7 +8,10 @@ import { generateOcsUrl } from '@nextcloud/router'
import { getTalkConfig, hasTalkFeature } from './CapabilitiesManager.ts'
import { SHARE } from '../constants.js'
-import type { TaskProcessingResponse } from '../types/index.ts'
+import type {
+ OutOfOfficeResponse,
+ TaskProcessingResponse,
+} from '../types/index.ts'
const canInviteToFederation = hasTalkFeature('local', 'federation-v1')
&& getTalkConfig('local', 'federation', 'enabled')
@@ -61,8 +64,18 @@ const deleteTaskById = async function(id: number, options?: object): Promise
{
+ return axios.get(generateOcsUrl('/apps/dav/api/v1/outOfOffice/{userId}/now', { userId }))
+}
+
export {
autocompleteQuery,
getTaskById,
deleteTaskById,
+ getUserAbsence,
}
diff --git a/src/services/participantsService.js b/src/services/participantsService.js
index dcd6ed153c0..93dc2d19f40 100644
--- a/src/services/participantsService.js
+++ b/src/services/participantsService.js
@@ -271,15 +271,6 @@ const setTyping = (typing) => {
signalingSetTyping(typing)
}
-/**
- * Get absence information for a user (in a given 1-1 conversation).
- *
- * @param {string} userId user id
- */
-const getUserAbsence = async (userId) => {
- return axios.get(generateOcsUrl('/apps/dav/api/v1/outOfOffice/{userId}/now', { userId }))
-}
-
export {
joinConversation,
rejoinConversation,
@@ -300,5 +291,4 @@ export {
setPermissions,
setSessionState,
setTyping,
- getUserAbsence,
}
diff --git a/src/stores/__tests__/chatExtras.spec.js b/src/stores/__tests__/chatExtras.spec.js
index b23aed0eed7..b330991daff 100644
--- a/src/stores/__tests__/chatExtras.spec.js
+++ b/src/stores/__tests__/chatExtras.spec.js
@@ -5,12 +5,12 @@
import { setActivePinia, createPinia } from 'pinia'
import BrowserStorage from '../../services/BrowserStorage.js'
+import { getUserAbsence } from '../../services/coreService.ts'
import { EventBus } from '../../services/EventBus.ts'
-import { getUserAbsence } from '../../services/participantsService.js'
import { generateOCSErrorResponse, generateOCSResponse } from '../../test-helpers.js'
import { useChatExtrasStore } from '../chatExtras.js'
-jest.mock('../../services/participantsService', () => ({
+jest.mock('../../services/coreService', () => ({
getUserAbsence: jest.fn(),
}))
diff --git a/src/stores/chatExtras.js b/src/stores/chatExtras.js
index 1745bf876cb..099ed652e9a 100644
--- a/src/stores/chatExtras.js
+++ b/src/stores/chatExtras.js
@@ -11,9 +11,9 @@ import { generateUrl, getBaseUrl } from '@nextcloud/router'
import BrowserStorage from '../services/BrowserStorage.js'
import { getUpcomingEvents } from '../services/conversationsService.js'
+import { getUserAbsence } from '../services/coreService.ts'
import { EventBus } from '../services/EventBus.ts'
import { summarizeChat } from '../services/messagesService.ts'
-import { getUserAbsence } from '../services/participantsService.js'
import { parseSpecialSymbols, parseMentions } from '../utils/textParse.ts'
/**
@@ -81,7 +81,7 @@ export const useChatExtrasStore = defineStore('chatExtras', {
actions: {
/**
- * Fetch an absence status for user and save to store
+ * Get chat input for current conversation (from store or BrowserStorage)
*
* @param {string} token The conversation token
* @return {string} The input text
diff --git a/src/types/index.ts b/src/types/index.ts
index 7e35b5f580a..2cad0980af9 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -214,3 +214,18 @@ export type TaskProcessingResponse = ApiResponseUnwrapped<{
endedAt: number
}
}>
+
+// Out of office response
+// From https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-out-of-office-api.html
+export type OutOfOfficeResponse = ApiResponseUnwrapped<{
+ task: {
+ id: string,
+ userId: string,
+ startDate: number,
+ endDate: number,
+ shortMessage: string,
+ message: string,
+ replacementUserId?: string|null,
+ replacementUserDisplayName?: string|null,
+ }
+}>