mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Support multiple chats per group. Fix A/N metadata not saving for groups.
This commit is contained in:
33
server.js
33
server.js
@ -1381,22 +1381,19 @@ app.post("/getallchatsofcharacter", jsonParser, function (request, response) {
|
||||
lastLine = line;
|
||||
});
|
||||
rl.on('close', () => {
|
||||
ii--;
|
||||
if (lastLine) {
|
||||
let jsonData = json5.parse(lastLine);
|
||||
if (jsonData.name !== undefined) {
|
||||
if (jsonData.name !== undefined || jsonData.character_name !== undefined) {
|
||||
chatData[i] = {};
|
||||
chatData[i]['file_name'] = file;
|
||||
chatData[i]['mes'] = jsonData['mes'];
|
||||
ii--;
|
||||
if (ii === 0) {
|
||||
console.log('ii count went to zero, responding with chatData');
|
||||
response.send(chatData);
|
||||
}
|
||||
} else {
|
||||
console.log('just returning from getallchatsofcharacter');
|
||||
return;
|
||||
chatData[i]['mes'] = jsonData['mes'] || '[The chat is empty]';
|
||||
}
|
||||
}
|
||||
if (ii === 0) {
|
||||
console.log('ii count went to zero, responding with chatData');
|
||||
response.send(chatData);
|
||||
}
|
||||
console.log('successfully closing getallchatsofcharacter');
|
||||
rl.close();
|
||||
});
|
||||
@ -1794,6 +1791,22 @@ app.post('/getgroupchat', jsonParser, (request, response) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/deletegroupchat', jsonParser, (request, response) => {
|
||||
if (!request.body || !request.body.id) {
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
const id = request.body.id;
|
||||
const pathToFile = path.join(directories.groupChats, `${id}.jsonl`);
|
||||
|
||||
if (fs.existsSync(pathToFile)) {
|
||||
fs.rmSync(pathToFile);
|
||||
return response.send({ ok: true });
|
||||
}
|
||||
|
||||
return response.send({ error: true });
|
||||
});
|
||||
|
||||
app.post('/savegroupchat', jsonParser, (request, response) => {
|
||||
if (!request.body || !request.body.id) {
|
||||
return response.sendStatus(400);
|
||||
|
Reference in New Issue
Block a user