2025-03-07 17:55:44 +01:00
|
|
|
const mongoose = require('mongoose');
|
2024-08-05 03:34:00 -04:00
|
|
|
const { nanoid } = require('nanoid');
|
|
|
|
|
const { Constants } = require('librechat-data-provider');
|
2025-01-21 15:31:05 +01:00
|
|
|
const { Conversation } = require('~/models/Conversation');
|
2025-03-07 17:55:44 +01:00
|
|
|
const { shareSchema } = require('@librechat/data-schemas');
|
|
|
|
|
const SharedLink = mongoose.model('SharedLink', shareSchema);
|
2024-08-05 03:34:00 -04:00
|
|
|
const { getMessages } = require('./Message');
|
🚀 feat: Shared Links (#2772)
* ✨ feat(types): add necessary types for shared link feature
* ✨ feat: add shared links functions to data service
Added functions for retrieving, creating, updating, and deleting shared links and shared messages.
* ✨ feat: Add useGetSharedMessages hook to fetch shared messages by shareId
Adds a new hook `useGetSharedMessages` which fetches shared messages based on the provided shareId.
* ✨ feat: Add share schema and data access functions to API models
* ✨ feat: Add share endpoint to API
The GET /api/share/${shareId} is exposed to the public, so authentication is not required. Other paths require authentication.
* ♻️ refactor(utils): generalize react-query cache manipulation functions
Introduces generic functions for manipulating react-query cache entries, marking a refinement in how query cache data is managed. It aims to enhance the flexibility and reusability of the cache interaction patterns within our application.
- Replaced specific index names with more generic terms in queries.ts, enhancing consistency across data handling functions.
- Introduced new utility functions in collection.ts for adding, updating, and deleting data entries in an InfiniteData<TCollection>. These utility functions (`addData`, `updateData`, `deleteData`, `findPage`) are designed to be re-usable across different data types and collections.
- Adapted existing conversation utility functions in convos.ts to leverage these new generic utilities.
* ✨ feat(shared-link): add functions to manipulate shared link cache list
implemented new utility functions to handle additions, updates, and deletions in the shared link cache list.
* ✨ feat: Add mutations and queries for shared links
* ✨ feat(shared-link): add `Share` button to conversation list
- Added a share button in each conversation in the conversation list.
- Implemented functionality where clicking the share button triggers a POST request to the API.
- The API checks if a share link was already created for the conversation today; if so, it returns the existing link.
- If no link was created for today, the API will create a new share link and return it.
- Each click on the share button results in a new API request, following the specification similar to ChatGPT's share link feature.
* ♻️ refactor(hooks): generalize useNavScrolling for broader use
- Modified `useNavScrolling` to accept a generic type parameter `TData`, allowing it to be used with different data structures besides `ConversationListResponse`.
- Updated instances in `Nav.tsx` and `ArchivedChatsTable.tsx` to explicitly specify `ConversationListResponse` as the type argument when invoking `useNavScrolling`.
* ✨ feat(settings): add shared links listing table with delete functionality in settings
- Integrated a delete button for each shared link in the table, allowing users to remove links as needed.
* ♻️ refactor(components): separate `EndpointIcon` from `Icon` component for standalone use
* ♻️ refactor: update useGetSharedMessages to return TSharedLink
- Modified the useGetSharedMessages hook to return not only a list of TMessage but also the TSharedLink itself.
- This change was necessary to support displaying the title and date in the Shared Message UI, which requires data from TSharedLink.
* ✨ feat(shared link): add UI for displaying shared conversations without authentication
- Implemented a new UI component to display shared conversations, designed to be accessible without requiring authentication.
- Reused components from the authenticated Messages module where possible. Copied and adapted components that could not be directly reused to fit the non-authenticated context.
* 🔧 chore: Add translations
Translate labels only. Messages remain in English as they are possibly subject to change.
* ♻️ refactor: add icon and tooltip props to EditMenuButton component
* moved icon and popover to arguments so that EditMenuButton can be reused.
* modified so that when a ShareButton is closed, the parent DropdownMenu is also closed.
* ♻️irefactor: added DropdownMenu for Export and Share
* ♻️ refactor: renamed component names more intuitive
* More accurate naming of the dropdown menu.
* When the export button is closed, the parent dropdown menu is also closed.
* 🌍 chore: updated translations
* 🐞 Fix: OpenID Profile Image Download (#2757)
* Add fetch requirement
Fixes - error: [openidStrategy] downloadImage: Error downloading image at URL "https://graph.microsoft.com/v1.0/me/photo/$value": TypeError: response.buffer is not a function
* Update openidStrategy.js
---------
Co-authored-by: Danny Avila <danacordially@gmail.com>
* 🚑 fix(export): Issue exporting Conversation with Assistants (#2769)
* 🚑 fix(export): use content as text if content is present in the message
If the endpoint is assistants, the text of the message goes into content, not message.text.
* refactor(ExportModel): TypeScript, remove unused code
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
* 📤style: export button icon (#2752)
* refactor(ShareDialog): logic and styling
* refactor(ExportAndShareMenu): imports order and icon update
* chore: imports
* chore: imports/render logic
* feat: message branching
* refactor: add optional config to useGetStartupConfig
* refactor: disable endpoints query
* chore: fix search view styling gradient in light mode
* style: ShareView gradient styling
* refactor(Share): use select queries
* style: shared link table buttons
* localization and dark text styling
* style: fix clipboard button layout shift app-wide and add localization for copy code
* support assistants message content in shared links, add useCopyToClipboard, add copy buttons to Search Messages and Shared Link Messages
* add localizations
* comparisons
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
Co-authored-by: bsu3338 <bsu3338@users.noreply.github.com>
Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>
2024-05-17 18:13:32 -04:00
|
|
|
const logger = require('~/config/winston');
|
|
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
class ShareServiceError extends Error {
|
|
|
|
|
constructor(message, code) {
|
|
|
|
|
super(message);
|
|
|
|
|
this.name = 'ShareServiceError';
|
|
|
|
|
this.code = code;
|
|
|
|
|
}
|
2024-08-05 03:34:00 -04:00
|
|
|
}
|
|
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
const memoizedAnonymizeId = (prefix) => {
|
|
|
|
|
const memo = new Map();
|
|
|
|
|
return (id) => {
|
|
|
|
|
if (!memo.has(id)) {
|
|
|
|
|
memo.set(id, `${prefix}_${nanoid()}`);
|
|
|
|
|
}
|
|
|
|
|
return memo.get(id);
|
|
|
|
|
};
|
|
|
|
|
};
|
2024-08-05 03:34:00 -04:00
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
const anonymizeConvoId = memoizedAnonymizeId('convo');
|
|
|
|
|
const anonymizeAssistantId = memoizedAnonymizeId('a');
|
|
|
|
|
const anonymizeMessageId = (id) =>
|
|
|
|
|
id === Constants.NO_PARENT ? id : memoizedAnonymizeId('msg')(id);
|
2024-08-05 03:34:00 -04:00
|
|
|
|
|
|
|
|
function anonymizeConvo(conversation) {
|
2025-01-21 15:31:05 +01:00
|
|
|
if (!conversation) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 03:34:00 -04:00
|
|
|
const newConvo = { ...conversation };
|
|
|
|
|
if (newConvo.assistant_id) {
|
2025-01-21 15:31:05 +01:00
|
|
|
newConvo.assistant_id = anonymizeAssistantId(newConvo.assistant_id);
|
2024-08-05 03:34:00 -04:00
|
|
|
}
|
|
|
|
|
return newConvo;
|
|
|
|
|
}
|
🚀 feat: Shared Links (#2772)
* ✨ feat(types): add necessary types for shared link feature
* ✨ feat: add shared links functions to data service
Added functions for retrieving, creating, updating, and deleting shared links and shared messages.
* ✨ feat: Add useGetSharedMessages hook to fetch shared messages by shareId
Adds a new hook `useGetSharedMessages` which fetches shared messages based on the provided shareId.
* ✨ feat: Add share schema and data access functions to API models
* ✨ feat: Add share endpoint to API
The GET /api/share/${shareId} is exposed to the public, so authentication is not required. Other paths require authentication.
* ♻️ refactor(utils): generalize react-query cache manipulation functions
Introduces generic functions for manipulating react-query cache entries, marking a refinement in how query cache data is managed. It aims to enhance the flexibility and reusability of the cache interaction patterns within our application.
- Replaced specific index names with more generic terms in queries.ts, enhancing consistency across data handling functions.
- Introduced new utility functions in collection.ts for adding, updating, and deleting data entries in an InfiniteData<TCollection>. These utility functions (`addData`, `updateData`, `deleteData`, `findPage`) are designed to be re-usable across different data types and collections.
- Adapted existing conversation utility functions in convos.ts to leverage these new generic utilities.
* ✨ feat(shared-link): add functions to manipulate shared link cache list
implemented new utility functions to handle additions, updates, and deletions in the shared link cache list.
* ✨ feat: Add mutations and queries for shared links
* ✨ feat(shared-link): add `Share` button to conversation list
- Added a share button in each conversation in the conversation list.
- Implemented functionality where clicking the share button triggers a POST request to the API.
- The API checks if a share link was already created for the conversation today; if so, it returns the existing link.
- If no link was created for today, the API will create a new share link and return it.
- Each click on the share button results in a new API request, following the specification similar to ChatGPT's share link feature.
* ♻️ refactor(hooks): generalize useNavScrolling for broader use
- Modified `useNavScrolling` to accept a generic type parameter `TData`, allowing it to be used with different data structures besides `ConversationListResponse`.
- Updated instances in `Nav.tsx` and `ArchivedChatsTable.tsx` to explicitly specify `ConversationListResponse` as the type argument when invoking `useNavScrolling`.
* ✨ feat(settings): add shared links listing table with delete functionality in settings
- Integrated a delete button for each shared link in the table, allowing users to remove links as needed.
* ♻️ refactor(components): separate `EndpointIcon` from `Icon` component for standalone use
* ♻️ refactor: update useGetSharedMessages to return TSharedLink
- Modified the useGetSharedMessages hook to return not only a list of TMessage but also the TSharedLink itself.
- This change was necessary to support displaying the title and date in the Shared Message UI, which requires data from TSharedLink.
* ✨ feat(shared link): add UI for displaying shared conversations without authentication
- Implemented a new UI component to display shared conversations, designed to be accessible without requiring authentication.
- Reused components from the authenticated Messages module where possible. Copied and adapted components that could not be directly reused to fit the non-authenticated context.
* 🔧 chore: Add translations
Translate labels only. Messages remain in English as they are possibly subject to change.
* ♻️ refactor: add icon and tooltip props to EditMenuButton component
* moved icon and popover to arguments so that EditMenuButton can be reused.
* modified so that when a ShareButton is closed, the parent DropdownMenu is also closed.
* ♻️irefactor: added DropdownMenu for Export and Share
* ♻️ refactor: renamed component names more intuitive
* More accurate naming of the dropdown menu.
* When the export button is closed, the parent dropdown menu is also closed.
* 🌍 chore: updated translations
* 🐞 Fix: OpenID Profile Image Download (#2757)
* Add fetch requirement
Fixes - error: [openidStrategy] downloadImage: Error downloading image at URL "https://graph.microsoft.com/v1.0/me/photo/$value": TypeError: response.buffer is not a function
* Update openidStrategy.js
---------
Co-authored-by: Danny Avila <danacordially@gmail.com>
* 🚑 fix(export): Issue exporting Conversation with Assistants (#2769)
* 🚑 fix(export): use content as text if content is present in the message
If the endpoint is assistants, the text of the message goes into content, not message.text.
* refactor(ExportModel): TypeScript, remove unused code
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
* 📤style: export button icon (#2752)
* refactor(ShareDialog): logic and styling
* refactor(ExportAndShareMenu): imports order and icon update
* chore: imports
* chore: imports/render logic
* feat: message branching
* refactor: add optional config to useGetStartupConfig
* refactor: disable endpoints query
* chore: fix search view styling gradient in light mode
* style: ShareView gradient styling
* refactor(Share): use select queries
* style: shared link table buttons
* localization and dark text styling
* style: fix clipboard button layout shift app-wide and add localization for copy code
* support assistants message content in shared links, add useCopyToClipboard, add copy buttons to Search Messages and Shared Link Messages
* add localizations
* comparisons
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
Co-authored-by: bsu3338 <bsu3338@users.noreply.github.com>
Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>
2024-05-17 18:13:32 -04:00
|
|
|
|
2024-08-05 03:34:00 -04:00
|
|
|
function anonymizeMessages(messages, newConvoId) {
|
2025-01-21 15:31:05 +01:00
|
|
|
if (!Array.isArray(messages)) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 03:34:00 -04:00
|
|
|
const idMap = new Map();
|
|
|
|
|
return messages.map((message) => {
|
|
|
|
|
const newMessageId = anonymizeMessageId(message.messageId);
|
|
|
|
|
idMap.set(message.messageId, newMessageId);
|
🚀 feat: Shared Links (#2772)
* ✨ feat(types): add necessary types for shared link feature
* ✨ feat: add shared links functions to data service
Added functions for retrieving, creating, updating, and deleting shared links and shared messages.
* ✨ feat: Add useGetSharedMessages hook to fetch shared messages by shareId
Adds a new hook `useGetSharedMessages` which fetches shared messages based on the provided shareId.
* ✨ feat: Add share schema and data access functions to API models
* ✨ feat: Add share endpoint to API
The GET /api/share/${shareId} is exposed to the public, so authentication is not required. Other paths require authentication.
* ♻️ refactor(utils): generalize react-query cache manipulation functions
Introduces generic functions for manipulating react-query cache entries, marking a refinement in how query cache data is managed. It aims to enhance the flexibility and reusability of the cache interaction patterns within our application.
- Replaced specific index names with more generic terms in queries.ts, enhancing consistency across data handling functions.
- Introduced new utility functions in collection.ts for adding, updating, and deleting data entries in an InfiniteData<TCollection>. These utility functions (`addData`, `updateData`, `deleteData`, `findPage`) are designed to be re-usable across different data types and collections.
- Adapted existing conversation utility functions in convos.ts to leverage these new generic utilities.
* ✨ feat(shared-link): add functions to manipulate shared link cache list
implemented new utility functions to handle additions, updates, and deletions in the shared link cache list.
* ✨ feat: Add mutations and queries for shared links
* ✨ feat(shared-link): add `Share` button to conversation list
- Added a share button in each conversation in the conversation list.
- Implemented functionality where clicking the share button triggers a POST request to the API.
- The API checks if a share link was already created for the conversation today; if so, it returns the existing link.
- If no link was created for today, the API will create a new share link and return it.
- Each click on the share button results in a new API request, following the specification similar to ChatGPT's share link feature.
* ♻️ refactor(hooks): generalize useNavScrolling for broader use
- Modified `useNavScrolling` to accept a generic type parameter `TData`, allowing it to be used with different data structures besides `ConversationListResponse`.
- Updated instances in `Nav.tsx` and `ArchivedChatsTable.tsx` to explicitly specify `ConversationListResponse` as the type argument when invoking `useNavScrolling`.
* ✨ feat(settings): add shared links listing table with delete functionality in settings
- Integrated a delete button for each shared link in the table, allowing users to remove links as needed.
* ♻️ refactor(components): separate `EndpointIcon` from `Icon` component for standalone use
* ♻️ refactor: update useGetSharedMessages to return TSharedLink
- Modified the useGetSharedMessages hook to return not only a list of TMessage but also the TSharedLink itself.
- This change was necessary to support displaying the title and date in the Shared Message UI, which requires data from TSharedLink.
* ✨ feat(shared link): add UI for displaying shared conversations without authentication
- Implemented a new UI component to display shared conversations, designed to be accessible without requiring authentication.
- Reused components from the authenticated Messages module where possible. Copied and adapted components that could not be directly reused to fit the non-authenticated context.
* 🔧 chore: Add translations
Translate labels only. Messages remain in English as they are possibly subject to change.
* ♻️ refactor: add icon and tooltip props to EditMenuButton component
* moved icon and popover to arguments so that EditMenuButton can be reused.
* modified so that when a ShareButton is closed, the parent DropdownMenu is also closed.
* ♻️irefactor: added DropdownMenu for Export and Share
* ♻️ refactor: renamed component names more intuitive
* More accurate naming of the dropdown menu.
* When the export button is closed, the parent dropdown menu is also closed.
* 🌍 chore: updated translations
* 🐞 Fix: OpenID Profile Image Download (#2757)
* Add fetch requirement
Fixes - error: [openidStrategy] downloadImage: Error downloading image at URL "https://graph.microsoft.com/v1.0/me/photo/$value": TypeError: response.buffer is not a function
* Update openidStrategy.js
---------
Co-authored-by: Danny Avila <danacordially@gmail.com>
* 🚑 fix(export): Issue exporting Conversation with Assistants (#2769)
* 🚑 fix(export): use content as text if content is present in the message
If the endpoint is assistants, the text of the message goes into content, not message.text.
* refactor(ExportModel): TypeScript, remove unused code
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
* 📤style: export button icon (#2752)
* refactor(ShareDialog): logic and styling
* refactor(ExportAndShareMenu): imports order and icon update
* chore: imports
* chore: imports/render logic
* feat: message branching
* refactor: add optional config to useGetStartupConfig
* refactor: disable endpoints query
* chore: fix search view styling gradient in light mode
* style: ShareView gradient styling
* refactor(Share): use select queries
* style: shared link table buttons
* localization and dark text styling
* style: fix clipboard button layout shift app-wide and add localization for copy code
* support assistants message content in shared links, add useCopyToClipboard, add copy buttons to Search Messages and Shared Link Messages
* add localizations
* comparisons
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
Co-authored-by: bsu3338 <bsu3338@users.noreply.github.com>
Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>
2024-05-17 18:13:32 -04:00
|
|
|
|
2025-04-26 04:30:58 -04:00
|
|
|
const anonymizedAttachments = message.attachments?.map((attachment) => {
|
|
|
|
|
return {
|
|
|
|
|
...attachment,
|
|
|
|
|
messageId: newMessageId,
|
|
|
|
|
conversationId: newConvoId,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
return {
|
|
|
|
|
...message,
|
2024-08-05 03:34:00 -04:00
|
|
|
messageId: newMessageId,
|
|
|
|
|
parentMessageId:
|
|
|
|
|
idMap.get(message.parentMessageId) || anonymizeMessageId(message.parentMessageId),
|
|
|
|
|
conversationId: newConvoId,
|
2025-01-21 15:31:05 +01:00
|
|
|
model: message.model?.startsWith('asst_')
|
|
|
|
|
? anonymizeAssistantId(message.model)
|
|
|
|
|
: message.model,
|
2025-04-26 04:30:58 -04:00
|
|
|
attachments: anonymizedAttachments,
|
2025-01-21 15:31:05 +01:00
|
|
|
};
|
2024-08-05 03:34:00 -04:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getSharedMessages(shareId) {
|
|
|
|
|
try {
|
2025-01-21 15:31:05 +01:00
|
|
|
const share = await SharedLink.findOne({ shareId, isPublic: true })
|
2024-08-05 03:34:00 -04:00
|
|
|
.populate({
|
|
|
|
|
path: 'messages',
|
|
|
|
|
select: '-_id -__v -user',
|
|
|
|
|
})
|
|
|
|
|
.select('-_id -__v -user')
|
|
|
|
|
.lean();
|
|
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
if (!share?.conversationId || !share.isPublic) {
|
2024-08-05 03:34:00 -04:00
|
|
|
return null;
|
🚀 feat: Shared Links (#2772)
* ✨ feat(types): add necessary types for shared link feature
* ✨ feat: add shared links functions to data service
Added functions for retrieving, creating, updating, and deleting shared links and shared messages.
* ✨ feat: Add useGetSharedMessages hook to fetch shared messages by shareId
Adds a new hook `useGetSharedMessages` which fetches shared messages based on the provided shareId.
* ✨ feat: Add share schema and data access functions to API models
* ✨ feat: Add share endpoint to API
The GET /api/share/${shareId} is exposed to the public, so authentication is not required. Other paths require authentication.
* ♻️ refactor(utils): generalize react-query cache manipulation functions
Introduces generic functions for manipulating react-query cache entries, marking a refinement in how query cache data is managed. It aims to enhance the flexibility and reusability of the cache interaction patterns within our application.
- Replaced specific index names with more generic terms in queries.ts, enhancing consistency across data handling functions.
- Introduced new utility functions in collection.ts for adding, updating, and deleting data entries in an InfiniteData<TCollection>. These utility functions (`addData`, `updateData`, `deleteData`, `findPage`) are designed to be re-usable across different data types and collections.
- Adapted existing conversation utility functions in convos.ts to leverage these new generic utilities.
* ✨ feat(shared-link): add functions to manipulate shared link cache list
implemented new utility functions to handle additions, updates, and deletions in the shared link cache list.
* ✨ feat: Add mutations and queries for shared links
* ✨ feat(shared-link): add `Share` button to conversation list
- Added a share button in each conversation in the conversation list.
- Implemented functionality where clicking the share button triggers a POST request to the API.
- The API checks if a share link was already created for the conversation today; if so, it returns the existing link.
- If no link was created for today, the API will create a new share link and return it.
- Each click on the share button results in a new API request, following the specification similar to ChatGPT's share link feature.
* ♻️ refactor(hooks): generalize useNavScrolling for broader use
- Modified `useNavScrolling` to accept a generic type parameter `TData`, allowing it to be used with different data structures besides `ConversationListResponse`.
- Updated instances in `Nav.tsx` and `ArchivedChatsTable.tsx` to explicitly specify `ConversationListResponse` as the type argument when invoking `useNavScrolling`.
* ✨ feat(settings): add shared links listing table with delete functionality in settings
- Integrated a delete button for each shared link in the table, allowing users to remove links as needed.
* ♻️ refactor(components): separate `EndpointIcon` from `Icon` component for standalone use
* ♻️ refactor: update useGetSharedMessages to return TSharedLink
- Modified the useGetSharedMessages hook to return not only a list of TMessage but also the TSharedLink itself.
- This change was necessary to support displaying the title and date in the Shared Message UI, which requires data from TSharedLink.
* ✨ feat(shared link): add UI for displaying shared conversations without authentication
- Implemented a new UI component to display shared conversations, designed to be accessible without requiring authentication.
- Reused components from the authenticated Messages module where possible. Copied and adapted components that could not be directly reused to fit the non-authenticated context.
* 🔧 chore: Add translations
Translate labels only. Messages remain in English as they are possibly subject to change.
* ♻️ refactor: add icon and tooltip props to EditMenuButton component
* moved icon and popover to arguments so that EditMenuButton can be reused.
* modified so that when a ShareButton is closed, the parent DropdownMenu is also closed.
* ♻️irefactor: added DropdownMenu for Export and Share
* ♻️ refactor: renamed component names more intuitive
* More accurate naming of the dropdown menu.
* When the export button is closed, the parent dropdown menu is also closed.
* 🌍 chore: updated translations
* 🐞 Fix: OpenID Profile Image Download (#2757)
* Add fetch requirement
Fixes - error: [openidStrategy] downloadImage: Error downloading image at URL "https://graph.microsoft.com/v1.0/me/photo/$value": TypeError: response.buffer is not a function
* Update openidStrategy.js
---------
Co-authored-by: Danny Avila <danacordially@gmail.com>
* 🚑 fix(export): Issue exporting Conversation with Assistants (#2769)
* 🚑 fix(export): use content as text if content is present in the message
If the endpoint is assistants, the text of the message goes into content, not message.text.
* refactor(ExportModel): TypeScript, remove unused code
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
* 📤style: export button icon (#2752)
* refactor(ShareDialog): logic and styling
* refactor(ExportAndShareMenu): imports order and icon update
* chore: imports
* chore: imports/render logic
* feat: message branching
* refactor: add optional config to useGetStartupConfig
* refactor: disable endpoints query
* chore: fix search view styling gradient in light mode
* style: ShareView gradient styling
* refactor(Share): use select queries
* style: shared link table buttons
* localization and dark text styling
* style: fix clipboard button layout shift app-wide and add localization for copy code
* support assistants message content in shared links, add useCopyToClipboard, add copy buttons to Search Messages and Shared Link Messages
* add localizations
* comparisons
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
Co-authored-by: bsu3338 <bsu3338@users.noreply.github.com>
Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>
2024-05-17 18:13:32 -04:00
|
|
|
}
|
2024-08-05 03:34:00 -04:00
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
const newConvoId = anonymizeConvoId(share.conversationId);
|
|
|
|
|
const result = {
|
|
|
|
|
...share,
|
2024-08-05 03:34:00 -04:00
|
|
|
conversationId: newConvoId,
|
|
|
|
|
messages: anonymizeMessages(share.messages, newConvoId),
|
2025-01-21 15:31:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return result;
|
2024-08-05 03:34:00 -04:00
|
|
|
} catch (error) {
|
2025-01-21 15:31:05 +01:00
|
|
|
logger.error('[getShare] Error getting share link', {
|
|
|
|
|
error: error.message,
|
|
|
|
|
shareId,
|
|
|
|
|
});
|
|
|
|
|
throw new ShareServiceError('Error getting share link', 'SHARE_FETCH_ERROR');
|
2024-08-05 03:34:00 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
async function getSharedLinks(user, pageParam, pageSize, isPublic, sortBy, sortDirection, search) {
|
2024-08-05 03:34:00 -04:00
|
|
|
try {
|
2025-01-21 15:31:05 +01:00
|
|
|
const query = { user, isPublic };
|
|
|
|
|
|
|
|
|
|
if (pageParam) {
|
|
|
|
|
if (sortDirection === 'desc') {
|
|
|
|
|
query[sortBy] = { $lt: pageParam };
|
|
|
|
|
} else {
|
|
|
|
|
query[sortBy] = { $gt: pageParam };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (search && search.trim()) {
|
|
|
|
|
try {
|
|
|
|
|
const searchResults = await Conversation.meiliSearch(search);
|
🚀 feat: Shared Links (#2772)
* ✨ feat(types): add necessary types for shared link feature
* ✨ feat: add shared links functions to data service
Added functions for retrieving, creating, updating, and deleting shared links and shared messages.
* ✨ feat: Add useGetSharedMessages hook to fetch shared messages by shareId
Adds a new hook `useGetSharedMessages` which fetches shared messages based on the provided shareId.
* ✨ feat: Add share schema and data access functions to API models
* ✨ feat: Add share endpoint to API
The GET /api/share/${shareId} is exposed to the public, so authentication is not required. Other paths require authentication.
* ♻️ refactor(utils): generalize react-query cache manipulation functions
Introduces generic functions for manipulating react-query cache entries, marking a refinement in how query cache data is managed. It aims to enhance the flexibility and reusability of the cache interaction patterns within our application.
- Replaced specific index names with more generic terms in queries.ts, enhancing consistency across data handling functions.
- Introduced new utility functions in collection.ts for adding, updating, and deleting data entries in an InfiniteData<TCollection>. These utility functions (`addData`, `updateData`, `deleteData`, `findPage`) are designed to be re-usable across different data types and collections.
- Adapted existing conversation utility functions in convos.ts to leverage these new generic utilities.
* ✨ feat(shared-link): add functions to manipulate shared link cache list
implemented new utility functions to handle additions, updates, and deletions in the shared link cache list.
* ✨ feat: Add mutations and queries for shared links
* ✨ feat(shared-link): add `Share` button to conversation list
- Added a share button in each conversation in the conversation list.
- Implemented functionality where clicking the share button triggers a POST request to the API.
- The API checks if a share link was already created for the conversation today; if so, it returns the existing link.
- If no link was created for today, the API will create a new share link and return it.
- Each click on the share button results in a new API request, following the specification similar to ChatGPT's share link feature.
* ♻️ refactor(hooks): generalize useNavScrolling for broader use
- Modified `useNavScrolling` to accept a generic type parameter `TData`, allowing it to be used with different data structures besides `ConversationListResponse`.
- Updated instances in `Nav.tsx` and `ArchivedChatsTable.tsx` to explicitly specify `ConversationListResponse` as the type argument when invoking `useNavScrolling`.
* ✨ feat(settings): add shared links listing table with delete functionality in settings
- Integrated a delete button for each shared link in the table, allowing users to remove links as needed.
* ♻️ refactor(components): separate `EndpointIcon` from `Icon` component for standalone use
* ♻️ refactor: update useGetSharedMessages to return TSharedLink
- Modified the useGetSharedMessages hook to return not only a list of TMessage but also the TSharedLink itself.
- This change was necessary to support displaying the title and date in the Shared Message UI, which requires data from TSharedLink.
* ✨ feat(shared link): add UI for displaying shared conversations without authentication
- Implemented a new UI component to display shared conversations, designed to be accessible without requiring authentication.
- Reused components from the authenticated Messages module where possible. Copied and adapted components that could not be directly reused to fit the non-authenticated context.
* 🔧 chore: Add translations
Translate labels only. Messages remain in English as they are possibly subject to change.
* ♻️ refactor: add icon and tooltip props to EditMenuButton component
* moved icon and popover to arguments so that EditMenuButton can be reused.
* modified so that when a ShareButton is closed, the parent DropdownMenu is also closed.
* ♻️irefactor: added DropdownMenu for Export and Share
* ♻️ refactor: renamed component names more intuitive
* More accurate naming of the dropdown menu.
* When the export button is closed, the parent dropdown menu is also closed.
* 🌍 chore: updated translations
* 🐞 Fix: OpenID Profile Image Download (#2757)
* Add fetch requirement
Fixes - error: [openidStrategy] downloadImage: Error downloading image at URL "https://graph.microsoft.com/v1.0/me/photo/$value": TypeError: response.buffer is not a function
* Update openidStrategy.js
---------
Co-authored-by: Danny Avila <danacordially@gmail.com>
* 🚑 fix(export): Issue exporting Conversation with Assistants (#2769)
* 🚑 fix(export): use content as text if content is present in the message
If the endpoint is assistants, the text of the message goes into content, not message.text.
* refactor(ExportModel): TypeScript, remove unused code
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
* 📤style: export button icon (#2752)
* refactor(ShareDialog): logic and styling
* refactor(ExportAndShareMenu): imports order and icon update
* chore: imports
* chore: imports/render logic
* feat: message branching
* refactor: add optional config to useGetStartupConfig
* refactor: disable endpoints query
* chore: fix search view styling gradient in light mode
* style: ShareView gradient styling
* refactor(Share): use select queries
* style: shared link table buttons
* localization and dark text styling
* style: fix clipboard button layout shift app-wide and add localization for copy code
* support assistants message content in shared links, add useCopyToClipboard, add copy buttons to Search Messages and Shared Link Messages
* add localizations
* comparisons
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
Co-authored-by: bsu3338 <bsu3338@users.noreply.github.com>
Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>
2024-05-17 18:13:32 -04:00
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
if (!searchResults?.hits?.length) {
|
|
|
|
|
return {
|
|
|
|
|
links: [],
|
|
|
|
|
nextCursor: undefined,
|
|
|
|
|
hasNextPage: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-08-05 03:34:00 -04:00
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
const conversationIds = searchResults.hits.map((hit) => hit.conversationId);
|
|
|
|
|
query['conversationId'] = { $in: conversationIds };
|
|
|
|
|
} catch (searchError) {
|
|
|
|
|
logger.error('[getSharedLinks] Meilisearch error', {
|
|
|
|
|
error: searchError.message,
|
|
|
|
|
user,
|
|
|
|
|
});
|
|
|
|
|
return {
|
|
|
|
|
links: [],
|
|
|
|
|
nextCursor: undefined,
|
|
|
|
|
hasNextPage: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const sort = {};
|
|
|
|
|
sort[sortBy] = sortDirection === 'desc' ? -1 : 1;
|
|
|
|
|
|
|
|
|
|
if (Array.isArray(query.conversationId)) {
|
|
|
|
|
query.conversationId = { $in: query.conversationId };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const sharedLinks = await SharedLink.find(query)
|
|
|
|
|
.sort(sort)
|
|
|
|
|
.limit(pageSize + 1)
|
|
|
|
|
.select('-__v -user')
|
|
|
|
|
.lean();
|
|
|
|
|
|
|
|
|
|
const hasNextPage = sharedLinks.length > pageSize;
|
|
|
|
|
const links = sharedLinks.slice(0, pageSize);
|
|
|
|
|
|
|
|
|
|
const nextCursor = hasNextPage ? links[links.length - 1][sortBy] : undefined;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
links: links.map((link) => ({
|
|
|
|
|
shareId: link.shareId,
|
|
|
|
|
title: link?.title || 'Untitled',
|
|
|
|
|
isPublic: link.isPublic,
|
|
|
|
|
createdAt: link.createdAt,
|
|
|
|
|
conversationId: link.conversationId,
|
|
|
|
|
})),
|
|
|
|
|
nextCursor,
|
|
|
|
|
hasNextPage,
|
|
|
|
|
};
|
|
|
|
|
} catch (error) {
|
|
|
|
|
logger.error('[getSharedLinks] Error getting shares', {
|
|
|
|
|
error: error.message,
|
|
|
|
|
user,
|
|
|
|
|
});
|
|
|
|
|
throw new ShareServiceError('Error getting shares', 'SHARES_FETCH_ERROR');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function deleteAllSharedLinks(user) {
|
|
|
|
|
try {
|
|
|
|
|
const result = await SharedLink.deleteMany({ user });
|
2024-08-05 03:34:00 -04:00
|
|
|
return {
|
2025-01-21 15:31:05 +01:00
|
|
|
message: 'All shared links deleted successfully',
|
|
|
|
|
deletedCount: result.deletedCount,
|
2024-08-05 03:34:00 -04:00
|
|
|
};
|
|
|
|
|
} catch (error) {
|
2025-01-21 15:31:05 +01:00
|
|
|
logger.error('[deleteAllSharedLinks] Error deleting shared links', {
|
|
|
|
|
error: error.message,
|
|
|
|
|
user,
|
|
|
|
|
});
|
|
|
|
|
throw new ShareServiceError('Error deleting shared links', 'BULK_DELETE_ERROR');
|
2024-08-05 03:34:00 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
async function createSharedLink(user, conversationId) {
|
|
|
|
|
if (!user || !conversationId) {
|
|
|
|
|
throw new ShareServiceError('Missing required parameters', 'INVALID_PARAMS');
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 03:34:00 -04:00
|
|
|
try {
|
2025-01-21 15:31:05 +01:00
|
|
|
const [existingShare, conversationMessages] = await Promise.all([
|
|
|
|
|
SharedLink.findOne({ conversationId, isPublic: true }).select('-_id -__v -user').lean(),
|
|
|
|
|
getMessages({ conversationId }),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
if (existingShare && existingShare.isPublic) {
|
|
|
|
|
throw new ShareServiceError('Share already exists', 'SHARE_EXISTS');
|
|
|
|
|
} else if (existingShare) {
|
|
|
|
|
await SharedLink.deleteOne({ conversationId });
|
🚀 feat: Shared Links (#2772)
* ✨ feat(types): add necessary types for shared link feature
* ✨ feat: add shared links functions to data service
Added functions for retrieving, creating, updating, and deleting shared links and shared messages.
* ✨ feat: Add useGetSharedMessages hook to fetch shared messages by shareId
Adds a new hook `useGetSharedMessages` which fetches shared messages based on the provided shareId.
* ✨ feat: Add share schema and data access functions to API models
* ✨ feat: Add share endpoint to API
The GET /api/share/${shareId} is exposed to the public, so authentication is not required. Other paths require authentication.
* ♻️ refactor(utils): generalize react-query cache manipulation functions
Introduces generic functions for manipulating react-query cache entries, marking a refinement in how query cache data is managed. It aims to enhance the flexibility and reusability of the cache interaction patterns within our application.
- Replaced specific index names with more generic terms in queries.ts, enhancing consistency across data handling functions.
- Introduced new utility functions in collection.ts for adding, updating, and deleting data entries in an InfiniteData<TCollection>. These utility functions (`addData`, `updateData`, `deleteData`, `findPage`) are designed to be re-usable across different data types and collections.
- Adapted existing conversation utility functions in convos.ts to leverage these new generic utilities.
* ✨ feat(shared-link): add functions to manipulate shared link cache list
implemented new utility functions to handle additions, updates, and deletions in the shared link cache list.
* ✨ feat: Add mutations and queries for shared links
* ✨ feat(shared-link): add `Share` button to conversation list
- Added a share button in each conversation in the conversation list.
- Implemented functionality where clicking the share button triggers a POST request to the API.
- The API checks if a share link was already created for the conversation today; if so, it returns the existing link.
- If no link was created for today, the API will create a new share link and return it.
- Each click on the share button results in a new API request, following the specification similar to ChatGPT's share link feature.
* ♻️ refactor(hooks): generalize useNavScrolling for broader use
- Modified `useNavScrolling` to accept a generic type parameter `TData`, allowing it to be used with different data structures besides `ConversationListResponse`.
- Updated instances in `Nav.tsx` and `ArchivedChatsTable.tsx` to explicitly specify `ConversationListResponse` as the type argument when invoking `useNavScrolling`.
* ✨ feat(settings): add shared links listing table with delete functionality in settings
- Integrated a delete button for each shared link in the table, allowing users to remove links as needed.
* ♻️ refactor(components): separate `EndpointIcon` from `Icon` component for standalone use
* ♻️ refactor: update useGetSharedMessages to return TSharedLink
- Modified the useGetSharedMessages hook to return not only a list of TMessage but also the TSharedLink itself.
- This change was necessary to support displaying the title and date in the Shared Message UI, which requires data from TSharedLink.
* ✨ feat(shared link): add UI for displaying shared conversations without authentication
- Implemented a new UI component to display shared conversations, designed to be accessible without requiring authentication.
- Reused components from the authenticated Messages module where possible. Copied and adapted components that could not be directly reused to fit the non-authenticated context.
* 🔧 chore: Add translations
Translate labels only. Messages remain in English as they are possibly subject to change.
* ♻️ refactor: add icon and tooltip props to EditMenuButton component
* moved icon and popover to arguments so that EditMenuButton can be reused.
* modified so that when a ShareButton is closed, the parent DropdownMenu is also closed.
* ♻️irefactor: added DropdownMenu for Export and Share
* ♻️ refactor: renamed component names more intuitive
* More accurate naming of the dropdown menu.
* When the export button is closed, the parent dropdown menu is also closed.
* 🌍 chore: updated translations
* 🐞 Fix: OpenID Profile Image Download (#2757)
* Add fetch requirement
Fixes - error: [openidStrategy] downloadImage: Error downloading image at URL "https://graph.microsoft.com/v1.0/me/photo/$value": TypeError: response.buffer is not a function
* Update openidStrategy.js
---------
Co-authored-by: Danny Avila <danacordially@gmail.com>
* 🚑 fix(export): Issue exporting Conversation with Assistants (#2769)
* 🚑 fix(export): use content as text if content is present in the message
If the endpoint is assistants, the text of the message goes into content, not message.text.
* refactor(ExportModel): TypeScript, remove unused code
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
* 📤style: export button icon (#2752)
* refactor(ShareDialog): logic and styling
* refactor(ExportAndShareMenu): imports order and icon update
* chore: imports
* chore: imports/render logic
* feat: message branching
* refactor: add optional config to useGetStartupConfig
* refactor: disable endpoints query
* chore: fix search view styling gradient in light mode
* style: ShareView gradient styling
* refactor(Share): use select queries
* style: shared link table buttons
* localization and dark text styling
* style: fix clipboard button layout shift app-wide and add localization for copy code
* support assistants message content in shared links, add useCopyToClipboard, add copy buttons to Search Messages and Shared Link Messages
* add localizations
* comparisons
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
Co-authored-by: bsu3338 <bsu3338@users.noreply.github.com>
Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>
2024-05-17 18:13:32 -04:00
|
|
|
}
|
2024-08-05 03:34:00 -04:00
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
const conversation = await Conversation.findOne({ conversationId }).lean();
|
|
|
|
|
const title = conversation?.title || 'Untitled';
|
|
|
|
|
|
2024-08-05 03:34:00 -04:00
|
|
|
const shareId = nanoid();
|
2025-01-21 15:31:05 +01:00
|
|
|
await SharedLink.create({
|
|
|
|
|
shareId,
|
|
|
|
|
conversationId,
|
|
|
|
|
messages: conversationMessages,
|
|
|
|
|
title,
|
|
|
|
|
user,
|
|
|
|
|
});
|
2024-08-05 03:34:00 -04:00
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
return { shareId, conversationId };
|
|
|
|
|
} catch (error) {
|
|
|
|
|
logger.error('[createSharedLink] Error creating shared link', {
|
|
|
|
|
error: error.message,
|
|
|
|
|
user,
|
|
|
|
|
conversationId,
|
2024-08-05 03:34:00 -04:00
|
|
|
});
|
2025-01-21 15:31:05 +01:00
|
|
|
throw new ShareServiceError('Error creating shared link', 'SHARE_CREATE_ERROR');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getSharedLink(user, conversationId) {
|
|
|
|
|
if (!user || !conversationId) {
|
|
|
|
|
throw new ShareServiceError('Missing required parameters', 'INVALID_PARAMS');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const share = await SharedLink.findOne({ conversationId, user, isPublic: true })
|
|
|
|
|
.select('shareId -_id')
|
|
|
|
|
.lean();
|
|
|
|
|
|
|
|
|
|
if (!share) {
|
|
|
|
|
return { shareId: null, success: false };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { shareId: share.shareId, success: true };
|
2024-08-05 03:34:00 -04:00
|
|
|
} catch (error) {
|
2025-01-21 15:31:05 +01:00
|
|
|
logger.error('[getSharedLink] Error getting shared link', {
|
|
|
|
|
error: error.message,
|
|
|
|
|
user,
|
|
|
|
|
conversationId,
|
|
|
|
|
});
|
|
|
|
|
throw new ShareServiceError('Error getting shared link', 'SHARE_FETCH_ERROR');
|
2024-08-05 03:34:00 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
async function updateSharedLink(user, shareId) {
|
|
|
|
|
if (!user || !shareId) {
|
|
|
|
|
throw new ShareServiceError('Missing required parameters', 'INVALID_PARAMS');
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 03:34:00 -04:00
|
|
|
try {
|
2025-01-21 15:31:05 +01:00
|
|
|
const share = await SharedLink.findOne({ shareId }).select('-_id -__v -user').lean();
|
|
|
|
|
|
2024-08-05 03:34:00 -04:00
|
|
|
if (!share) {
|
2025-01-21 15:31:05 +01:00
|
|
|
throw new ShareServiceError('Share not found', 'SHARE_NOT_FOUND');
|
2024-06-07 21:06:47 +02:00
|
|
|
}
|
2024-08-05 03:34:00 -04:00
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
const [updatedMessages] = await Promise.all([
|
|
|
|
|
getMessages({ conversationId: share.conversationId }),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const newShareId = nanoid();
|
|
|
|
|
const update = {
|
|
|
|
|
messages: updatedMessages,
|
|
|
|
|
user,
|
|
|
|
|
shareId: newShareId,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const updatedShare = await SharedLink.findOneAndUpdate({ shareId, user }, update, {
|
2024-08-05 03:34:00 -04:00
|
|
|
new: true,
|
|
|
|
|
upsert: false,
|
2025-01-21 15:31:05 +01:00
|
|
|
runValidators: true,
|
2024-08-05 03:34:00 -04:00
|
|
|
}).lean();
|
|
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
if (!updatedShare) {
|
|
|
|
|
throw new ShareServiceError('Share update failed', 'SHARE_UPDATE_ERROR');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
anonymizeConvo(updatedShare);
|
|
|
|
|
|
|
|
|
|
return { shareId: newShareId, conversationId: updatedShare.conversationId };
|
2024-08-05 03:34:00 -04:00
|
|
|
} catch (error) {
|
2025-01-21 15:31:05 +01:00
|
|
|
logger.error('[updateSharedLink] Error updating shared link', {
|
|
|
|
|
error: error.message,
|
|
|
|
|
user,
|
|
|
|
|
shareId,
|
|
|
|
|
});
|
|
|
|
|
throw new ShareServiceError(
|
|
|
|
|
error.code === 'SHARE_UPDATE_ERROR' ? error.message : 'Error updating shared link',
|
|
|
|
|
error.code || 'SHARE_UPDATE_ERROR',
|
|
|
|
|
);
|
2024-08-05 03:34:00 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 15:31:05 +01:00
|
|
|
async function deleteSharedLink(user, shareId) {
|
|
|
|
|
if (!user || !shareId) {
|
|
|
|
|
throw new ShareServiceError('Missing required parameters', 'INVALID_PARAMS');
|
2024-08-05 03:34:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2025-01-21 15:31:05 +01:00
|
|
|
const result = await SharedLink.findOneAndDelete({ shareId, user }).lean();
|
|
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 03:34:00 -04:00
|
|
|
return {
|
2025-01-21 15:31:05 +01:00
|
|
|
success: true,
|
|
|
|
|
shareId,
|
|
|
|
|
message: 'Share deleted successfully',
|
2024-08-05 03:34:00 -04:00
|
|
|
};
|
|
|
|
|
} catch (error) {
|
2025-01-21 15:31:05 +01:00
|
|
|
logger.error('[deleteSharedLink] Error deleting shared link', {
|
|
|
|
|
error: error.message,
|
|
|
|
|
user,
|
|
|
|
|
shareId,
|
|
|
|
|
});
|
|
|
|
|
throw new ShareServiceError('Error deleting shared link', 'SHARE_DELETE_ERROR');
|
2024-08-05 03:34:00 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
SharedLink,
|
2025-01-21 15:31:05 +01:00
|
|
|
getSharedLink,
|
2024-08-05 03:34:00 -04:00
|
|
|
getSharedLinks,
|
|
|
|
|
createSharedLink,
|
|
|
|
|
updateSharedLink,
|
|
|
|
|
deleteSharedLink,
|
|
|
|
|
getSharedMessages,
|
|
|
|
|
deleteAllSharedLinks,
|
🚀 feat: Shared Links (#2772)
* ✨ feat(types): add necessary types for shared link feature
* ✨ feat: add shared links functions to data service
Added functions for retrieving, creating, updating, and deleting shared links and shared messages.
* ✨ feat: Add useGetSharedMessages hook to fetch shared messages by shareId
Adds a new hook `useGetSharedMessages` which fetches shared messages based on the provided shareId.
* ✨ feat: Add share schema and data access functions to API models
* ✨ feat: Add share endpoint to API
The GET /api/share/${shareId} is exposed to the public, so authentication is not required. Other paths require authentication.
* ♻️ refactor(utils): generalize react-query cache manipulation functions
Introduces generic functions for manipulating react-query cache entries, marking a refinement in how query cache data is managed. It aims to enhance the flexibility and reusability of the cache interaction patterns within our application.
- Replaced specific index names with more generic terms in queries.ts, enhancing consistency across data handling functions.
- Introduced new utility functions in collection.ts for adding, updating, and deleting data entries in an InfiniteData<TCollection>. These utility functions (`addData`, `updateData`, `deleteData`, `findPage`) are designed to be re-usable across different data types and collections.
- Adapted existing conversation utility functions in convos.ts to leverage these new generic utilities.
* ✨ feat(shared-link): add functions to manipulate shared link cache list
implemented new utility functions to handle additions, updates, and deletions in the shared link cache list.
* ✨ feat: Add mutations and queries for shared links
* ✨ feat(shared-link): add `Share` button to conversation list
- Added a share button in each conversation in the conversation list.
- Implemented functionality where clicking the share button triggers a POST request to the API.
- The API checks if a share link was already created for the conversation today; if so, it returns the existing link.
- If no link was created for today, the API will create a new share link and return it.
- Each click on the share button results in a new API request, following the specification similar to ChatGPT's share link feature.
* ♻️ refactor(hooks): generalize useNavScrolling for broader use
- Modified `useNavScrolling` to accept a generic type parameter `TData`, allowing it to be used with different data structures besides `ConversationListResponse`.
- Updated instances in `Nav.tsx` and `ArchivedChatsTable.tsx` to explicitly specify `ConversationListResponse` as the type argument when invoking `useNavScrolling`.
* ✨ feat(settings): add shared links listing table with delete functionality in settings
- Integrated a delete button for each shared link in the table, allowing users to remove links as needed.
* ♻️ refactor(components): separate `EndpointIcon` from `Icon` component for standalone use
* ♻️ refactor: update useGetSharedMessages to return TSharedLink
- Modified the useGetSharedMessages hook to return not only a list of TMessage but also the TSharedLink itself.
- This change was necessary to support displaying the title and date in the Shared Message UI, which requires data from TSharedLink.
* ✨ feat(shared link): add UI for displaying shared conversations without authentication
- Implemented a new UI component to display shared conversations, designed to be accessible without requiring authentication.
- Reused components from the authenticated Messages module where possible. Copied and adapted components that could not be directly reused to fit the non-authenticated context.
* 🔧 chore: Add translations
Translate labels only. Messages remain in English as they are possibly subject to change.
* ♻️ refactor: add icon and tooltip props to EditMenuButton component
* moved icon and popover to arguments so that EditMenuButton can be reused.
* modified so that when a ShareButton is closed, the parent DropdownMenu is also closed.
* ♻️irefactor: added DropdownMenu for Export and Share
* ♻️ refactor: renamed component names more intuitive
* More accurate naming of the dropdown menu.
* When the export button is closed, the parent dropdown menu is also closed.
* 🌍 chore: updated translations
* 🐞 Fix: OpenID Profile Image Download (#2757)
* Add fetch requirement
Fixes - error: [openidStrategy] downloadImage: Error downloading image at URL "https://graph.microsoft.com/v1.0/me/photo/$value": TypeError: response.buffer is not a function
* Update openidStrategy.js
---------
Co-authored-by: Danny Avila <danacordially@gmail.com>
* 🚑 fix(export): Issue exporting Conversation with Assistants (#2769)
* 🚑 fix(export): use content as text if content is present in the message
If the endpoint is assistants, the text of the message goes into content, not message.text.
* refactor(ExportModel): TypeScript, remove unused code
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
* 📤style: export button icon (#2752)
* refactor(ShareDialog): logic and styling
* refactor(ExportAndShareMenu): imports order and icon update
* chore: imports
* chore: imports/render logic
* feat: message branching
* refactor: add optional config to useGetStartupConfig
* refactor: disable endpoints query
* chore: fix search view styling gradient in light mode
* style: ShareView gradient styling
* refactor(Share): use select queries
* style: shared link table buttons
* localization and dark text styling
* style: fix clipboard button layout shift app-wide and add localization for copy code
* support assistants message content in shared links, add useCopyToClipboard, add copy buttons to Search Messages and Shared Link Messages
* add localizations
* comparisons
---------
Co-authored-by: Yuichi Ohneda <ohneda@gmail.com>
Co-authored-by: bsu3338 <bsu3338@users.noreply.github.com>
Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>
2024-05-17 18:13:32 -04:00
|
|
|
};
|