"use strict";(this.webpackChunk_msteams_react_web_client=this.webpackChunk_msteams_react_web_client||[]).push([[63966],{335897:(e,r,t)=>{var s;t.r(r),t.d(r,{CallRecordingService:()=>w}),function(e){e.Undefined="Undefined",e.Unknown="Unknown"}(s||(s={}));var o=t(135449),n=t(553840),i=t(182635);const a={GET_CALL_RECORDING:"beta/meetings/recording"},c=({discover:e,authenticationResources:r,platformService:t,config:s})=>{const i=(0,n.B)(t,s);return{baseUrlPromise:()=>e.regionGtm("middleTier"),serviceName:o.p.MiddleTier,authResource:r.mtAuthResource,models:{callRecordingInfo:d(i)}}},d=e=>Promise.resolve({constructRequest:r=>({authOptions:{source:"CMDStable"},url:g(r),method:"GET",headers:e,serviceName:o.p.MiddleTier,apiName:"recording"})}),g=e=>{const{tenantId:r,userId:t,threadId:s,messageId:o,limit:n,recordingMessageIds:c}=e;let d=a.GET_CALL_RECORDING;return d=(0,i.rs)(d,"tenantId",r),d=(0,i.rs)(d,"userId",t),d=(0,i.rs)(d,"threadId",s),d=(0,i.rs)(d,"messageId",o),d=(0,i.rs)(d,"limit",n?.toString()||""),c&&(d=(0,i.rs)(d,"recordingMessageIds",c.toString())),d};var l=t(401368),u=t(134185),m=t(400695),h=t(128860),p=t(506456);const R=(e,r)=>r.get(e)||0;function T(e){return Promise.resolve({constructRequest:e,retryPolicy:(r=[[u.nW.SERVER_TIMEOUT,2],[m.B.RejectHttpError,3],[m.B.FailedToFetch,3],[m.B.TransformFailed,3]],t=3,{shouldRetry:(e,s,o)=>e<t&&r.some((([e,r])=>s===e&&R(e,o)<r)),nextDelay:e=>1e3*Math.pow(1.5,e)}),rejectHttpError:!0,allowedResponses:[u.nW.OK,u.nW.CREATED,u.nW.ACCEPTED,u.nW.NO_CONTENT]});var r,t}const y=e=>{const{status:r}=e;return r>=u.nW.BAD_REQUEST?Promise.reject((0,h.$)(m.B.TransformFailed)):Promise.resolve("success")},f=e=>{const{authenticationResources:r,authenticationService:t,coreSettings:s}=e,{callRecorderResource:n}=s.get(l.w.Calling),i=(0,p.e)(T),a=r.composeAuthResources((e=>t.authorizeRequest(e,n||"")),r.skypeXTokenAuthResource);return{baseUrl:"https://api.flightproxy.teams.microsoft.com/api/v2/ep/",serviceName:o.p.Skype,authResource:a,models:{retryUploadRecordings:i(I).withTransform(y)}}},I=(e,r,t,s,o,n,i,a,c)=>({url:e.split("://")[1],method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({errorReport:c,notificationData:i,exportMetadata:a,ownerObjectId:r,ownerTenantId:t,ownerMri:s,userToken:n,amsObjectId:o})});var v=t(912435);class w{constructor(e,r){this.loggerFactory=e,this.logger=this.loggerFactory.newLogger("CallRecordingService","services-io-call-recording"),this.transport=r.createApi(c),this.botTransport=r.createApi(f)}async getRecordings(e,r,t){let o;this.logger.log(`Getting recordings for thread ${e.threadId}`);try{o=await this.transport.callRecordingInfo({...e,limit:r,recordingMessageIds:t})}catch(e){const r=e.serverResponse?.body?.status,t=await(e.serverResponse?.body?.json()),o=t&&t.errorCode||(0,v.rX)(e);return this.logger.error(`Fail to get recordings from MT: response status is ${r}`),Promise.reject(o||s.Unknown)}if(o&&o.streamRecordings){if(r){const e=o.streamRecordings.length;e>r&&this.logger.warn(`The limit number of call recordings is set to ${r} but get ${e} recordings`)}return{recordings:o.streamRecordings,availableRecordingsCount:o.availableRecordingsCount}}return Promise.reject(s.Undefined)}async retryUploadRecordings(e,r,t,s,o,n,i,a,c){this.logger.log(`Retry upload request started, requesting endpoint ${e} for recording ${o}`);try{const d=await this.botTransport.retryUploadRecordings(e,r,t,s,o,n,i,a,c);return this.logger.log("Successfully send retry upload request."),d}catch(s){const n=!!r&&!!t,a="string"==typeof i.meetingOrganizerId&&i.meetingOrganizerId.endsWith(r),c=i.meetingOrganizerTenantId===t;return this.logger.error(`Retry upload request failed with errorCode: ${s.errorCode}, endpoint: ${e}; amsObjectId: ${o}; isValidOwner: ${n}; isSameMeetingOrganizer: ${a}; isSameTenant: ${c}.`),Promise.reject(s)}}}}}]);
//# sourceMappingURL=https://local.teams.office.com/sourcemaps/hashed-assets/services-call-recording-8ac5c8a2bff2e24b.js.map