Skip to content

Commit 78876ed

Browse files
History and get memberships fix (#14)
* add MacOS-side fix for user.CustomData * fix for user.GetMemberships() limit crash * fix for PNR_RX_BUFF_NOT_EMPTY error
1 parent 1fd3b33 commit 78876ed

File tree

9 files changed

+45
-5
lines changed

9 files changed

+45
-5
lines changed

.pubnub.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
---
2-
version: v0.4.2
2+
version: v0.4.3
33
changelog:
4+
- date: 2025-04-02
5+
version: v0.4.3
6+
changes:
7+
- type: bug
8+
text: "Fixed an issue where on Mac user.CustomData would still show up as improperly linked."
9+
- type: bug
10+
text: "Fixed an issue where limit > 100 would cause a C-Core assert to crash the application."
11+
- type: bug
12+
text: "Fixed an issue where in C-Core GetMessageHistory() didn't clear message buffer causing error on subsequent calls."
413
- date: 2025-03-31
514
version: v0.4.2
615
changes:

c-sharp-chat/PubnubChatApi/PubNubChatApi.Tests/MembershipTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,23 @@ public async Task TestUnreadMessagesCount()
155155
var unreadCount = membership == null ? -1 : await membership.GetUnreadMessagesCount();
156156
Assert.True(unreadCount >= 3, $"Expected >=3 unread but got: {unreadCount}");
157157
}
158+
159+
[Test]
160+
//Test added after a specific user issue where calling membership.GetUnreadMessagesCount()
161+
//after a history fetch would throw a C-Core PNR_RX_BUFF_NOT_EMPTY error
162+
public async Task TestUnreadCountAfterFetchHistory()
163+
{
164+
await channel.SendText("some_text");
165+
var membership = (await user.GetMemberships())
166+
.Memberships.FirstOrDefault(x => x.ChannelId == channel.Id);
167+
if (membership == null)
168+
{
169+
Assert.Fail("Couldn't find membership");
170+
return;
171+
}
172+
await Task.Delay(5000);
173+
var history = await channel.GetMessageHistory("99999999999999999", "00000000000000000", 1);
174+
var unread = await membership.GetUnreadMessagesCount();
175+
Assert.True(unread >= 1);
176+
}
158177
}

c-sharp-chat/PubnubChatApi/PubNubChatApi.Tests/UserTests.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,33 @@ public async Task TestLastUserActive()
5959
public async Task TestUserUpdate()
6060
{
6161
var updatedReset = new ManualResetEvent(false);
62-
var testUser = await chat.GetOrCreateUser("wolololo");
62+
var testUser = await chat.GetOrCreateUser("wolololo_guy");
6363

6464
await Task.Delay(5000);
6565

6666
var newRandomUserName = Guid.NewGuid().ToString();
6767
testUser.OnUserUpdated += updatedUser =>
6868
{
6969
Assert.True(updatedUser.UserName == newRandomUserName);
70+
Assert.True(updatedUser.CustomData == "{\"some_key\":\"some_value\"}");
71+
Assert.True(updatedUser.Email == "[email protected]");
72+
Assert.True(updatedUser.ExternalId == "xxx_some_guy_420_xxx");
73+
Assert.True(updatedUser.ProfileUrl == "www.some.guy");
74+
Assert.True(updatedUser.Status == "yes");
75+
Assert.True(updatedUser.DataType == "someType");
7076
updatedReset.Set();
7177
};
7278
testUser.SetListeningForUpdates(true);
7379
await Task.Delay(3000);
7480
await testUser.Update(new ChatUserData()
7581
{
76-
Username = newRandomUserName
82+
Username = newRandomUserName,
83+
CustomDataJson = "{\"some_key\":\"some_value\"}",
84+
Email = "[email protected]",
85+
ExternalId = "xxx_some_guy_420_xxx",
86+
ProfileUrl = "www.some.guy",
87+
Status = "yes",
88+
Type = "someType"
7789
});
7890
var updated = updatedReset.WaitOne(15000);
7991
Assert.True(updated);

c-sharp-chat/PubnubChatApi/PubnubChatApi/Entities/Chat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ public async Task UpdateUser(string userId, ChatUserData updatedData)
13171317
updatedData.Email,
13181318
updatedData.CustomDataJson,
13191319
updatedData.Status,
1320-
updatedData.Status));
1320+
updatedData.Type));
13211321
CUtilities.CheckCFunctionResult(newPointer);
13221322
if (userWrappers.TryGetValue(userId, out var existingUserWrapper))
13231323
{
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

unity-chat/PubnubChatUnity/Assets/PubnubChat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.pubnub.pubnubchat",
3-
"version": "0.4.2",
3+
"version": "0.4.3",
44
"displayName": "Pubnub Chat",
55
"description": "PubNub Unity Chat SDK",
66
"unity": "2022.3",

0 commit comments

Comments
 (0)