Skip to content

History and get memberships fix #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 2, 2025
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
11 changes: 10 additions & 1 deletion .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
---
version: v0.4.2
version: v0.4.3
changelog:
- date: 2025-04-02
version: v0.4.3
changes:
- type: bug
text: "Fixed an issue where on Mac user.CustomData would still show up as improperly linked."
- type: bug
text: "Fixed an issue where limit > 100 would cause a C-Core assert to crash the application."
- type: bug
text: "Fixed an issue where in C-Core GetMessageHistory() didn't clear message buffer causing error on subsequent calls."
- date: 2025-03-31
version: v0.4.2
changes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,23 @@ public async Task TestUnreadMessagesCount()
var unreadCount = membership == null ? -1 : await membership.GetUnreadMessagesCount();
Assert.True(unreadCount >= 3, $"Expected >=3 unread but got: {unreadCount}");
}

[Test]
//Test added after a specific user issue where calling membership.GetUnreadMessagesCount()
//after a history fetch would throw a C-Core PNR_RX_BUFF_NOT_EMPTY error
public async Task TestUnreadCountAfterFetchHistory()
{
await channel.SendText("some_text");
var membership = (await user.GetMemberships())
.Memberships.FirstOrDefault(x => x.ChannelId == channel.Id);
if (membership == null)
{
Assert.Fail("Couldn't find membership");
return;
}
await Task.Delay(5000);
var history = await channel.GetMessageHistory("99999999999999999", "00000000000000000", 1);
var unread = await membership.GetUnreadMessagesCount();
Assert.True(unread >= 1);
}
}
16 changes: 14 additions & 2 deletions c-sharp-chat/PubnubChatApi/PubNubChatApi.Tests/UserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,33 @@ public async Task TestLastUserActive()
public async Task TestUserUpdate()
{
var updatedReset = new ManualResetEvent(false);
var testUser = await chat.GetOrCreateUser("wolololo");
var testUser = await chat.GetOrCreateUser("wolololo_guy");

await Task.Delay(5000);

var newRandomUserName = Guid.NewGuid().ToString();
testUser.OnUserUpdated += updatedUser =>
{
Assert.True(updatedUser.UserName == newRandomUserName);
Assert.True(updatedUser.CustomData == "{\"some_key\":\"some_value\"}");
Assert.True(updatedUser.Email == "[email protected]");
Assert.True(updatedUser.ExternalId == "xxx_some_guy_420_xxx");
Assert.True(updatedUser.ProfileUrl == "www.some.guy");
Assert.True(updatedUser.Status == "yes");
Assert.True(updatedUser.DataType == "someType");
updatedReset.Set();
};
testUser.SetListeningForUpdates(true);
await Task.Delay(3000);
await testUser.Update(new ChatUserData()
{
Username = newRandomUserName
Username = newRandomUserName,
CustomDataJson = "{\"some_key\":\"some_value\"}",
Email = "[email protected]",
ExternalId = "xxx_some_guy_420_xxx",
ProfileUrl = "www.some.guy",
Status = "yes",
Type = "someType"
});
var updated = updatedReset.WaitOne(15000);
Assert.True(updated);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ public async Task UpdateUser(string userId, ChatUserData updatedData)
updatedData.Email,
updatedData.CustomDataJson,
updatedData.Status,
updatedData.Status));
updatedData.Type));
CUtilities.CheckCFunctionResult(newPointer);
if (userWrappers.TryGetValue(userId, out var existingUserWrapper))
{
Expand Down
Binary file modified c-sharp-chat/PubnubChatApi/PubnubChatApi/pubnub-chat.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.pubnub.pubnubchat",
"version": "0.4.2",
"version": "0.4.3",
"displayName": "Pubnub Chat",
"description": "PubNub Unity Chat SDK",
"unity": "2022.3",
Expand Down