mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-05-13 16:07:30 +00:00
fix: reject expired retained share creation
This commit is contained in:
parent
c2990b4d2e
commit
e76bb6aff5
2 changed files with 7 additions and 8 deletions
|
|
@ -105,7 +105,7 @@ describe('share routes retention', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('keeps new shares on the parent expiration when the retained conversation expired', async () => {
|
||||
it('rejects new shares when the retained conversation expired', async () => {
|
||||
mongoose.models.Conversation.findOne.mockReturnValue(lean(expiredRetainedConvo));
|
||||
createSharedLink.mockResolvedValue({ shareId: 'share-123' });
|
||||
|
||||
|
|
@ -113,14 +113,9 @@ describe('share routes retention', () => {
|
|||
.post('/api/share/convo-123')
|
||||
.send({ targetMessageId: 'msg-123' });
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.status).toBe(404);
|
||||
expect(createTempChatExpirationDate).not.toHaveBeenCalled();
|
||||
expect(createSharedLink).toHaveBeenCalledWith(
|
||||
'user-123',
|
||||
'convo-123',
|
||||
'msg-123',
|
||||
expiredRetainedConvo.expiredAt,
|
||||
);
|
||||
expect(createSharedLink).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('expires updated shares for retained non-temporary conversations', async () => {
|
||||
|
|
|
|||
|
|
@ -141,6 +141,10 @@ router.post('/:conversationId', requireJwtAuth, async (req, res) => {
|
|||
try {
|
||||
const { targetMessageId } = req.body;
|
||||
const expiredAt = await getSharedLinkExpiration(req, req.params.conversationId);
|
||||
if (expiredAt != null && !isActiveExpirationDate(expiredAt)) {
|
||||
return res.status(404).end();
|
||||
}
|
||||
|
||||
const created = await createSharedLink(
|
||||
req.user.id,
|
||||
req.params.conversationId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue