Skip to content

Commit

Permalink
🐛 Debug: added channels list debug method
Browse files Browse the repository at this point in the history
  • Loading branch information
rezk2ll committed Mar 7, 2024
1 parent 60510c1 commit dc10ba2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,57 @@ export class ChannelCrudController
};
}

async listDebug(
request: FastifyRequest<{
Querystring: ChannelListQueryParameters;
Params: BaseChannelsParameters;
}>,
): Promise<ResourceListResponse<ChannelObject>> {
const context = getExecutionContext(request);
// TODO: remove when debug is done.
context.user.server_request = true;
context.user.id = "12d4bb30-7274-11ea-a178-0242ac120004";
context.user.email = "[email protected]";
context.user.identity_provider_id = "5ffd789d5010fa00196f360d";

const list = await gr.services.channels.channels.list(
new Pagination(request.query.page_token, request.query.limit),
{ ...request.query },
context,
);

let entities = [];
if (request.query.include_users) {
entities = [];
for (const e of list.getEntities()) {
entities.push(
await gr.services.channels.channels.includeUsersInDirectChannel(e, context.user.id),
);
}
} else {
entities = list.getEntities();
}

const resources = entities.map(a => ChannelObject.mapTo(a));

await gr.services.channels.channels.completeWithStatistics(resources);

return {
...{
resources: resources,
},
...(request.query.websockets && {
websockets: gr.platformServices.realtime.sign(
getWorkspaceRooms(request.params, request.currentUser),
request.currentUser.id,
),
}),
...(list.page_token && {
next_page_token: list.page_token,
}),
};
}

async delete(
request: FastifyRequest<{ Params: ChannelParameters }>,
reply: FastifyReply,
Expand Down
2 changes: 1 addition & 1 deletion twake/backend/node/src/services/channels/web/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const routes: FastifyPluginCallback = (fastify: FastifyInstance, options, next)
fastify.route({
method: "GET",
url: `${channelsUrl}debug`,
handler: channelsController.list.bind(channelsController),
handler: channelsController.listDebug.bind(channelsController),
});

fastify.route({
Expand Down

0 comments on commit dc10ba2

Please sign in to comment.