@@ -16,11 +16,17 @@ import {
1616} from "../constants/requests" ;
1717import { getRequests , updateRequest } from "../models/requests" ;
1818import { AcknowledgeOOORequestBody } from "../types/oooRequest" ;
19- import { statusState } from "../constants/userStatus" ;
20- import { createUserFutureStatus } from "../models/userFutureStatus" ;
2119import { addFutureStatus } from "../models/userStatus" ;
2220const requestModel = firestore . collection ( "requests" ) ;
2321
22+ /**
23+ * Validates an Out-Of-Office (OOO) acknowledge request
24+ *
25+ * @param {string } requestId - The unique identifier of the request.
26+ * @param {string } requestType - The type of the request (expected to be 'OOO').
27+ * @param {string } requestStatus - The current status of the request.
28+ * @throws {Error } Throws an error if an issue occurs during validation.
29+ */
2430export const validateOOOAcknowledgeRequest = async (
2531 requestId : string ,
2632 requestType : string ,
@@ -58,6 +64,15 @@ export const validateOOOAcknowledgeRequest = async (
5864 }
5965}
6066
67+ /**
68+ * Acknowledges an Out-of-Office (OOO) request
69+ *
70+ * @param {string } requestId - The ID of the OOO request to acknowledge.
71+ * @param {AcknowledgeOOORequestBody } body - The acknowledgement body containing acknowledging details.
72+ * @param {string } userId - The unique identifier of the superuser user.
73+ * @returns {Promise<object> } The acknowledged OOO request.
74+ * @throws {Error } Throws an error if an issue occurs during acknowledgment process.
75+ */
6176export const acknowledgeOOORequest = async (
6277 requestId : string ,
6378 body : AcknowledgeOOORequestBody ,
@@ -106,17 +121,15 @@ export const acknowledgeOOORequest = async (
106121 const requestData = await getRequests ( { id : requestId } ) ;
107122
108123 if ( requestData ) {
109- const { from, until, requestedBy , comment } = requestData as any ;
124+ const { from, until, userId , comment } = requestData as any ;
110125 const userFutureStatusData = {
111126 requestId,
112- status : REQUEST_TYPE . OOO ,
113- state : statusState . UPCOMING ,
127+ state : REQUEST_TYPE . OOO ,
114128 from,
115129 endsOn : until ,
116- userId : requestedBy ,
130+ userId : userId ,
117131 message : comment ,
118132 } ;
119- await createUserFutureStatus ( userFutureStatusData ) ;
120133 await addFutureStatus ( userFutureStatusData ) ;
121134 }
122135 }
0 commit comments