Skip to content

Commit 2c66b2b

Browse files
jakub-grzesiowskimohitpubnubMohit Tejanipubnub-release-bot
authored
History result refactor (#261)
* refactor PNHistoryItemResult Meta and Action fields to be formatted dictionaries instead of plain objects * fix: issue with publish POST with PAM enabled keyset (#262) * handle publish POST with secret key, calculate signature as old way * tests for signature calculation across all http method types * test-fix: removed unnecessary authtoken for secretKey test case for publish * test fix, removing invalid characters space from channel name Co-authored-by: Mohit Tejani <[email protected]> Co-authored-by: Mohit Tejani <[email protected]> Co-authored-by: PubNub Release Bot <[email protected]>
1 parent 5b05902 commit 2c66b2b

19 files changed

+500
-104
lines changed

.pubnub.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
name: c-sharp
2-
version: "7.4.1"
2+
version: "7.5.0"
33
schema: 1
44
scm: github.com/pubnub/c-sharp
55
changelog:
6+
- date: 2025-09-01
7+
version: v7.5.0
8+
changes:
9+
- type: bug
10+
text: "Fixed types of Meta and Actions in PNHistoryItemResult to not be objects but properly formatted Dictionaries."
11+
- type: bug
12+
text: "Fixed issue of getting Forbidden error while using publish with POST type along with PAM enabled keyset."
613
- date: 2025-07-30
714
version: v7.4.1
815
changes:
@@ -936,7 +943,7 @@ features:
936943
- QUERY-PARAM
937944
supported-platforms:
938945
-
939-
version: Pubnub 'C#' 7.4.1
946+
version: Pubnub 'C#' 7.5.0
940947
platforms:
941948
- Windows 10 and up
942949
- Windows Server 2008 and up
@@ -947,7 +954,7 @@ supported-platforms:
947954
- .Net Framework 4.6.1+
948955
- .Net Framework 6.0
949956
-
950-
version: PubnubPCL 'C#' 7.4.1
957+
version: PubnubPCL 'C#' 7.5.0
951958
platforms:
952959
- Xamarin.Android
953960
- Xamarin.iOS
@@ -967,7 +974,7 @@ supported-platforms:
967974
- .Net Core
968975
- .Net 6.0
969976
-
970-
version: PubnubUWP 'C#' 7.4.1
977+
version: PubnubUWP 'C#' 7.5.0
971978
platforms:
972979
- Windows Phone 10
973980
- Universal Windows Apps
@@ -991,7 +998,7 @@ sdks:
991998
distribution-type: source
992999
distribution-repository: GitHub
9931000
package-name: Pubnub
994-
location: https://github.com/pubnub/c-sharp/releases/tag/v7.4.1.0
1001+
location: https://github.com/pubnub/c-sharp/releases/tag/v7.5.0.0
9951002
requires:
9961003
-
9971004
name: ".Net"
@@ -1274,7 +1281,7 @@ sdks:
12741281
distribution-type: source
12751282
distribution-repository: GitHub
12761283
package-name: PubNubPCL
1277-
location: https://github.com/pubnub/c-sharp/releases/tag/v7.4.1.0
1284+
location: https://github.com/pubnub/c-sharp/releases/tag/v7.5.0.0
12781285
requires:
12791286
-
12801287
name: ".Net Core"
@@ -1633,7 +1640,7 @@ sdks:
16331640
distribution-type: source
16341641
distribution-repository: GitHub
16351642
package-name: PubnubUWP
1636-
location: https://github.com/pubnub/c-sharp/releases/tag/v7.4.1.0
1643+
location: https://github.com/pubnub/c-sharp/releases/tag/v7.5.0.0
16371644
requires:
16381645
-
16391646
name: "Universal Windows Platform Development"

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v7.5.0 - September 01 2025
2+
-----------------------------
3+
- Fixed: fixed types of Meta and Actions in PNHistoryItemResult to not be objects but properly formatted Dictionaries.
4+
- Fixed: fixed issue of getting Forbidden error while using publish with POST type along with PAM enabled keyset.
5+
16
v7.4.1 - July 30 2025
27
-----------------------------
38
- Fixed: added MembershipMetadata container inside PNObjectEventResult to correctly parse and forward data when object event type is "membership".

src/Api/PubnubApi/JsonDataParse/PNFetchHistoryJsonDataParse.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,42 @@ internal static PNFetchHistoryResult GetObject(IJsonPluggableLibrary jsonPlug, L
4646

4747
if (messagesContainer.ContainsKey("meta"))
4848
{
49-
result.Meta = messagesContainer["meta"];
49+
result.Meta = jsonPlug.ConvertToDictionaryObject(messagesContainer["meta"]);
5050
}
5151

5252
if (messagesContainer.ContainsKey("actions"))
5353
{
5454
result.Actions = messagesContainer["actions"];
55+
var formattedActions = new Dictionary<string, List<PNMessageActionItem>>();
56+
var actionsRaw = messagesContainer["actions"] as Dictionary<string, object>;
57+
foreach (var rawAction in actionsRaw)
58+
{
59+
var actionItems = new List<PNMessageActionItem>();
60+
var actionType = rawAction.Key;
61+
var rawActionValues = rawAction.Value as Dictionary<string, object>;
62+
foreach (var rawActionValue in rawActionValues)
63+
{
64+
var actionValue = rawActionValue.Key;
65+
var entries = rawActionValue.Value as List<object>;
66+
foreach (var entry in entries)
67+
{
68+
var entryDict = entry as Dictionary<string, object>;
69+
actionItems.Add(new PNMessageActionItem()
70+
{
71+
ActionTimetoken = long.Parse(entryDict["actionTimetoken"].ToString()),
72+
Uuid = entryDict["uuid"].ToString(),
73+
Action = new PNMessageAction()
74+
{
75+
Type = actionType,
76+
Value = actionValue
77+
},
78+
MessageTimetoken = result.Timetoken
79+
});
80+
}
81+
}
82+
formattedActions[actionType] = actionItems;
83+
}
84+
result.ActionItems = formattedActions;
5585
}
5686
if (messagesContainer.ContainsKey("uuid") && messagesContainer["uuid"] != null)
5787
{

src/Api/PubnubApi/JsonDataParse/PNHistoryJsonDataParse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ internal static PNHistoryResult GetObject(IJsonPluggableLibrary jsonPlug, List<o
5555

5656
if (dicMessageTimetoken.ContainsKey("meta"))
5757
{
58-
result.Meta = dicMessageTimetoken["meta"];
58+
result.Meta = jsonPlug.ConvertToDictionaryObject(dicMessageTimetoken["meta"]);
5959
}
6060
if (dicMessageTimetoken.ContainsKey("uuid") && dicMessageTimetoken["uuid"] != null)
6161
{

src/Api/PubnubApi/Model/Consumer/History/PNHistoryItemResult.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
53

64
namespace PubnubApi
75
{
86
public class PNHistoryItemResult
97
{
108
public long Timetoken { get; internal set; }
119
public object Entry { get; internal set; }
12-
public object Meta { get; internal set; }
10+
public Dictionary<string, object> Meta { get; internal set; }
11+
[Obsolete("Uses old data format, please use ActionItems instead")]
1312
public object Actions { get; internal set; }
13+
public Dictionary<string, List<PNMessageActionItem>> ActionItems { get; internal set; }
1414
public string Uuid { get; internal set; }
1515
public int MessageType { get; internal set; }
1616

src/Api/PubnubApi/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
[assembly: AssemblyProduct("Pubnub C# SDK")]
1212
[assembly: AssemblyCopyright("Copyright © 2021")]
1313
[assembly: AssemblyTrademark("")]
14-
[assembly: AssemblyVersion("7.4.1.0")]
15-
[assembly: AssemblyFileVersion("7.4.1.0")]
14+
[assembly: AssemblyVersion("7.5.0.0")]
15+
[assembly: AssemblyFileVersion("7.5.0.0")]
1616
// Setting ComVisible to false makes the types in this assembly not visible
1717
// to COM components. If you need to access a type in this assembly from
1818
// COM, set the ComVisible attribute to true on that type.

src/Api/PubnubApi/PubnubApi.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414

1515
<PropertyGroup>
1616
<PackageId>Pubnub</PackageId>
17-
<PackageVersion>7.4.1.0</PackageVersion>
17+
<PackageVersion>7.5.0.0</PackageVersion>
1818
<Title>PubNub C# .NET - Web Data Push API</Title>
1919
<Authors>Pandu Masabathula</Authors>
2020
<Owners>PubNub</Owners>
2121
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2222
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
2323
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2424
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
25-
<PackageReleaseNotes>Added MembershipMetadata container inside PNObjectEventResult to correctly parse and forward data when object event type is `membership`.
26-
Fixed issue where some result objects like PNMessageResult had UserMetadata declared as an object instead of the standard Dictionary format for metadata.</PackageReleaseNotes>
25+
<PackageReleaseNotes>Fixed types of Meta and Actions in PNHistoryItemResult to not be objects but properly formatted Dictionaries.
26+
Fixed issue of getting Forbidden error while using publish with POST type along with PAM enabled keyset.</PackageReleaseNotes>
2727
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
2828
<!--<Summary>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Summary>-->
2929
<Description>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Description>

src/Api/PubnubApi/Transport/Middleware.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ public TransportRequest PreapareTransportRequest(RequestParameter requestParamet
8080
{
8181
string signature = string.Empty;
8282
StringBuilder stringToSign = new StringBuilder();
83-
stringToSign.AppendFormat(CultureInfo.InvariantCulture, "{0}\n", requestParameter.RequestType);
83+
stringToSign.AppendFormat(CultureInfo.InvariantCulture, "{0}\n", operationType == PNOperationType.PNPublishOperation ? "GET" : requestParameter.RequestType);
8484
stringToSign.AppendFormat(CultureInfo.InvariantCulture, "{0}\n", configuration.PublishKey);
8585
stringToSign.AppendFormat(CultureInfo.InvariantCulture, "{0}\n", pathString);
8686
stringToSign.AppendFormat(CultureInfo.InvariantCulture, "{0}\n", queryString);
87-
if (!string.IsNullOrEmpty(requestParameter.BodyContentString)) stringToSign.Append(requestParameter.BodyContentString);
87+
if (!string.IsNullOrEmpty(requestParameter.BodyContentString) && operationType != PNOperationType.PNPublishOperation) stringToSign.Append(requestParameter.BodyContentString);
8888
signature = Util.PubnubAccessManagerSign(configuration.SecretKey, stringToSign.ToString());
8989
signature = string.Format(CultureInfo.InvariantCulture, "v2.{0}", signature.TrimEnd(new[] { '=' }));
9090
requestParameter.Query.Add("signature", signature);

src/Api/PubnubApiPCL/PubnubApiPCL.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414

1515
<PropertyGroup>
1616
<PackageId>PubnubPCL</PackageId>
17-
<PackageVersion>7.4.1.0</PackageVersion>
17+
<PackageVersion>7.5.0.0</PackageVersion>
1818
<Title>PubNub C# .NET - Web Data Push API</Title>
1919
<Authors>Pandu Masabathula</Authors>
2020
<Owners>PubNub</Owners>
2121
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2222
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
2323
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2424
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
25-
<PackageReleaseNotes>Added MembershipMetadata container inside PNObjectEventResult to correctly parse and forward data when object event type is `membership`.
26-
Fixed issue where some result objects like PNMessageResult had UserMetadata declared as an object instead of the standard Dictionary format for metadata.</PackageReleaseNotes>
25+
<PackageReleaseNotes>Fixed types of Meta and Actions in PNHistoryItemResult to not be objects but properly formatted Dictionaries.
26+
Fixed issue of getting Forbidden error while using publish with POST type along with PAM enabled keyset.</PackageReleaseNotes>
2727
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
2828
<!--<Summary>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Summary>-->
2929
<Description>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Description>

src/Api/PubnubApiUWP/PubnubApiUWP.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616

1717
<PropertyGroup>
1818
<PackageId>PubnubUWP</PackageId>
19-
<PackageVersion>7.4.1.0</PackageVersion>
19+
<PackageVersion>7.5.0.0</PackageVersion>
2020
<Title>PubNub C# .NET - Web Data Push API</Title>
2121
<Authors>Pandu Masabathula</Authors>
2222
<Owners>PubNub</Owners>
2323
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2424
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
2525
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2626
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
27-
<PackageReleaseNotes>Added MembershipMetadata container inside PNObjectEventResult to correctly parse and forward data when object event type is `membership`.
28-
Fixed issue where some result objects like PNMessageResult had UserMetadata declared as an object instead of the standard Dictionary format for metadata.</PackageReleaseNotes>
27+
<PackageReleaseNotes>Fixed types of Meta and Actions in PNHistoryItemResult to not be objects but properly formatted Dictionaries.
28+
Fixed issue of getting Forbidden error while using publish with POST type along with PAM enabled keyset.</PackageReleaseNotes>
2929
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
3030
<!--<Summary>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Summary>-->
3131
<Description>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Description>

0 commit comments

Comments
 (0)