setSpaceOperator method

void setSpaceOperator(
  1. String spaceId,
  2. String? agentId
)

Makes agentId the default operator of spaceId (default_operator_agent_id), or removes it for null, and refreshes the operator.effective_agent_id of the space's channels that inherit (03 channels, 10 5.2 point 1).

Implementation

void setSpaceOperator(String spaceId, String? agentId) {
  final space = spaces[spaceId]!;
  if (agentId == null) {
    space.remove('default_operator_agent_id');
  } else {
    space['default_operator_agent_id'] = agentId;
  }
  for (final c in channels.values) {
    final op = c.json['operator'] as JsonMap?;
    if (c.spaceId == spaceId && op?['mode'] == 'inherit') {
      c.json['operator'] = _inheritOperator(spaceId);
    }
  }
}