@@ -16,11 +16,17 @@ import {
16
16
} from "../constants/requests" ;
17
17
import { getRequests , updateRequest } from "../models/requests" ;
18
18
import { AcknowledgeOOORequestBody } from "../types/oooRequest" ;
19
- import { statusState } from "../constants/userStatus" ;
20
- import { createUserFutureStatus } from "../models/userFutureStatus" ;
21
19
import { addFutureStatus } from "../models/userStatus" ;
22
20
const requestModel = firestore . collection ( "requests" ) ;
23
21
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
+ */
24
30
export const validateOOOAcknowledgeRequest = async (
25
31
requestId : string ,
26
32
requestType : string ,
@@ -58,6 +64,15 @@ export const validateOOOAcknowledgeRequest = async (
58
64
}
59
65
}
60
66
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
+ */
61
76
export const acknowledgeOOORequest = async (
62
77
requestId : string ,
63
78
body : AcknowledgeOOORequestBody ,
@@ -106,17 +121,15 @@ export const acknowledgeOOORequest = async (
106
121
const requestData = await getRequests ( { id : requestId } ) ;
107
122
108
123
if ( requestData ) {
109
- const { from, until, requestedBy , comment } = requestData as any ;
124
+ const { from, until, userId , comment } = requestData as any ;
110
125
const userFutureStatusData = {
111
126
requestId,
112
- status : REQUEST_TYPE . OOO ,
113
- state : statusState . UPCOMING ,
127
+ state : REQUEST_TYPE . OOO ,
114
128
from,
115
129
endsOn : until ,
116
- userId : requestedBy ,
130
+ userId : userId ,
117
131
message : comment ,
118
132
} ;
119
- await createUserFutureStatus ( userFutureStatusData ) ;
120
133
await addFutureStatus ( userFutureStatusData ) ;
121
134
}
122
135
}
0 commit comments