Skip to content

Commit

Permalink
Merge branch 'trunk' into address-app-privacy-declaration-requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
crazytonyli committed Apr 3, 2024
2 parents c824bc4 + c2d4a35 commit fd7dfe2
Show file tree
Hide file tree
Showing 107 changed files with 4,297 additions and 2,411 deletions.
24 changes: 0 additions & 24 deletions .buildkite/commands/release-build-wordpress-internal.sh

This file was deleted.

21 changes: 3 additions & 18 deletions .buildkite/release-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,20 @@ common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#3.1.0
# Common environment values to use with the `env` key.
- &common_env
# Be sure to also update the `.xcode-version` file when updating the Xcode image/version here
IMAGE_ID: xcode-15.1

env:
IMAGE_ID: xcode-15.1

steps:

- label: ":wordpress: :testflight: WordPress Release Build (App Store Connect)"
command: ".buildkite/commands/release-build-wordpress.sh $BETA_RELEASE"
# The TestFlight build has a priority of 2 so that it is higher than the AppCenter build
priority: 2
env: *common_env
plugins: *common_plugins
notify:
- slack: "#build-and-ship"

- label: ":wordpress: :appcenter: WordPress Release Build (App Center)"
command: ".buildkite/commands/release-build-wordpress-internal.sh"
priority: 1
env: *common_env
plugins: *common_plugins
notify:
- slack: "#build-and-ship"

- label: ":jetpack: :testflight: Jetpack Release Build (App Store Connect)"
command: ".buildkite/commands/release-build-jetpack.sh"
# The TestFlight build has a priority of 2 so that it is higher than the AppCenter build
priority: 2
env: *common_env
plugins: *common_plugins
notify:
- slack: "#build-and-ship"
12 changes: 9 additions & 3 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@ def aztec
end

def wordpress_ui
pod 'WordPressUI', '~> 1.15'
pod 'WordPressUI', '~> 1.16'
# pod 'WordPressUI', git: 'https://github.com/wordpress-mobile/WordPressUI-iOS', tag: ''
# pod 'WordPressUI', git: 'https://github.com/wordpress-mobile/WordPressUI-iOS', branch: ''
# pod 'WordPressUI', git: 'https://github.com/wordpress-mobile/WordPressUI-iOS', commit: ''
# pod 'WordPressUI', path: '../WordPressUI-iOS'
end

def gravatar
# pod 'Gravatar', path: '../Gravatar-SDK-iOS'
pod 'Gravatar', '1.0.0'
end

def wordpress_kit
pod 'WordPressKit', '~> 14.1'
pod 'WordPressKit', '~> 16.0.0'
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', commit: ''
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', branch: ''
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', tag: ''
Expand Down Expand Up @@ -132,6 +137,7 @@ abstract_target 'Apps' do
wordpress_kit
wordpress_shared
kanvas
gravatar

# Production

Expand All @@ -143,7 +149,7 @@ abstract_target 'Apps' do

pod 'NSURL+IDN', '~> 0.4'

pod 'WordPressAuthenticator', '~> 9.0', '>= 9.0.2'
pod 'WordPressAuthenticator', '~> 9.0', '>= 9.0.6'
# pod 'WordPressAuthenticator', git: 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', commit: ''
# pod 'WordPressAuthenticator', git: 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', branch: ''
# pod 'WordPressAuthenticator', path: '../WordPressAuthenticator-iOS'
Expand Down
26 changes: 15 additions & 11 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PODS:
- Down (0.6.6)
- FSInteractiveMap (0.1.0)
- Gifu (3.3.1)
- Gravatar (1.0.0)
- Gridicons (1.2.0)
- Gutenberg (1.116.0)
- JTAppleCalendar (8.0.5)
Expand Down Expand Up @@ -63,20 +64,20 @@ PODS:
- WordPress-Aztec-iOS (1.19.11)
- WordPress-Editor-iOS (1.19.11):
- WordPress-Aztec-iOS (= 1.19.11)
- WordPressAuthenticator (9.0.3):
- WordPressAuthenticator (9.0.6):
- Gridicons (~> 1.0)
- "NSURL+IDN (= 0.4)"
- SVProgressHUD (~> 2.2.5)
- WordPressKit (~> 14.0)
- WordPressKit (~> 16.0)
- WordPressShared (~> 2.1-beta)
- WordPressUI (~> 1.7-beta)
- WordPressKit (14.1.0):
- WordPressKit (16.0.0):
- NSObject-SafeExpectations (~> 0.0.4)
- UIDeviceIdentifier (~> 2.0)
- WordPressShared (~> 2.0-beta)
- wpxmlrpc (~> 0.10)
- WordPressShared (2.3.1)
- WordPressUI (1.15.1)
- WordPressUI (1.16.0)
- wpxmlrpc (0.10.0)
- ZendeskCommonUISDK (6.1.4)
- ZendeskCoreSDK (2.5.1)
Expand Down Expand Up @@ -104,6 +105,7 @@ DEPENDENCIES:
- Down (~> 0.6.6)
- FSInteractiveMap (from `https://github.com/wordpress-mobile/FSInteractiveMap.git`, tag `0.2.0`)
- Gifu (= 3.3.1)
- Gravatar (= 1.0.0)
- Gridicons (~> 1.2)
- Gutenberg (from `https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.116.0.podspec`)
- JTAppleCalendar (~> 8.0.5)
Expand All @@ -118,10 +120,10 @@ DEPENDENCIES:
- SVProgressHUD (= 2.2.5)
- SwiftLint (= 0.54.0)
- WordPress-Editor-iOS (~> 1.19.11)
- WordPressAuthenticator (>= 9.0.2, ~> 9.0)
- WordPressKit (~> 14.1)
- WordPressAuthenticator (>= 9.0.6, ~> 9.0)
- WordPressKit (~> 16.0.0)
- WordPressShared (>= 2.3.1, ~> 2.3)
- WordPressUI (~> 1.15)
- WordPressUI (~> 1.16)
- ZendeskSupportSDK (= 5.3.0)
- ZIPFoundation (= 0.9.16)

Expand All @@ -140,6 +142,7 @@ SPEC REPOS:
- CropViewController
- Down
- Gifu
- Gravatar
- Gridicons
- JTAppleCalendar
- Kanvas
Expand Down Expand Up @@ -192,6 +195,7 @@ SPEC CHECKSUMS:
Down: 71bf4af3c04fa093e65dffa25c4b64fa61287373
FSInteractiveMap: a396f610f48b76cb540baa87139d056429abda86
Gifu: 416d4e38c4c2fed012f019e0a1d3ffcb58e5b842
Gravatar: bdd3950c5128304b51a9e655e4145334f23201d1
Gridicons: 4455b9f366960121430e45997e32112ae49ffe1d
Gutenberg: fda9c1f9d8d5ec0b565d0efb32757a39b046f538
JTAppleCalendar: 16c6501b22cb27520372c28b0a2e0b12c8d0cd73
Expand All @@ -211,10 +215,10 @@ SPEC CHECKSUMS:
UIDeviceIdentifier: 442b65b4ff1832d4ca9c2a157815cb29ad981b17
WordPress-Aztec-iOS: 3732c6d865a5c9f35788377bdeda8a80ea10d0a1
WordPress-Editor-iOS: 453345420ced3d3ef20f0051b3df46ff10281e0c
WordPressAuthenticator: 20c962dc116473337be1a3825bd16c321ee865cb
WordPressKit: 324ee6100ad74b72c0c37b81fab8937c437f0773
WordPressAuthenticator: 6be121346d4303dd32904a57f6d0e68eaa825152
WordPressKit: f6dc2acce37a526ddb59e02388b3d59da50918ed
WordPressShared: 04c6d51441bb8fa29651075b3a5536c90ae89c76
WordPressUI: 700e3ec5a9f77b6920c8104c338c85788036ab3c
WordPressUI: ec5ebcf7e63e797ba51d07513e340c1b14cf45a4
wpxmlrpc: 68db063041e85d186db21f674adf08d9c70627fd
ZendeskCommonUISDK: ba160fe413b491af9e7bfcb9808afcd494dc83a5
ZendeskCoreSDK: 19a18e5ef2edcb18f4dbc0ea0d12bd31f515712a
Expand All @@ -225,6 +229,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
ZIPFoundation: d170fa8e270b2a32bef9dcdcabff5b8f1a5deced

PODFILE CHECKSUM: 90ee5f33a5d3b4270124d7a10e2315ef6ace2204
PODFILE CHECKSUM: b361dfc7bcbb688ac4bf5bef27e75c33438c5fb3

COCOAPODS: 1.15.2
5 changes: 5 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
24.7
-----


24.6
-----
* [**] Block editor: Highlight text fixes [https://github.com/WordPress/gutenberg/pull/57650]
* [*] [Jetpack-only] Stats: Eliminated common error causes in the Insights tab. [#22890]
* [*] [Jetpack-only] Reader: Fix displaying stale site information [#22885]

24.5
Expand Down
3 changes: 2 additions & 1 deletion WordPress/Classes/Models/ManagedPerson.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation
import CoreData
import WordPressKit
import WordPressUI
import Gravatar

public typealias Person = RemotePerson

Expand All @@ -10,7 +11,7 @@ public typealias Person = RemotePerson
class ManagedPerson: NSManagedObject {

func updateWith<T: Person>(_ person: T) {
let canonicalAvatarURL = person.avatarURL.flatMap { Gravatar($0)?.canonicalURL }
let canonicalAvatarURL = person.avatarURL.flatMap { AvatarURL(url: $0)?.canonicalURL }

avatarURL = canonicalAvatarURL?.absoluteString
displayName = person.displayName
Expand Down
42 changes: 25 additions & 17 deletions WordPress/Classes/Services/GravatarService.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import Foundation
import CocoaLumberjack
import WordPressKit
import Gravatar

@objc public enum GravatarServiceError: Int, Error {
case invalidAccountInfo
}

public protocol GravatarImageUploader {
@discardableResult
func upload(_ image: UIImage, email: Email, accessToken: String) async throws -> URLResponse
}

extension AvatarService: GravatarImageUploader { }

/// This Service exposes all of the valid operations we can execute, to interact with the Gravatar Service.
///
open class GravatarService {
public class GravatarService {

let imageUploader: GravatarImageUploader

init(imageUploader: GravatarImageUploader? = nil) {
self.imageUploader = imageUploader ?? AvatarService()
}

/// This method fetches the Gravatar profile for the specified email address.
///
Expand All @@ -17,7 +31,7 @@ open class GravatarService {
/// - completion: A completion block.
///
open func fetchProfile(email: String, onCompletion: @escaping ((_ profile: GravatarProfile?) -> Void)) {
let remote = gravatarServiceRemote()
let remote = GravatarServiceRemote()
remote.fetchProfile(email, success: { remoteProfile in
var profile = GravatarProfile()
profile.profileID = remoteProfile.profileID
Expand All @@ -43,31 +57,25 @@ open class GravatarService {
/// - account: The WPAccount instance for which to upload a new image.
/// - completion: An optional closure to be executed on completion.
///
open func uploadImage(_ image: UIImage, forAccount account: WPAccount, completion: ((_ error: NSError?) -> ())? = nil) {
open func uploadImage(_ image: UIImage, forAccount account: WPAccount, completion: ((_ error: Error?) -> ())? = nil) {
guard
let accountToken = account.authToken, !accountToken.isEmpty,
let accountEmail = account.email, !accountEmail.isEmpty else {
completion?(GravatarServiceError.invalidAccountInfo as NSError)
completion?(GravatarServiceError.invalidAccountInfo)
return
}

let email = accountEmail.trimmingCharacters(in: CharacterSet.whitespaces).lowercased()

let remote = gravatarServiceRemote()
remote.uploadImage(image, accountEmail: email, accountToken: accountToken) { (error) in
if let theError = error {
DDLogError("GravatarService.uploadImage Error: \(theError)")
} else {
Task {
do {
try await imageUploader.upload(image, email: Email(email), accessToken: accountToken)
DDLogInfo("GravatarService.uploadImage Success!")
completion?(nil)
} catch {
DDLogError("GravatarService.uploadImage Error: \(error)")
completion?(error)
}

completion?(error)
}
}

/// Overridden by tests for mocking.
///
func gravatarServiceRemote() -> GravatarServiceRemote {
return GravatarServiceRemote()
}
}
5 changes: 4 additions & 1 deletion WordPress/Classes/Services/PostRepository+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import WordPressKit
extension RemotePostCreateParameters {
/// Initializes the parameters required to create the given post.
init(post: AbstractPost) {
self.init(status: (post.status ?? .draft).rawValue)
self.init(
type: post is Post ? "post" : "page",
status: (post.status ?? .draft).rawValue
)

date = post.dateCreated
authorID = post.authorID?.intValue
Expand Down
72 changes: 72 additions & 0 deletions WordPress/Classes/Services/ReaderTopicService+FollowedSites.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

extension ReaderTopicService {

enum FollowedSitesError: Error {
case unknown
}

@objc func fetchAllFollowedSites(success: @escaping () -> Void, failure: @escaping (Error?) -> Void) {
let service = ReaderTopicServiceRemote(wordPressComRestApi: apiRequest())
let pageSize: UInt = 100

service.fetchFollowedSites(forPage: 1, number: pageSize) { totalSites, sites in
guard let totalSites, let sites else {
failure(nil)
return
}
let totalPages = Int(ceil(Double(totalSites.intValue) / Double(pageSize)))
WPAnalytics.subscriptionCount = totalSites.intValue

guard totalPages > 1 else {
self.mergeFollowedSites(sites, withSuccess: success)
return
}

Task {
await withTaskGroup(of: Result<[RemoteReaderSiteInfo], Error>.self) { taskGroup in
for page in 2...totalPages {
taskGroup.addTask {
return await self.fetchFollowedSites(service: service, page: UInt(page), number: pageSize)
}
}
var allSites = sites
for await result in taskGroup {
switch result {
case .success(let sites):
allSites.append(contentsOf: sites)
case .failure(let error):
DispatchQueue.main.async {
failure(error)
}
return
}
}
self.mergeFollowedSites(allSites, withSuccess: success)
}
}
} failure: { error in
failure(error)
}
}

private func fetchFollowedSites(service: ReaderTopicServiceRemote, page: UInt, number: UInt) async -> Result<[RemoteReaderSiteInfo], Error> {
return await withCheckedContinuation { continuation in
service.fetchFollowedSites(forPage: page, number: number) { _, sites in
continuation.resume(returning: .success(sites ?? []))
} failure: { error in
DDLogError("Error fetching page \(page) for followed sites: \(String(describing: error))")
continuation.resume(returning: .failure(error ?? FollowedSitesError.unknown))
}
}
}

private func apiRequest() -> WordPressComRestApi {
let token = self.coreDataStack.performQuery { context in
try? WPAccount.lookupDefaultWordPressComAccount(in: context)?.authToken
}

return WordPressComRestApi.defaultApi(oAuthToken: token,
userAgent: WPUserAgent.wordPress())
}

}
Loading

0 comments on commit fd7dfe2

Please sign in to comment.