Skip to content
Open
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
4 changes: 3 additions & 1 deletion Modules/Sources/WordPressKitObjC/PostServiceRemoteREST.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#import "RemotePostTerm.h"
#import "FilePart.h"
#import "NSString+Helpers.h"
#import "NSString+WPKitNumericValueHack.h"

@import WordPressShared;
@import WordPressKitModels;
Expand Down Expand Up @@ -396,7 +397,8 @@ - (RemotePost *)remotePostFromJSONDictionary:(NSDictionary *)jsonPost {
+ (RemotePost *)remotePostFromJSONDictionary:(NSDictionary *)jsonPost {
RemotePost *post = [RemotePost new];
post.postID = jsonPost[@"ID"];
post.siteID = jsonPost[@"site_ID"];
// Create and update responses return site_ID as a string, while read responses return a number.
post.siteID = [jsonPost[@"site_ID"] wpkit_numericValue];
if (jsonPost[@"author"] != [NSNull null]) {
NSDictionary *authorDictionary = jsonPost[@"author"];
post.authorAvatarURL = authorDictionary[@"avatar_URL"];
Expand Down
2 changes: 1 addition & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* [*] [internal] In-app updates: guard the flexible update notice against double-posting when two update checks race [#25666]
* [*] [build tooling] Add a String Catalog localization pipeline (plurals + build-free catalog generation) with a CI coverage gate [#25688]
* [*] [internal] Stats widgets: migrate the site picker from SiriKit to App Intents [#25753]

* [*] Share Extension: Fix a crash after uploading a post to WordPress.com [#25773]

27.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ - (PostServiceRemoteREST*)service
return [[PostServiceRemoteREST alloc] initWithWordPressComRestApi:api siteID:siteID];
}

#pragma mark - Mapping posts

- (void)testThatRemotePostMappingConvertsStringSiteIDToNumber
{
NSDictionary *jsonPost = @{
@"ID": @1147,
@"site_ID": @"237072388"
};

RemotePost *post = [PostServiceRemoteREST remotePostFromJSONDictionary:jsonPost];

XCTAssertEqualObjects(post.postID, @1147);
XCTAssertEqualObjects(post.siteID, @237072388);
XCTAssertTrue([post.siteID isKindOfClass:[NSNumber class]]);
}

#pragma mark - Getting posts by ID

- (void)testThatGetPostWithIDWorks
Expand Down