Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
List<User> GetUsersByAffiliateId(string affiliateId) => throw new NotImplementedException();
User? GetUserByUserName(string userName) => throw new NotImplementedException();
void UpdateUserName(string userId, string userName) => throw new NotImplementedException();
Dashboard? GetDashboard(string id = null) => throw new NotImplementedException();

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Cannot convert null literal to non-nullable reference type.

Check warning on line 51 in src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Cannot convert null literal to non-nullable reference type.
void CreateUser(User user) => throw new NotImplementedException();
void UpdateExistUser(string userId, User user) => throw new NotImplementedException();
void UpdateUserVerified(string userId) => throw new NotImplementedException();
Expand Down Expand Up @@ -127,7 +127,7 @@
#endregion

#region Conversation
void CreateNewConversation(Conversation conversation)
Task CreateNewConversation(Conversation conversation)
=> throw new NotImplementedException();
bool DeleteConversations(IEnumerable<string> conversationIds)
=> throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public async Task<Conversation> NewConversation(Conversation sess)
record.Tags = sess.Tags;
record.Title = string.IsNullOrEmpty(record.Title) ? "New Conversation" : record.Title;

db.CreateNewConversation(record);
await db.CreateNewConversation(record);

var hooks = _services.GetHooks<IConversationHook>(record.AgentId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class FileRepository
private static readonly object _dialogLock = new object();
private static readonly object _stateLock = new object();

public void CreateNewConversation(Conversation conversation)
public async Task CreateNewConversation(Conversation conversation)
{
var utcNow = DateTime.UtcNow;
conversation.CreatedTime = utcNow;
Expand All @@ -24,31 +24,31 @@ public void CreateNewConversation(Conversation conversation)
var convFile = Path.Combine(dir, CONVERSATION_FILE);
if (!File.Exists(convFile))
{
File.WriteAllText(convFile, JsonSerializer.Serialize(conversation, _options));
await File.WriteAllTextAsync(convFile, JsonSerializer.Serialize(conversation, _options));
}

var dialogFile = Path.Combine(dir, DIALOG_FILE);
if (!File.Exists(dialogFile))
{
File.WriteAllText(dialogFile, "[]");
await File.WriteAllTextAsync(dialogFile, "[]");
}

var stateFile = Path.Combine(dir, STATE_FILE);
if (!File.Exists(stateFile))
{
File.WriteAllText(stateFile, "[]");
await File.WriteAllTextAsync(stateFile, "[]");
}

var latestStateFile = Path.Combine(dir, CONV_LATEST_STATE_FILE);
if (!File.Exists(latestStateFile))
{
File.WriteAllText(latestStateFile, "{}");
await File.WriteAllTextAsync(latestStateFile, "{}");
}

var breakpointFile = Path.Combine(dir, BREAKPOINT_FILE);
if (!File.Exists(breakpointFile))
{
File.WriteAllText(breakpointFile, "[]");
await File.WriteAllTextAsync(breakpointFile, "[]");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace BotSharp.Plugin.MongoStorage.Repository;

public partial class MongoRepository
{
public void CreateNewConversation(Conversation conversation)
public async Task CreateNewConversation(Conversation conversation)
{
if (conversation == null) return;

Expand Down Expand Up @@ -49,9 +49,17 @@ public void CreateNewConversation(Conversation conversation)
UpdatedTime = utcNow
};

_dc.Conversations.InsertOne(convDoc);
_dc.ConversationDialogs.InsertOne(dialogDoc);
_dc.ConversationStates.InsertOne(stateDoc);
try
{
await _dc.Conversations.InsertOneAsync(convDoc);
await _dc.ConversationDialogs.InsertOneAsync(dialogDoc);
await _dc.ConversationStates.InsertOneAsync(stateDoc);
}
catch (MongoWriteException ex) when (ex.WriteError?.Code == 11000)
{
//11000 duplicate key error
return;
}
}

public bool DeleteConversations(IEnumerable<string> conversationIds)
Expand Down
Loading