Skip to content

Commit

Permalink
Merge pull request #165 from TootSDK/add-missing-initializer-for-push…
Browse files Browse the repository at this point in the history
…-notification-params

Add missing initializer for push notification params
  • Loading branch information
kkostov committed May 19, 2023
2 parents 2ed30a9 + 76a8a7f commit 2ef2f43
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 13 deletions.
18 changes: 18 additions & 0 deletions Sources/TootSDK/Models/PushSubscriptionParams.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,29 @@ public struct PushSubscriptionParams: Codable, Sendable {

/// Auth secret. Base64 encoded string of 16 bytes of random data.
public var auth: String

public init(p256dh: String, auth: String) {
self.p256dh = p256dh
self.auth = auth
}
}

public struct SubscriptionData: Codable, Sendable {
public var alerts: Alerts?
/// Specify whether to receive push notifications from all, followed, follower, or none users.
public var policy: String?

public init(alerts: Alerts? = nil, policy: String? = nil) {
self.alerts = alerts
self.policy = policy
}
}

public init(
subscription: PushSubscriptionParams.Subscription,
data: PushSubscriptionParams.SubscriptionData? = nil
) {
self.subscription = subscription
self.data = data
}
}
5 changes: 4 additions & 1 deletion Sources/TootSDK/Models/PushSubscriptionUpdateParams.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import Foundation

/// Change Web Push API subscription configuration request
public struct PushSubscriptionUpdateParams: Codable, Sendable {

public var data: SubscriptionData?
public struct SubscriptionData: Codable, Sendable {
public var alerts: Alerts?
/// Specify whether to receive push notifications from all, followed, follower, or none users.
public var policy: String?
}

public init(data: PushSubscriptionUpdateParams.SubscriptionData? = nil) {
self.data = data
}
}
2 changes: 1 addition & 1 deletion Sources/TootSDK/Models/Suggestion.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Suggestion.swift
//
//
//
// Created by Philip Chu on 5/17/23.
//
Expand Down
4 changes: 2 additions & 2 deletions Sources/TootSDK/TootClient/TootClient+Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension TootClient {
$0.method = .get
$0.query = getQueryParams(pageInfo, limit: limit)
}

return try await fetchPagedResult(req)
}

Expand All @@ -52,7 +52,7 @@ extension TootClient {
$0.method = .get
$0.query = getQueryParams(pageInfo, limit: limit)
}

return try await fetchPagedResult(req)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/TootSDK/TootClient/TootClient+Lists.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public extension TootClient {
$0.method = .get
$0.query = getQueryParams(pageInfo, limit: limit)
}

return try await fetchPagedResult(req)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/TootSDK/TootClient/TootClient+Notifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public extension TootClient {
$0.method = .get
$0.query = createQuery(from: params) + getQueryParams(pageInfo, limit: limit)
}

return try await fetchPagedResult(req)
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/TootSDK/TootClient/TootClient+Relationships.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extension TootClient {
}
return try await fetch(Relationship.self, req)
}

/// Get all accounts which the current account is blocking
/// - Returns: the accounts requested
public func getBlockedAccounts(_ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[Account]> {
Expand All @@ -128,7 +128,7 @@ extension TootClient {
$0.method = .get
$0.query = getQueryParams(pageInfo, limit: limit)
}

return try await fetchPagedResult(req)
}

Expand All @@ -154,7 +154,7 @@ extension TootClient {
}
return try await fetch(Relationship.self, req)
}

/// Get all accounts which the current account is blocking
/// - Returns: the accounts requested
public func getMutedAccounts(_ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[Account]> {
Expand Down
2 changes: 1 addition & 1 deletion Sources/TootSDK/TootClient/TootClient+Suggestions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Foundation

public extension TootClient {

/// Accounts that are promoted by staff, or that the user has had past positive interactions with, but is not yet following.
///
/// - Parameters:
Expand Down
2 changes: 1 addition & 1 deletion Sources/TootSDK/TootClient/TootClient+Tags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public extension TootClient {
$0.method = .get
$0.query = getQueryParams(pageInfo, limit: limit)
}

return try await fetchPagedResult(req)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/TootSDK/TootClient/TootClient+TimeLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension TootClient {
/// - limit: the limit of posts being requested
/// - Returns: a paged result with an array of posts
internal func getPosts(_ req: HTTPRequestBuilder, _ pageInfo: PagedInfo? = nil, _ limit: Int? = nil) async throws -> PagedResult<[Post]> {

return try await fetchPagedResult(req)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/TootSDK/TootClient/TootClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ extension TootClient {
let supportedFlavours = Set(TootSDKFlavour.allCases).subtracting(unsupportedFalvours)
try requireFlavour(supportedFlavours)
}

/// Performs a request that returns paginated arrays
/// - Parameters:
/// - req: the HTTP request to execute
Expand Down

0 comments on commit 2ef2f43

Please sign in to comment.