@@ -21,30 +21,28 @@ const {db} = require("../application/lib");
2121
2222/**
2323 * Description
24- * @param {any } meetDocId
2524 * @param {any } orgDomain
2625 * @param {any } teamId
2726 * @param {any } teamMembers
2827 * @param {any } title
2928 * @param {any } startTime
3029 * @param {any } endTime
31- * @param {any } hostName
30+ * @param {any } hostEmail
3231 * @param {any } description
3332 * @param {any } date
3433 * @param {any } roomId
3534 * @return {any }
3635 */
37- exports . setMeet = function ( meetDocId , orgDomain , teamId , teamMembers , title , startTime , endTime , hostName , description , date , roomId ) {
38- const setMeetDoc = db . collection ( "Meet" ) . doc ( meetDocId ) . set ( {
39- MeetDocId : meetDocId ,
36+ exports . setMeet = function ( orgDomain , teamId , teamMembers , title , startTime , endTime , hostEmail , description , date , roomId ) {
37+ const setMeetDoc = db . collection ( "Meets" ) . doc ( roomId ) . set ( {
4038 OrgDomain : orgDomain ,
4139 TeamId : teamId ,
42- TeamMembers : teamMembers ,
40+ Attendees : teamMembers ,
4341 Title : title ,
4442 StartTime : startTime ,
4543 EndTime : endTime ,
4644 Status : "OK" ,
47- HostName : hostName ,
45+ HostEmail : hostEmail ,
4846 Description : description ,
4947 Date : date ,
5048 RoomId : roomId ,
@@ -54,48 +52,45 @@ exports.setMeet = function(meetDocId, orgDomain, teamId, teamMembers, title, sta
5452
5553/**
5654 * Description
57- * @param {any } meetDocId
55+ * @param {any } userEmail
5856 * @param {any } orgDomain
5957 * @param {any } teamId
6058 * @param {any } teamMembers
6159 * @param {any } title
6260 * @param {any } startTime
6361 * @param {any } endTime
64- * @param {any } hostName
62+ * @param {any } hostEmail
6563 * @param {any } description
6664 * @param {any } date
67- * @param {any } uid
6865 * @param {any } roomId
6966 * @return {any }
7067 */
71- exports . setUserMeet = function ( meetDocId , orgDomain , teamId , teamMembers , title , startTime , endTime , hostName , description , date , uid , roomId ) {
72- const setMeetDoc1 = db . collection ( "Users" ) . doc ( uid ) . collection ( "Meet" ) . doc ( meetDocId ) . set ( {
73- MeetDocId : meetDocId ,
68+ exports . setUserMeet = function ( userEmail , orgDomain , teamId , teamMembers , title , startTime , endTime , hostEmail , description , date , roomId ) {
69+ const setMeetDoc1 = db . collection ( "UserMeets" ) . doc ( userEmail ) . collection ( "Meets" ) . doc ( roomId ) . set ( {
7470 OrgDomain : orgDomain ,
7571 TeamId : teamId ,
7672 TeamMembers : teamMembers ,
7773 Title : title ,
7874 StartTime : startTime ,
7975 EndTime : endTime ,
80- HostName : hostName ,
76+ HostEmail : hostEmail ,
8177 Status : "OK" ,
8278 Description : description ,
8379 Date : date ,
84- Uid : uid ,
8580 RoomId : roomId ,
8681 } ) ;
8782 return Promise . resolve ( setMeetDoc1 ) ;
8883} ;
8984
9085/**
9186 * Description
92- * @param {any } uid
93- * @param {any } docId
87+ * @param {any } email
88+ * @param {any } roomId
9489 * @param {any } updateMeetDetailsToJson
9590 * @return {any }
9691 */
97- exports . updateUserMeetDetails = function ( uid , docId , updateMeetDetailsToJson ) {
98- const updateMeet = db . collection ( "Users " ) . doc ( uid ) . collection ( "Meet " ) . doc ( docId ) . update ( updateMeetDetailsToJson ) ;
92+ exports . updateUserMeetDetails = function ( email , roomId , updateMeetDetailsToJson ) {
93+ const updateMeet = db . collection ( "UserMeets " ) . doc ( email ) . collection ( "Meets " ) . doc ( roomId ) . update ( updateMeetDetailsToJson ) ;
9994 return Promise . resolve ( updateMeet ) ;
10095} ;
10196
@@ -114,30 +109,18 @@ exports.updateMeetDetails= function(updateJson, meetDocId) {
114109
115110/**
116111 * Description
117- * @param {any } meetDocId
112+ * @param {any } email
113+ * @param {any } today
118114 * @return {any }
119115 */
120- exports . getWorktezMeetDetails = function ( meetDocId ) {
121- const query = db . collection ( "Meet" ) . doc ( meetDocId ) ;
122- const promise = query . get ( ) . then ( ( doc ) => {
123- const data = [ ] ;
124- doc . forEach ( ( element ) => {
125- if ( element . exists ) {
126- data . push ( element . data ( ) ) ;
127- }
128- } ) ;
129- return data ;
130- } ) ;
131- return Promise . resolve ( promise ) ;
132- } ;
133-
134- /**
135- * Description
136- * @param {any } uid
137- * @return {any }
138- */
139- exports . getMeetDetails = function ( uid ) {
140- const query = db . collection ( "Users" ) . doc ( uid ) . collection ( "Meet" ) . where ( "Status" , "==" , "OK" ) ;
116+ exports . getMeetDetails = function ( email , today = "" ) {
117+ let query = db . collection ( "UserMeets" ) . doc ( email ) . collection ( "Meets" ) . where ( "Status" , "==" , "OK" ) ;
118+ if ( today != "" ) {
119+ // @TODO Select only meetings future meetings of the day ( by Time )
120+ // @TODO Create a scheduler fn for marking past meetings as 'Completed' or 'Ended', It should run with daily scheduler.
121+ // @TODO Create a scheduler fn for deleting the old meetings from database.S
122+ query = query . where ( "Date" , "==" , today ) ;
123+ }
141124 const promise = query . get ( ) . then ( ( doc ) => {
142125 const data = [ ] ;
143126 doc . forEach ( ( element ) => {
@@ -154,24 +137,47 @@ exports.getMeetDetails=function(uid) {
154137/**
155138 * Description
156139 * @param {any } updateJson
157- * @param {any } meetDocId
140+ * @param {any } roomId
158141 * @return {any }
159142 */
160- exports . updateMeetDetailsAtWorktez = function ( updateJson , meetDocId ) {
161- const updateMeet = db . collection ( "Meet " ) . doc ( meetDocId ) . update ( updateJson ) ;
143+ exports . updateMeetDetailsByID = function ( updateJson , roomId ) {
144+ const updateMeet = db . collection ( "Meets " ) . doc ( roomId ) . update ( updateJson ) ;
162145 return Promise . resolve ( updateMeet ) ;
163146} ;
164147
165148/**
166149 * Description
167- * @param {any } uid
150+ * @param {any } email
168151 * @param {any } docId
169152 * @return {any }
170153 */
171- exports . getUserMeetDetailsById = function ( uid , docId ) {
172- const getUserMeetDetailsById = db . collection ( "Users " ) . doc ( uid ) . collection ( "Meet " ) . doc ( docId ) . get ( ) . then ( ( doc ) => {
154+ exports . getUserMeetDetailsById = function ( email , docId ) {
155+ const getUserMeetDetailsById = db . collection ( "UserMeets " ) . doc ( email ) . collection ( "Meets " ) . doc ( docId ) . get ( ) . then ( ( doc ) => {
173156 const data = doc . data ( ) ;
174157 return data ;
175158 } ) ;
176159 return Promise . resolve ( getUserMeetDetailsById ) ;
177160} ;
161+
162+ exports . generateRoomId = function ( ) {
163+ const alphabet = "abcdefghijklmnopqrstuvwxyz" ;
164+ const idLength = 9 ;
165+ let id = "" ;
166+
167+ // Loop through and add a random character to the ID until it reaches the desired length
168+ while ( id . length < idLength ) {
169+ const randomIndex = Math . floor ( Math . random ( ) * alphabet . length ) ;
170+ id += alphabet [ randomIndex ] ;
171+ }
172+ console . log ( "Room id given" , id ) ;
173+ return id ;
174+ } ;
175+
176+ exports . getRoomDetailsById = function ( id ) {
177+ console . log ( "Checking for" , id ) ;
178+ const promise = db . collection ( "Meets" ) . doc ( id ) . get ( ) . then ( ( doc ) => {
179+ const data = doc . data ( ) ;
180+ return data ;
181+ } ) ;
182+ return Promise . resolve ( promise ) ;
183+ } ;
0 commit comments