Skip to content

Commit 820a627

Browse files
authored
Merge pull request #1 from FastComments/release-2025-11-20
Release v0.1.0 - Add optional response fields, comment approvals, adds Linux support
2 parents 3b44503 + ab4000d commit 820a627

19 files changed

+98
-10
lines changed

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.2.1

Package.resolved

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ let package = Package(
2020
dependencies: [
2121
// Dependencies declare other packages that this package depends on.
2222
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.8.0"),
23+
.package(url: "https://github.com/apple/swift-crypto.git", from: "3.0.0"),
2324
],
2425
targets: [
2526
// Targets are the basic building blocks of a package, defining a module or a test suite.
2627
.target(
2728
name: "FastCommentsSwift",
28-
dependencies: ["Alamofire"],
29+
dependencies: [
30+
"Alamofire",
31+
.product(name: "Crypto", package: "swift-crypto", condition: .when(platforms: [.linux])),
32+
],
2933
path: ".",
3034
exclude: [
3135
"Tests",

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Add the following to your `Package.swift` file:
1010

1111
```swift
1212
dependencies: [
13-
.package(url: "https://github.com/fastcomments/fastcomments-swift.git", from: "0.0.1")
13+
.package(url: "https://github.com/fastcomments/fastcomments-swift.git", from: "0.1.0")
1414
]
1515
```
1616

Sources/FastCommentsSwift/SSO/Helpers.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import Foundation
2+
3+
#if canImport(CryptoKit)
24
import CryptoKit
5+
#else
6+
import Crypto
7+
#endif
38

49
/// Helper functions for FastComments SSO
510
public enum Helpers {

client/FastCommentsSwift/Models/APICreateUserBadgeResponse.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ public struct APICreateUserBadgeResponse: Sendable, Codable, JSONEncodable, Hash
1111

1212
public var status: APIStatus
1313
public var userBadge: UserBadge
14+
public var notes: [String]?
1415

15-
public init(status: APIStatus, userBadge: UserBadge) {
16+
public init(status: APIStatus, userBadge: UserBadge, notes: [String]? = nil) {
1617
self.status = status
1718
self.userBadge = userBadge
19+
self.notes = notes
1820
}
1921

2022
public enum CodingKeys: String, CodingKey, CaseIterable {
2123
case status
2224
case userBadge
25+
case notes
2326
}
2427

2528
// Encodable protocol methods
@@ -28,6 +31,7 @@ public struct APICreateUserBadgeResponse: Sendable, Codable, JSONEncodable, Hash
2831
var container = encoder.container(keyedBy: CodingKeys.self)
2932
try container.encode(status, forKey: .status)
3033
try container.encode(userBadge, forKey: .userBadge)
34+
try container.encodeIfPresent(notes, forKey: .notes)
3135
}
3236
}
3337

client/FastCommentsSwift/Models/CreateUserBadge200Response.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public struct CreateUserBadge200Response: Sendable, Codable, JSONEncodable, Hash
1111

1212
public var status: APIStatus
1313
public var userBadge: UserBadge
14+
public var notes: [String]?
1415
public var reason: String
1516
public var code: String
1617
public var secondaryCode: String?
@@ -19,9 +20,10 @@ public struct CreateUserBadge200Response: Sendable, Codable, JSONEncodable, Hash
1920
public var translatedError: String?
2021
public var customConfig: CustomConfigParameters?
2122

22-
public init(status: APIStatus, userBadge: UserBadge, reason: String, code: String, secondaryCode: String? = nil, bannedUntil: Int64? = nil, maxCharacterLength: Int? = nil, translatedError: String? = nil, customConfig: CustomConfigParameters? = nil) {
23+
public init(status: APIStatus, userBadge: UserBadge, notes: [String]? = nil, reason: String, code: String, secondaryCode: String? = nil, bannedUntil: Int64? = nil, maxCharacterLength: Int? = nil, translatedError: String? = nil, customConfig: CustomConfigParameters? = nil) {
2324
self.status = status
2425
self.userBadge = userBadge
26+
self.notes = notes
2527
self.reason = reason
2628
self.code = code
2729
self.secondaryCode = secondaryCode
@@ -34,6 +36,7 @@ public struct CreateUserBadge200Response: Sendable, Codable, JSONEncodable, Hash
3436
public enum CodingKeys: String, CodingKey, CaseIterable {
3537
case status
3638
case userBadge
39+
case notes
3740
case reason
3841
case code
3942
case secondaryCode
@@ -49,6 +52,7 @@ public struct CreateUserBadge200Response: Sendable, Codable, JSONEncodable, Hash
4952
var container = encoder.container(keyedBy: CodingKeys.self)
5053
try container.encode(status, forKey: .status)
5154
try container.encode(userBadge, forKey: .userBadge)
55+
try container.encodeIfPresent(notes, forKey: .notes)
5256
try container.encode(reason, forKey: .reason)
5357
try container.encode(code, forKey: .code)
5458
try container.encodeIfPresent(secondaryCode, forKey: .secondaryCode)

client/FastCommentsSwift/Models/CustomConfigParameters.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public struct CustomConfigParameters: Sendable, Codable, JSONEncodable, Hashable
6161
public var noStyles: Bool?
6262
public var pageSize: Int?
6363
public var readonly: Bool?
64+
public var noNewRootComments: Bool?
6465
public var requireSSO: Bool?
6566
public var enableResizeHandle: Bool?
6667
public var restrictedLinkDomains: [String]?
@@ -83,7 +84,7 @@ public struct CustomConfigParameters: Sendable, Codable, JSONEncodable, Hashable
8384
public var widgetSubQuestionVisibility: QuestionSubQuestionVisibility?
8485
public var wrap: Bool?
8586

86-
public init(absoluteAndRelativeDates: Bool? = nil, absoluteDates: Bool? = nil, allowAnon: Bool? = nil, allowAnonFlag: Bool? = nil, allowAnonVotes: Bool? = nil, allowedLanguages: [String]? = nil, collapseReplies: Bool? = nil, commentCountFormat: String? = nil, commentHTMLRenderingMode: CommentHTMLRenderingMode? = nil, commentThreadDeleteMode: CommentThreadDeletionMode? = nil, commenterNameFormat: CommenterNameFormats? = nil, countAboveToggle: Int? = nil, customCSS: String? = nil, defaultAvatarSrc: String? = nil, defaultSortDirection: SortDirections? = nil, defaultUsername: String? = nil, disableAutoAdminMigration: Bool? = nil, disableAutoHashTagCreation: Bool? = nil, disableBlocking: Bool? = nil, disableCommenterCommentDelete: Bool? = nil, disableCommenterCommentEdit: Bool? = nil, disableEmailInputs: Bool? = nil, disableLiveCommenting: Bool? = nil, disableNotificationBell: Bool? = nil, disableProfiles: Bool? = nil, disableSuccessMessage: Bool? = nil, disableToolbar: Bool? = nil, disableUnverifiedLabel: Bool? = nil, disableVoting: Bool? = nil, enableCommenterLinks: Bool? = nil, enableSearch: Bool? = nil, enableSpoilers: Bool? = nil, enableThirdPartyCookieBypass: Bool? = nil, enableViewCounts: Bool? = nil, enableVoteList: Bool? = nil, enableWYSIWYG: Bool? = nil, gifRating: GifRating? = nil, hasDarkBackground: Bool? = nil, headerHTML: String? = nil, hideAvatars: Bool? = nil, hideCommentsUnderCountTextFormat: String? = nil, imageContentProfanityLevel: ImageContentProfanityLevel? = nil, inputAfterComments: Bool? = nil, limitCommentsByGroups: Bool? = nil, locale: String? = nil, maxCommentCharacterLength: Int? = nil, maxCommentCreatedCountPUPM: Int? = nil, noCustomConfig: Bool? = nil, noImageUploads: Bool? = nil, noStyles: Bool? = nil, pageSize: Int? = nil, readonly: Bool? = nil, requireSSO: Bool? = nil, enableResizeHandle: Bool? = nil, restrictedLinkDomains: [String]? = nil, showBadgesInTopBar: Bool? = nil, showCommentSaveSuccess: Bool? = nil, showLiveRightAway: Bool? = nil, showQuestion: Bool? = nil, spamRules: [SpamRule]? = nil, ssoSecLvl: SSOSecurityLevel? = nil, translations: [String: String]? = nil, useShowCommentsToggle: Bool? = nil, useSingleLineCommentInput: Bool? = nil, voteStyle: VoteStyle? = nil, widgetQuestionId: String? = nil, widgetQuestionResultsStyle: CommentQuestionResultsRenderingType? = nil, widgetQuestionStyle: QuestionRenderingType? = nil, widgetQuestionWhenToSave: QuestionWhenSave? = nil, widgetQuestionsRequired: CommentQuestionsRequired? = nil, widgetSubQuestionVisibility: QuestionSubQuestionVisibility? = nil, wrap: Bool? = nil) {
87+
public init(absoluteAndRelativeDates: Bool? = nil, absoluteDates: Bool? = nil, allowAnon: Bool? = nil, allowAnonFlag: Bool? = nil, allowAnonVotes: Bool? = nil, allowedLanguages: [String]? = nil, collapseReplies: Bool? = nil, commentCountFormat: String? = nil, commentHTMLRenderingMode: CommentHTMLRenderingMode? = nil, commentThreadDeleteMode: CommentThreadDeletionMode? = nil, commenterNameFormat: CommenterNameFormats? = nil, countAboveToggle: Int? = nil, customCSS: String? = nil, defaultAvatarSrc: String? = nil, defaultSortDirection: SortDirections? = nil, defaultUsername: String? = nil, disableAutoAdminMigration: Bool? = nil, disableAutoHashTagCreation: Bool? = nil, disableBlocking: Bool? = nil, disableCommenterCommentDelete: Bool? = nil, disableCommenterCommentEdit: Bool? = nil, disableEmailInputs: Bool? = nil, disableLiveCommenting: Bool? = nil, disableNotificationBell: Bool? = nil, disableProfiles: Bool? = nil, disableSuccessMessage: Bool? = nil, disableToolbar: Bool? = nil, disableUnverifiedLabel: Bool? = nil, disableVoting: Bool? = nil, enableCommenterLinks: Bool? = nil, enableSearch: Bool? = nil, enableSpoilers: Bool? = nil, enableThirdPartyCookieBypass: Bool? = nil, enableViewCounts: Bool? = nil, enableVoteList: Bool? = nil, enableWYSIWYG: Bool? = nil, gifRating: GifRating? = nil, hasDarkBackground: Bool? = nil, headerHTML: String? = nil, hideAvatars: Bool? = nil, hideCommentsUnderCountTextFormat: String? = nil, imageContentProfanityLevel: ImageContentProfanityLevel? = nil, inputAfterComments: Bool? = nil, limitCommentsByGroups: Bool? = nil, locale: String? = nil, maxCommentCharacterLength: Int? = nil, maxCommentCreatedCountPUPM: Int? = nil, noCustomConfig: Bool? = nil, noImageUploads: Bool? = nil, noStyles: Bool? = nil, pageSize: Int? = nil, readonly: Bool? = nil, noNewRootComments: Bool? = nil, requireSSO: Bool? = nil, enableResizeHandle: Bool? = nil, restrictedLinkDomains: [String]? = nil, showBadgesInTopBar: Bool? = nil, showCommentSaveSuccess: Bool? = nil, showLiveRightAway: Bool? = nil, showQuestion: Bool? = nil, spamRules: [SpamRule]? = nil, ssoSecLvl: SSOSecurityLevel? = nil, translations: [String: String]? = nil, useShowCommentsToggle: Bool? = nil, useSingleLineCommentInput: Bool? = nil, voteStyle: VoteStyle? = nil, widgetQuestionId: String? = nil, widgetQuestionResultsStyle: CommentQuestionResultsRenderingType? = nil, widgetQuestionStyle: QuestionRenderingType? = nil, widgetQuestionWhenToSave: QuestionWhenSave? = nil, widgetQuestionsRequired: CommentQuestionsRequired? = nil, widgetSubQuestionVisibility: QuestionSubQuestionVisibility? = nil, wrap: Bool? = nil) {
8788
self.absoluteAndRelativeDates = absoluteAndRelativeDates
8889
self.absoluteDates = absoluteDates
8990
self.allowAnon = allowAnon
@@ -136,6 +137,7 @@ public struct CustomConfigParameters: Sendable, Codable, JSONEncodable, Hashable
136137
self.noStyles = noStyles
137138
self.pageSize = pageSize
138139
self.readonly = readonly
140+
self.noNewRootComments = noNewRootComments
139141
self.requireSSO = requireSSO
140142
self.enableResizeHandle = enableResizeHandle
141143
self.restrictedLinkDomains = restrictedLinkDomains
@@ -211,6 +213,7 @@ public struct CustomConfigParameters: Sendable, Codable, JSONEncodable, Hashable
211213
case noStyles
212214
case pageSize
213215
case readonly
216+
case noNewRootComments
214217
case requireSSO
215218
case enableResizeHandle
216219
case restrictedLinkDomains
@@ -289,6 +292,7 @@ public struct CustomConfigParameters: Sendable, Codable, JSONEncodable, Hashable
289292
try container.encodeIfPresent(noStyles, forKey: .noStyles)
290293
try container.encodeIfPresent(pageSize, forKey: .pageSize)
291294
try container.encodeIfPresent(readonly, forKey: .readonly)
295+
try container.encodeIfPresent(noNewRootComments, forKey: .noNewRootComments)
292296
try container.encodeIfPresent(requireSSO, forKey: .requireSSO)
293297
try container.encodeIfPresent(enableResizeHandle, forKey: .enableResizeHandle)
294298
try container.encodeIfPresent(restrictedLinkDomains, forKey: .restrictedLinkDomains)

client/FastCommentsSwift/Models/PatchPageAPIResponse.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ public struct PatchPageAPIResponse: Sendable, Codable, JSONEncodable, Hashable {
1111

1212
public var reason: String?
1313
public var code: String?
14+
public var commentsUpdated: Int64?
1415
public var page: APIPage?
1516
public var status: String
1617

17-
public init(reason: String? = nil, code: String? = nil, page: APIPage? = nil, status: String) {
18+
public init(reason: String? = nil, code: String? = nil, commentsUpdated: Int64? = nil, page: APIPage? = nil, status: String) {
1819
self.reason = reason
1920
self.code = code
21+
self.commentsUpdated = commentsUpdated
2022
self.page = page
2123
self.status = status
2224
}
2325

2426
public enum CodingKeys: String, CodingKey, CaseIterable {
2527
case reason
2628
case code
29+
case commentsUpdated
2730
case page
2831
case status
2932
}
@@ -34,6 +37,7 @@ public struct PatchPageAPIResponse: Sendable, Codable, JSONEncodable, Hashable {
3437
var container = encoder.container(keyedBy: CodingKeys.self)
3538
try container.encodeIfPresent(reason, forKey: .reason)
3639
try container.encodeIfPresent(code, forKey: .code)
40+
try container.encodeIfPresent(commentsUpdated, forKey: .commentsUpdated)
3741
try container.encodeIfPresent(page, forKey: .page)
3842
try container.encode(status, forKey: .status)
3943
}

client/FastCommentsSwift/Models/PublicComment.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public struct PublicComment: Sendable, Codable, JSONEncodable, Hashable {
3737
public var feedbackIds: [String]?
3838
public var requiresVerification: Bool?
3939
public var editKey: String?
40+
public var approved: Bool?
4041
public var isUnread: Bool?
4142
public var myVoteId: String?
4243
public var isVotedDown: Bool?
@@ -51,7 +52,7 @@ public struct PublicComment: Sendable, Codable, JSONEncodable, Hashable {
5152
public var isFlagged: Bool?
5253
public var isBlocked: Bool?
5354

54-
public init(id: String, userId: String? = nil, commenterName: String, commenterLink: String? = nil, commentHTML: String, parentId: String? = nil, date: Date?, votes: Int? = nil, votesUp: Int? = nil, votesDown: Int? = nil, verified: Bool, avatarSrc: String? = nil, hasImages: Bool? = nil, isByAdmin: Bool? = nil, isByModerator: Bool? = nil, isPinned: Bool? = nil, isLocked: Bool? = nil, displayLabel: String? = nil, rating: Double? = nil, badges: [CommentUserBadgeInfo]? = nil, viewCount: Int64? = nil, isDeleted: Bool? = nil, isDeletedUser: Bool? = nil, isSpam: Bool? = nil, anonUserId: String? = nil, feedbackIds: [String]? = nil, requiresVerification: Bool? = nil, editKey: String? = nil, isUnread: Bool? = nil, myVoteId: String? = nil, isVotedDown: Bool? = nil, isVotedUp: Bool? = nil, hasChildren: Bool? = nil, nestedChildrenCount: Int? = nil, childCount: Int? = nil, children: [PublicComment]? = nil, isFlagged: Bool? = nil, isBlocked: Bool? = nil) {
55+
public init(id: String, userId: String? = nil, commenterName: String, commenterLink: String? = nil, commentHTML: String, parentId: String? = nil, date: Date?, votes: Int? = nil, votesUp: Int? = nil, votesDown: Int? = nil, verified: Bool, avatarSrc: String? = nil, hasImages: Bool? = nil, isByAdmin: Bool? = nil, isByModerator: Bool? = nil, isPinned: Bool? = nil, isLocked: Bool? = nil, displayLabel: String? = nil, rating: Double? = nil, badges: [CommentUserBadgeInfo]? = nil, viewCount: Int64? = nil, isDeleted: Bool? = nil, isDeletedUser: Bool? = nil, isSpam: Bool? = nil, anonUserId: String? = nil, feedbackIds: [String]? = nil, requiresVerification: Bool? = nil, editKey: String? = nil, approved: Bool? = nil, isUnread: Bool? = nil, myVoteId: String? = nil, isVotedDown: Bool? = nil, isVotedUp: Bool? = nil, hasChildren: Bool? = nil, nestedChildrenCount: Int? = nil, childCount: Int? = nil, children: [PublicComment]? = nil, isFlagged: Bool? = nil, isBlocked: Bool? = nil) {
5556
self.id = id
5657
self.userId = userId
5758
self.commenterName = commenterName
@@ -80,6 +81,7 @@ public struct PublicComment: Sendable, Codable, JSONEncodable, Hashable {
8081
self.feedbackIds = feedbackIds
8182
self.requiresVerification = requiresVerification
8283
self.editKey = editKey
84+
self.approved = approved
8385
self.isUnread = isUnread
8486
self.myVoteId = myVoteId
8587
self.isVotedDown = isVotedDown
@@ -121,6 +123,7 @@ public struct PublicComment: Sendable, Codable, JSONEncodable, Hashable {
121123
case feedbackIds
122124
case requiresVerification
123125
case editKey
126+
case approved
124127
case isUnread
125128
case myVoteId
126129
case isVotedDown
@@ -165,6 +168,7 @@ public struct PublicComment: Sendable, Codable, JSONEncodable, Hashable {
165168
try container.encodeIfPresent(feedbackIds, forKey: .feedbackIds)
166169
try container.encodeIfPresent(requiresVerification, forKey: .requiresVerification)
167170
try container.encodeIfPresent(editKey, forKey: .editKey)
171+
try container.encodeIfPresent(approved, forKey: .approved)
168172
try container.encodeIfPresent(isUnread, forKey: .isUnread)
169173
try container.encodeIfPresent(myVoteId, forKey: .myVoteId)
170174
try container.encodeIfPresent(isVotedDown, forKey: .isVotedDown)

0 commit comments

Comments
 (0)