MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / wsOrganizationEvents

Function wsOrganizationEvents

apps/api/src/controllers/live.controller.ts:143–181  ·  view source on GitHub ↗
(
  socket: WebSocket,
  req: FastifyRequest<{
    Params: {
      organizationId: string;
    };
  }>
)

Source from the content-addressed store, hash-verified

141}
142
143export async function wsOrganizationEvents(
144 socket: WebSocket,
145 req: FastifyRequest<{
146 Params: {
147 organizationId: string;
148 };
149 }>
150) {
151 guardSocket(socket, req);
152 const { params } = req;
153 const userId = req.session?.userId;
154
155 if (!userId) {
156 socket.send('No active session');
157 socket.close();
158 return;
159 }
160
161 const access = await getOrganizationAccess({
162 userId,
163 organizationId: params.organizationId,
164 });
165
166 if (!access) {
167 socket.send('No access');
168 socket.close();
169 return;
170 }
171
172 const unsubscribe = subscribeToPublishedEvent(
173 'organization',
174 'subscription_updated',
175 (message) => {
176 socket.send(setSuperJson(message));
177 }
178 );
179
180 socket.on('close', () => unsubscribe());
181}

Callers

nothing calls this directly

Calls 5

setSuperJsonFunction · 0.90
guardSocketFunction · 0.85
closeMethod · 0.80
sendMethod · 0.45

Tested by

no test coverage detected