mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
feat: merge all message.id into message.messageId
feat: the first message will have a parentMessageId as 00000000-0000-0000-0000-000000000000 (in order not to create new convo when resubmit) feat: ask will return the userMessage as well, to send back the messageId TODO: comment out the title generation. TODO: bing version need to be test fix: never use the same messageId fix: never delete exist messages fix: connect response.parentMessageId to the userMessage.messageId fix: set default convo title as new Chat
This commit is contained in:
parent
be71140dd4
commit
0ed8a40a41
7 changed files with 159 additions and 85 deletions
|
|
@ -1,7 +1,7 @@
|
|||
const mongoose = require('mongoose');
|
||||
|
||||
const messageSchema = mongoose.Schema({
|
||||
id: {
|
||||
messageId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
required: true
|
||||
|
|
@ -42,24 +42,24 @@ const messageSchema = mongoose.Schema({
|
|||
const Message = mongoose.models.Message || mongoose.model('Message', messageSchema);
|
||||
|
||||
module.exports = {
|
||||
saveMessage: async ({ id, conversationId, parentMessageId, sender, text, isCreatedByUser=false }) => {
|
||||
saveMessage: async ({ messageId, conversationId, parentMessageId, sender, text, isCreatedByUser=false }) => {
|
||||
try {
|
||||
await Message.findOneAndUpdate({ id }, {
|
||||
await Message.findOneAndUpdate({ messageId }, {
|
||||
conversationId,
|
||||
parentMessageId,
|
||||
sender,
|
||||
text,
|
||||
isCreatedByUser
|
||||
}, { upsert: true, new: true });
|
||||
return { id, conversationId, parentMessageId, sender, text, isCreatedByUser };
|
||||
return { messageId, conversationId, parentMessageId, sender, text, isCreatedByUser };
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return { message: 'Error saving message' };
|
||||
}
|
||||
},
|
||||
deleteMessagesSince: async ({ id, conversationId }) => {
|
||||
deleteMessagesSince: async ({ messageId, conversationId }) => {
|
||||
try {
|
||||
message = await Message.findOne({ id }).exec()
|
||||
message = await Message.findOne({ messageId }).exec()
|
||||
|
||||
if (message)
|
||||
return await Message.find({ conversationId }).deleteMany({ createdAt: { $gt: message.createdAt } }).exec();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue