group select chats
This commit is contained in:
@@ -262,13 +262,17 @@ piRestRouter.delete('/pi/sessions', async (ctx: Context) => {
|
||||
}
|
||||
|
||||
const body = await ctx.req.json().catch(() => ({}));
|
||||
const sessionIds = Array.isArray(body.sessionIds) ? (body.sessionIds as string[]) : undefined;
|
||||
const contextFilter = body.context
|
||||
? { context: body.context as string, contextId: body.contextId as string | undefined }
|
||||
: undefined;
|
||||
const userHome = getHomeDir(user.email);
|
||||
|
||||
try {
|
||||
const sessions = await storage.listUserSessions(userHome, contextFilter);
|
||||
const allSessions = await storage.listUserSessions(userHome, contextFilter);
|
||||
const sessions = sessionIds
|
||||
? allSessions.filter((s) => sessionIds.includes(s.id))
|
||||
: allSessions;
|
||||
let deleted = 0;
|
||||
for (const session of sessions) {
|
||||
try {
|
||||
@@ -283,6 +287,7 @@ piRestRouter.delete('/pi/sessions', async (ctx: Context) => {
|
||||
deleted,
|
||||
total: sessions.length,
|
||||
context: contextFilter?.context,
|
||||
sessionIds: sessionIds?.length,
|
||||
});
|
||||
return ctx.json({ success: true, deleted });
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user