Search code examples
c#azure-communication-services

Change History Time Azure Communication Services



I'm trying to create a simple chat app using Azure Communication Services SDK for .NET. I managed to add participants to a thread following

this example.
I read the documentation for class ChatParticipant and I found out that it can show the time from which the chat history is shared with the participant. The default date is 1/1/1970 00:00.
I would like to make this date variable, so that a user can only see messages from the moment he joined the chat on.
Is there a way to do it?

Thank you in advance


Solution

  • Can you try to set the property for ShareHistoryTime at the time of adding a participant to the Chat thread?. e.g in the below example, it is set to current time.

    // ThreadId : Chat ThreadId , participantUserId : participant communication user Identifier 
    
    ChatThreadClient chatThreadClient = 
    chatClient.GetChatThreadClient(ThreadId);
    chatThreadClient.AddParticipant(new ChatParticipant(
           new CommunicationUserIdentifier(participantUserId))
           {
                    DisplayName = displayName,
                    ShareHistoryTime = DateTimeOffset.Now
           });
    

    You can refer Chat Participant Properties here