@@ -442,10 +442,13 @@ def _rtc_join_call(self, store: Store = None, check_rtc_session_ids=None, camera
442442 "_store_rtc_update_fields" ,
443443 fields_params = {"added" : rtc_updates [0 ], "removed" : rtc_updates [1 ]},
444444 )
445+ has_sfu = bool (discuss .get_sfu_url (self .env ))
445446 store .add_singleton_values (
446447 "Rtc" ,
447448 lambda res : (
448449 res .attr ("iceServers" , ice_servers or False ),
450+ res .attr ("canRecord" , has_sfu ),
451+ res .attr ("canTranscribe" , has_sfu ),
449452 res .one ("localSession" , "_store_rtc_session_fields" , value = rtc_session ),
450453 res .attr ("serverInfo" , self ._get_rtc_server_info (rtc_session , ice_servers )),
451454 ),
@@ -454,7 +457,10 @@ def _rtc_join_call(self, store: Store = None, check_rtc_session_ids=None, camera
454457 self ._rtc_invite_members ()
455458
456459 def _join_sfu (self , ice_servers = None , force = False ):
457- if len (self .channel_id .rtc_session_ids ) < SFU_MODE_THRESHOLD and not force :
460+ session_count = len (self .channel_id .rtc_session_ids )
461+ if session_count < 2 :
462+ return # cant join a SFU when alone
463+ if session_count < SFU_MODE_THRESHOLD and not force :
458464 if self .channel_id .sfu_channel_uuid :
459465 self .channel_id .sfu_channel_uuid = None
460466 self .channel_id .sfu_server_url = None
@@ -475,9 +481,13 @@ def _join_sfu(self, ice_servers=None, force=False):
475481 algorithm = jwt .Algorithm .HS256 ,
476482 )
477483 try :
484+ recording_address = (
485+ f"{ self .get_base_url ()} /mail/rtc/recording/routing/{ self .channel_id .id } "
486+ )
478487 response = requests .get (
479488 sfu_server_url + "/v1/channel" ,
480489 headers = {"Authorization" : "jwt " + json_web_token },
490+ params = {"recordingAddress" : recording_address },
481491 timeout = 3 ,
482492 )
483493 response .raise_for_status ()
@@ -500,9 +510,11 @@ def _get_rtc_server_info(self, rtc_session, ice_servers=None, key=None):
500510 return None
501511 if not key :
502512 key = self .env ["ir.config_parameter" ].sudo ().get_str ("mail.sfu_local_key" )
513+ is_partner = bool (rtc_session .partner_id )
503514 claims = {
504515 "session_id" : rtc_session .id ,
505516 "ice_servers" : ice_servers ,
517+ "permissions" : {"recording" : is_partner , "transcription" : is_partner }
506518 }
507519 json_web_token = jwt .sign (claims , key = key , ttl = 60 * 60 * 8 , algorithm = jwt .Algorithm .HS256 ) # 8 hours
508520 return {"url" : sfu_server_url , "channelUUID" : sfu_channel_uuid , "jsonWebToken" : json_web_token }
0 commit comments