Skip to content

Custom send-event is not being in OwnCapabilities #1987

@Vondry

Description

@Vondry

Which package/packages do you use?

  • @stream-io/video-react-sdk
  • @stream-io/video-react-native-sdk
  • @stream-io/video-client

Describe the bug

  1. When sending custom event I had to setup send-event call type grant, which i did not find documented either in https://getstream.io/video/docs/react/guides/custom-events/ or https://getstream.io/video/docs/react/advanced/events/
  2. But the bug I see is that i do not see this in capabilities on the client, nor there is custom capability that i can check, if user can send custom events

To Reproduce
Steps to reproduce the behavior:

If you for example invoke this custom event warnUser for warning users, you need to have send-event as a setup grant.

import type { Call, UserResponse } from '@stream-io/video-react-sdk';

type WarnUserEvent = {
  type: 'warning';
  warn_by_user: Pick<UserResponse, 'name' | 'id'>;
  user: Pick<UserResponse, 'name' | 'id'>;
};

export const useCallWarning = (call: Call) => {
  const warnUser = (
    issuer: WarnUserEvent['warn_by_user'],
    user: WarnUserEvent['user'],
  ) =>
    call.sendCustomEvent({
      type: 'warning',
      warn_by_user: issuer,
      user,
    } satisfies WarnUserEvent);

  const onWarn = (event: WarnUserEvent) => {
    console.log('onWarn', event);
  };

  const isWarnEvent = (event: Record<string, any>): event is WarnUserEvent =>
    event.type === 'warning';

  return { warnUser, onWarn, isWarnEvent };
};

And if i filter later in my component:

  const { useOwnCapabilities } = useCallStateHooks();
  const capabilities = useOwnCapabilities();
  const canSendCustomEvent = capabilities?.includes('send-event');

I do not see send-event in capabilities althought the code works and events are being sent and received.

Expected behavior
I would expect:

  1. send-event to be in capabilities list
  2. send-event capability would be available on OwnCapability object eg. OwnCapability.SEND_EVENT

Screenshots
If applicable, add screenshots to help explain your problem.

Version

  • SDK version: "@stream-io/video-react-sdk": "^1.25.0"
  • It is a React application with PHP backend

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions