Skip to content

Commit dfdc8de

Browse files
authored
Append "+testing" to feedback form email for Automatticians (#23804)
1 parent a254d33 commit dfdc8de

File tree

4 files changed

+72
-4
lines changed

4 files changed

+72
-4
lines changed

WordPress/Classes/Utility/ZendeskUtils.swift

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ protocol ZendeskUtilsProtocol {
4242
/// as well as displaying views for the Help Center, new tickets, and ticket list.
4343
///
4444
@objc class ZendeskUtils: NSObject, ZendeskUtilsProtocol {
45-
4645
// MARK: - Public Properties
4746

4847
static var sharedInstance: ZendeskUtils = ZendeskUtils(contextManager: ContextManager.shared)
@@ -63,7 +62,15 @@ protocol ZendeskUtilsProtocol {
6362
private var sourceTag: WordPressSupportSourceTag?
6463

6564
private var userName: String?
66-
private var userEmail: String?
65+
private var userEmail: String? {
66+
set {
67+
_userEmail = newValue.map(ZendeskUtils.a8cTestEmail(_:))
68+
}
69+
get {
70+
_userEmail
71+
}
72+
}
73+
private var _userEmail: String?
6774
private var userNameConfirmed = false
6875

6976
private var deviceID: String?
@@ -1201,3 +1208,26 @@ extension ZendeskUtils {
12011208
}
12021209
}
12031210
}
1211+
1212+
extension ZendeskUtils {
1213+
static var automatticEmails = ["@automattic.com", "@a8c.com"]
1214+
1215+
/// Insert "+testing" to Automattic email address.
1216+
/// - SeeAlso: https://github.com/wordpress-mobile/WordPress-iOS/issues/23794
1217+
static func a8cTestEmail(_ email: String) -> String {
1218+
guard let suffix = ZendeskUtils.automatticEmails.first(where: { email.lowercased().hasSuffix($0) }) else {
1219+
return email
1220+
}
1221+
1222+
let atSymbolIndex = email.index(email.endIndex, offsetBy: -suffix.count)
1223+
1224+
// Do nothing if the email is already an "alias email".
1225+
if email[email.startIndex..<atSymbolIndex].contains("+") {
1226+
return email
1227+
}
1228+
1229+
var newEmail = email
1230+
newEmail.insert(contentsOf: "+testing", at: atSymbolIndex)
1231+
return newEmail
1232+
}
1233+
}

WordPress/Classes/ViewRelated/Support/SupportTableViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ private extension SupportTableViewController {
333333
///
334334
func checkForAutomatticEmail() {
335335
guard let email = ZendeskUtils.userSupportEmail(),
336-
(Constants.automatticEmails.first { email.contains($0) }) != nil else {
336+
(ZendeskUtils.automatticEmails.first { email.contains($0) }) != nil else {
337337
return
338338
}
339339

@@ -526,7 +526,6 @@ private extension SupportTableViewController {
526526
static let jetpackMigrationFAQURL = URL(string: "https://jetpack.com/support/switch-to-the-jetpack-app/")
527527

528528
static let forumsURL = URL(string: "https://wordpress.org/support/forum/mobile/")
529-
static let automatticEmails = ["@automattic.com", "@a8c.com"]
530529
}
531530
}
532531

WordPress/WordPress.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@
440440
4A2C73E42A943DEA00ACE79E /* TaggedManagedObjectIDTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A2C73E32A943DEA00ACE79E /* TaggedManagedObjectIDTests.swift */; };
441441
4A2C73F72A9585B000ACE79E /* PostRepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A2C73F62A9585B000ACE79E /* PostRepositoryTests.swift */; };
442442
4A5598852B05AC180083C220 /* PagesListTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A5598842B05AC180083C220 /* PagesListTests.swift */; };
443+
4A5EDD812CE58B9900A605FC /* ZendeskUtilsTests+A8CEmail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A5EDD802CE58B9900A605FC /* ZendeskUtilsTests+A8CEmail.swift */; };
443444
4A690C152BA791B100A8E0C5 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 4A690C142BA790BC00A8E0C5 /* PrivacyInfo.xcprivacy */; };
444445
4A690C162BA791B200A8E0C5 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 4A690C142BA790BC00A8E0C5 /* PrivacyInfo.xcprivacy */; };
445446
4A690C182BA794C800A8E0C5 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 4A690C172BA794C300A8E0C5 /* PrivacyInfo.xcprivacy */; };
@@ -2329,6 +2330,7 @@
23292330
4A2C73F62A9585B000ACE79E /* PostRepositoryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostRepositoryTests.swift; sourceTree = "<group>"; };
23302331
4A2F746A2C2198CB00E72117 /* WordPressAuthenticatorTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WordPressAuthenticatorTests.xcconfig; sourceTree = "<group>"; };
23312332
4A5598842B05AC180083C220 /* PagesListTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PagesListTests.swift; sourceTree = "<group>"; };
2333+
4A5EDD802CE58B9900A605FC /* ZendeskUtilsTests+A8CEmail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ZendeskUtilsTests+A8CEmail.swift"; sourceTree = "<group>"; };
23322334
4A690C142BA790BC00A8E0C5 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
23332335
4A690C172BA794C300A8E0C5 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
23342336
4A690C1A2BA7958F00A8E0C5 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
@@ -4733,6 +4735,7 @@
47334735
isa = PBXGroup;
47344736
children = (
47354737
3F751D452491A93D0008A2B1 /* ZendeskUtilsTests+Plans.swift */,
4738+
4A5EDD802CE58B9900A605FC /* ZendeskUtilsTests+A8CEmail.swift */,
47364739
);
47374740
name = Zendesk;
47384741
sourceTree = "<group>";
@@ -10085,6 +10088,7 @@
1008510088
D81C2F6620F8ACCD002AE1F1 /* FormattableContentFormatterTests.swift in Sources */,
1008610089
08AA640C2A8511FB0076E38D /* DashboardGoogleDomainsViewModelTests.swift in Sources */,
1008710090
83EF3D7F2937F08C000AF9BF /* SharedDataIssueSolverTests.swift in Sources */,
10091+
4A5EDD812CE58B9900A605FC /* ZendeskUtilsTests+A8CEmail.swift in Sources */,
1008810092
8070EB3E28D807CB005C6513 /* InMemoryUserDefaults.swift in Sources */,
1008910093
F93735F822D53C3B00A3C312 /* LoggingURLRedactorTests.swift in Sources */,
1009010094
C738CB1128626606001BE107 /* QRLoginVerifyCoordinatorTests.swift in Sources */,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Foundation
2+
import Testing
3+
4+
@testable import WordPress
5+
6+
@Suite
7+
struct ZendeskUtilsA8CEmailTests {
8+
9+
@Test(
10+
arguments: [
11+
12+
13+
14+
15+
]
16+
)
17+
func insertTesting(email: String, expected: String) {
18+
let result = ZendeskUtils.a8cTestEmail(email)
19+
#expect(result == expected)
20+
}
21+
22+
@Test(
23+
arguments: [
24+
25+
26+
27+
28+
]
29+
)
30+
func keepOriginalEmail(email: String) {
31+
let result = ZendeskUtils.a8cTestEmail(email)
32+
#expect(result == email)
33+
}
34+
35+
}

0 commit comments

Comments
 (0)