mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-10-13 19:18:14 +00:00
Handling double stringify JSON parsing
This commit is contained in:
@@ -67,8 +67,10 @@ fs.readdirSync(migrationsFolder)
|
|||||||
`);
|
`);
|
||||||
|
|
||||||
messages.forEach((msg: any) => {
|
messages.forEach((msg: any) => {
|
||||||
if (msg.type === 'user') {
|
while (typeof msg.metadata === 'string') {
|
||||||
msg.metadata = JSON.parse(msg.metadata || '{}');
|
msg.metadata = JSON.parse(msg.metadata || '{}');
|
||||||
|
}
|
||||||
|
if (msg.type === 'user') {
|
||||||
insertMessage.run(
|
insertMessage.run(
|
||||||
'user',
|
'user',
|
||||||
msg.chatId,
|
msg.chatId,
|
||||||
@@ -78,7 +80,6 @@ fs.readdirSync(migrationsFolder)
|
|||||||
'[]',
|
'[]',
|
||||||
);
|
);
|
||||||
} else if (msg.type === 'assistant') {
|
} else if (msg.type === 'assistant') {
|
||||||
msg.metadata = JSON.parse(msg.metadata || '{}');
|
|
||||||
insertMessage.run(
|
insertMessage.run(
|
||||||
'assistant',
|
'assistant',
|
||||||
msg.chatId,
|
msg.chatId,
|
||||||
|
Reference in New Issue
Block a user