daily-co / daily-js

https://docs.daily.co/reference/daily-js
BSD 2-Clause "Simplified" License
103 stars 33 forks source link

Owner unable to mute participant when tokens includes userId #206

Closed swemail closed 1 year ago

swemail commented 1 year ago

Same issue as reported here but maybe it belongs here instead?

Hello and thank you for this great service and library!

I found and issue muting participants in a meeting when the userId is included in the meeting token.

Expected behavior

As a user joining with token including owner: true and userId: "some-user-id" I should be able to mute other participants joining with tokens including owner: false and userId: "some-other-user-id"

Describe the bug (unexpected behavior)

When creating a token, via the api or self signed, and including the userId I get update setAudio can't be applied to participant {{userId}}; skipping null when as an owner calling updateParticipant on the daily call object like

call.updateParticipant(participant.user_id, {setAudio: !muted})

If I exclude the userId from the token it works.

This is how we create tokens:

import dayjs from 'dayjs';
import jwt from 'jsonwebtoken';
import {getDomainId} from './dailyApi';
import config from './config';

const {DAILY_API_KEY} = config;

export const generateSessionToken = async (
  roomName: string,
  isHost: boolean,
  expireDate: dayjs.Dayjs,
  userId?: string,
): Promise<string> => {
  const domainId = await getDomainId();

  const payload = {
    r: roomName,
    d: domainId,
    ud: userId,
    iat: dayjs().unix(),
    exp: expireDate.unix(),
    o: isHost,
  };

  return jwt.sign(payload, DAILY_API_KEY);
};

Is this expected behaviour? I could not find anything in the documentation about excluding userId from tokens for the owner to be able to mute others.