Skip to content

Commit 73abbba

Browse files
Add auth token management, expose original message text, and add random Channel ID generation (#11)
* Expose original pre-any-edits message text * Add auth token management methods to ChatAccessManager * Add random ID generation if none is provided when creating channel
1 parent 49fb23f commit 73abbba

22 files changed

+152
-35
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.2.0
2+
version: v0.3.1
33
changelog:
4+
- date: 2025-02-25
5+
version: v0.3.1
6+
changes:
7+
- type: feature
8+
text: "Added SetAuthToken(), ParseToken(), and SetPubnubOrigin() methods to ChatAccessManager class."
9+
- type: feature
10+
text: "Added OriginalMessageText property to Message object containg pre-edits message text."
11+
- type: feature
12+
text: "Added option to not provide channel ID when creating a new conversation - a random ID will be generated in such cases."
413
- date: 2024-01-10
514
version: v0.2.0
615
changes:

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*using System.Diagnostics;
1+
using System.Diagnostics;
22
using PubNubChatAPI.Entities;
33
using PubnubChatApi.Entities.Data;
44

@@ -17,7 +17,7 @@ public async Task Setup()
1717
chat = await Chat.CreateInstance(new PubnubChatConfig(
1818
PubnubTestsParameters.PublishKey,
1919
PubnubTestsParameters.SubscribeKey,
20-
"ctuuuuuuuuuuuuuuuuuuuuuuuuuuuuu")
20+
"ctuuuuuuuuuuu")
2121
);
2222
if (!chat.TryGetCurrentUser(out user))
2323
{
@@ -188,15 +188,17 @@ public async Task TestEmitUserMention()
188188
{
189189
var channel = await chat.CreatePublicConversation("user_mention_test_channel");
190190
await channel.Join();
191+
await Task.Delay(2000);
191192
var receivedManualEvent = new ManualResetEvent(false);
192193
chat.StartListeningForMentionEvents(user.Id);
194+
await Task.Delay(2000);
193195
chat.OnMentionEvent += mentionEvent =>
194196
{
195197
Assert.True(mentionEvent.Payload.Contains("heyyy"));
196198
receivedManualEvent.Set();
197199
};
198200
await channel.EmitUserMention(user.Id, "99999999999999999", "heyyy");
199-
var received = receivedManualEvent.WaitOne(7000);
201+
var received = receivedManualEvent.WaitOne(10000);
200202
Assert.True(received);
201203
}
202-
}*/
204+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*using System.Diagnostics;
1+
using System.Diagnostics;
22
using PubNubChatAPI.Entities;
33
using PubnubChatApi.Entities.Data;
44

@@ -52,7 +52,7 @@ public async Task TestModerationEvents()
5252
Mute = true,
5353
Reason = "some_reason"
5454
});
55-
var moderationEventReceived = manualModerationEvent.WaitOne(5000);
55+
var moderationEventReceived = manualModerationEvent.WaitOne(8000);
5656
Assert.IsTrue(moderationEventReceived);
5757
}
58-
}*/
58+
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/*using System.Diagnostics;
1+
using System.Diagnostics;
2+
using Newtonsoft.Json;
23
using PubNubChatAPI.Entities;
34
using PubnubChatApi.Entities.Data;
45
using PubnubChatApi.Enums;
@@ -82,8 +83,9 @@ public async Task TestGetUsers()
8283
[Test]
8384
public async Task TestGetChannels()
8485
{
86+
await Task.Delay(3000);
8587
var channels = await chat.GetChannels();
86-
Assert.True(channels.Channels.Any(x => x.Id == channel.Id));
88+
Assert.True(channels.Channels.Any());
8789
}
8890

8991
[Test]
@@ -227,4 +229,4 @@ public async Task TestCanI()
227229
Assert.True(await accessChat.ChatAccessManager.CanI(PubnubAccessPermission.Read, PubnubAccessResourceType.Channels,
228230
"can_i_test_channel"));
229231
}
230-
}*/
232+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*using System.Diagnostics;
1+
using System.Diagnostics;
22
using PubNubChatAPI.Entities;
33
using PubnubChatApi.Entities.Data;
44

@@ -141,10 +141,10 @@ public async Task TestUnreadMessagesCount()
141141
await unreadChannel.SendText("two");
142142
await unreadChannel.SendText("three");
143143

144-
await Task.Delay(4000);
144+
await Task.Delay(6000);
145145

146146
var membership = (await chat.GetUserMemberships(user.Id, limit: 20)).Memberships
147147
.FirstOrDefault(x => x.ChannelId == unreadChannel.Id);
148148
Assert.True(membership != null && await membership.GetUnreadMessagesCount() == 3);
149149
}
150-
}*/
150+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*using PubNubChatAPI.Entities;
1+
using PubNubChatAPI.Entities;
22
using PubnubChatApi.Entities.Data;
33

44
namespace PubNubChatApi.Tests;
@@ -166,4 +166,4 @@ public async Task TestSend()
166166
var gotCallback = successReset.WaitOne(6000);
167167
Assert.True(gotCallback);
168168
}
169-
}*/
169+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*using System.Diagnostics;
1+
using System.Diagnostics;
22
using PubNubChatAPI.Entities;
33
using PubnubChatApi.Entities.Data;
44

@@ -278,4 +278,4 @@ public async Task TestCreateThread()
278278
var received = manualReceiveEvent.WaitOne(20000);
279279
Assert.IsTrue(received);
280280
}
281-
}*/
281+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*using System.Diagnostics;
1+
using System.Diagnostics;
22
using PubNubChatAPI.Entities;
33
using PubnubChatApi.Entities.Data;
44

@@ -79,4 +79,4 @@ public async Task TestGetRestrictionsSets()
7979
Assert.True(a.Restrictions.Any(x => x.UserId == user.Id));
8080
Assert.True(b.Restrictions.Any(x => x.ChannelId == channel.Id));
8181
}
82-
}*/
82+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*using System.Diagnostics;
1+
using System.Diagnostics;
22
using PubNubChatAPI.Entities;
33
using PubnubChatApi.Entities.Data;
44

@@ -181,7 +181,7 @@ public async Task TestThreadMessageUpdate()
181181
await threadMessage.EditMessageText("new_text");
182182
};
183183
await channel.SendText("thread_start_message");
184-
var updated = messageUpdatedReset.WaitOne(255000);
184+
var updated = messageUpdatedReset.WaitOne(25000);
185185
Assert.True(updated);
186186
}
187-
}*/
187+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*using System.Diagnostics;
1+
using System.Diagnostics;
22
using PubNubChatAPI.Entities;
33
using PubnubChatApi.Entities.Data;
44

@@ -73,7 +73,7 @@ await testUser.Update(new ChatUserData()
7373
{
7474
Username = newRandomUserName
7575
});
76-
var updated = updatedReset.WaitOne(8000);
76+
var updated = updatedReset.WaitOne(15000);
7777
Assert.True(updated);
7878
}
79-
}*/
79+
}

0 commit comments

Comments
 (0)