Support audio attachement + better push keys flow

This commit is contained in:
Thomas Ricouard 2023-01-08 16:18:38 +01:00
parent 5920e40528
commit a9db49e5df
3 changed files with 7 additions and 5 deletions

View file

@ -74,6 +74,8 @@ public class PushNotificationsService: ObservableObject {
public func updateSubscriptions(accounts: [PushAccounts]) async { public func updateSubscriptions(accounts: [PushAccounts]) async {
subscriptions = [] subscriptions = []
let key = notificationsPrivateKeyAsKey.publicKey.x963Representation
let authKey = notificationsAuthKeyAsKey
guard let pushToken = pushToken, isUserPushEnabled else { return } guard let pushToken = pushToken, isUserPushEnabled else { return }
for account in accounts { for account in accounts {
let client = Client(server: account.server, oauthToken: account.token) let client = Client(server: account.server, oauthToken: account.token)
@ -87,8 +89,8 @@ public class PushNotificationsService: ObservableObject {
#endif #endif
let sub: PushSubscription = let sub: PushSubscription =
try await client.post(endpoint: Push.createSub(endpoint: listenerURL, try await client.post(endpoint: Push.createSub(endpoint: listenerURL,
p256dh: notificationsPrivateKeyAsKey.publicKey.x963Representation, p256dh: key,
auth: notificationsAuthKeyAsKey, auth: authKey,
mentions: isMentionNotificationEnabled, mentions: isMentionNotificationEnabled,
status: isNewPostsNotificationEnabled, status: isNewPostsNotificationEnabled,
reblog: isReblogNotificationEnabled, reblog: isReblogNotificationEnabled,

View file

@ -11,7 +11,7 @@ public struct MediaAttachement: Codable, Identifiable, Hashable {
} }
public enum SupportedType: String { public enum SupportedType: String {
case image, gifv, video case image, gifv, video, audio
} }
public func hash(into hasher: inout Hasher) { public func hash(into hasher: inout Hasher) {

View file

@ -163,7 +163,7 @@ public struct StatusMediaPreviewView: View {
.shimmering() .shimmering()
}) })
} }
case .gifv, .video: case .gifv, .video, .audio:
if let url = attachement.url { if let url = attachement.url {
VideoPlayerView(viewModel: .init(url: url)) VideoPlayerView(viewModel: .init(url: url))
.frame(height: imageMaxHeight) .frame(height: imageMaxHeight)
@ -209,7 +209,7 @@ public struct StatusMediaPreviewView: View {
.cornerRadius(4) .cornerRadius(4)
} }
} }
case .gifv, .video: case .gifv, .video, .audio:
if let url = attachement.url { if let url = attachement.url {
VideoPlayerView(viewModel: .init(url: url)) VideoPlayerView(viewModel: .init(url: url))
.frame(width: isNotifications ? imageMaxHeight : proxy.frame(in: .local).width) .frame(width: isNotifications ? imageMaxHeight : proxy.frame(in: .local).width)