Reputation: 4611
In my application, I create and later delete chat threads, and I noticed that when I enumerate chat threads using ChatClient.GetChatThreads(), it returns deleted chats (with DeletedOn
property not null). Some deleted chats are already 10+ days old. This leads to a situation when ChatClient.GetChatThreads()
takes more and more time to run because I must filter through all these deleted chats.
This looks like a "soft delete" behavior, and I cannot find information on when chat threads will finally be "hard deleted" by the system and stop appearing in the GetChatThreads()
call. Is there a way to immediately "hard delete" a chat thread, or at least make GetChatThreads()
ignore deleted chats?
A related issue is that a few days ago, GetChatThreads()
started to return a chat thread with DeletedOn == null
, but when I try to get chat thread properties, I receive an exception that the chat thread has already been deleted (404
). The problematic chat thread still gets returned after 2 days I noticed it, which makes GetChatThreads()
very untrustworthy for me.
Upvotes: 0
Views: 59
Reputation: 3448
when chat threads will finally be "hard deleted" by the system and stop appearing in the
GetChatThreads()
call.
This is expected behavior with the current design of the chat service.
When you delete a chat thread, it is not removed from the backend. Instead, it’s “soft deleted” and retained for a certain period (weeks).
Deleted threads still appear in the results from GetChatThreads()
, so you need to filter them on the client side by checking for a non-null DeletedOn
value.
There is no supported API or mechanism to force an immediate hard delete.
You need to continue filtering out threads that have been soft deleted.
For retrieving, filtering, and verifies active chat threads.
public async Task<List<ChatThread>> GetFilteredActiveChatThreadsAsync()
{
// Retrieve all chat threads
var allChatThreads = await ChatClient.GetChatThreads();
// Filter out threads that are soft deleted
var activeChatThreads = allChatThreads
.Where(thread => thread.DeletedOn == null)
.ToList();
// Validate threads to catch inconsistencies where details retrieval fails
var reliableActiveThreads = new List<ChatThread>();
foreach (var thread in activeChatThreads)
{
try
{
// Retrieve details to ensure the thread is truly active
var details = await ChatClient.GetChatThreadDetails(thread.Id);
reliableActiveThreads.Add(thread);
}
catch (NotFoundException)
{
// Optionally log the error and continue with next thread
// This thread is likely in a transient state or already deleted
}
}
return reliableActiveThreads;
}
Note:
Regarding the issue you described with a thread appearing as if it were not deleted (DeletedOn is null) causing a 404 when accessed
Recommended to report it through the support channel so that the team can investigate further.
Upvotes: 0