Add error handling to group parsing in chat search
| @@ -561,11 +561,15 @@ router.post('/search', jsonParser, function (request, response) { | ||
| 561 | 561 | |
| 562 | 562 | let targetGroup; |
| 563 | 563 | for (const groupFile of groupFiles) { |
| 564 | + try { | |
| 564 | 565 | const groupData = JSON.parse(fs.readFileSync(path.join(groupDir, groupFile), 'utf8')); |
| 565 | 566 | if (groupData.id === group_id) { |
| 566 | 567 | targetGroup = groupData; |
| 567 | 568 | break; |
| 568 | 569 | } |
| 570 | + } catch (error) { | |
| 571 | + console.error(groupFile, 'group file is corrupted:', error); | |
| 572 | + } | |
| 569 | 573 | } |
| 570 | 574 | |
| 571 | 575 | if (!targetGroup?.chats) { |