@@ -394,7 +394,19 @@ export class CallMembership {
394394 }
395395 }
396396
397- public createdTs ( ) : number {
397+ /**
398+ * The last update to this membership.
399+ * @returns The timestamp when this membership was last updated.
400+ */
401+ public updatedTs ( ) : number {
402+ return this . matrixEvent . getTs ( ) ;
403+ }
404+
405+ /**
406+ * The ts of the initial connection of this membership.
407+ * @returns The timestamp when this membership was initially connected.
408+ */
409+ public connectedTs ( ) : number {
398410 const { kind, data } = this . membershipData ;
399411 switch ( kind ) {
400412 case "rtc" :
@@ -405,19 +417,34 @@ export class CallMembership {
405417 }
406418 }
407419
420+ /** @deprecated use connectedTs instead */
421+ public createdTs ( ) : number {
422+ return this . connectedTs ( ) ;
423+ }
424+
408425 /**
409426 * Gets the absolute expiry timestamp of the membership.
427+ *
428+ * The absolute expiry based on DEFAULT_EXPIRE_DURATION and `sessionData.expires`.
429+ *
430+ * ### Note:
431+ * This concept is not required for m.rtc.member sticky events anymore. the sticky timeout serves takes care of
432+ * this logic automatically (removing member events that have were missed to get removed manually or via delayed events)
433+ * So this is mostly relevant for legacy m.call.member events.
434+ * It is planned to remove manual expiration logic entirely once m.rtc.member is widely adopted.
435+ *
410436 * @returns The absolute expiry time of the membership as a unix timestamp in milliseconds or undefined if not applicable
411437 */
412438 public getAbsoluteExpiry ( ) : number | undefined {
413439 const { kind, data } = this . membershipData ;
414440 switch ( kind ) {
415441 case "rtc" :
416- return this . createdTs ( ) + DEFAULT_EXPIRE_DURATION ;
442+ // Rtc events do not have an data.expires field that gets updated
443+ // Instead the sticky event is resent.
444+ return this . updatedTs ( ) + DEFAULT_EXPIRE_DURATION ;
417445 case "session" :
418446 default :
419- // TODO: calculate this from the MatrixRTCSession join configuration directly
420- return this . createdTs ( ) + ( data . expires ?? DEFAULT_EXPIRE_DURATION ) ;
447+ return this . connectedTs ( ) + ( data . expires ?? DEFAULT_EXPIRE_DURATION ) ;
421448 }
422449 }
423450
0 commit comments