Compare commits
3 Commits
53611d80d6
...
6b7c828cc9
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 6b7c828cc9 | |
Shadowfacts | 2be1ee19de | |
Shadowfacts | 3f15a453bd |
|
@ -216,7 +216,7 @@ extension DraftAttachment {
|
||||||
options.isNetworkAccessAllowed = true
|
options.isNetworkAccessAllowed = true
|
||||||
PHImageManager.default().requestExportSession(forVideo: asset, options: options, exportPreset: AVAssetExportPresetHighestQuality) { exportSession, info in
|
PHImageManager.default().requestExportSession(forVideo: asset, options: options, exportPreset: AVAssetExportPresetHighestQuality) { exportSession, info in
|
||||||
if let exportSession {
|
if let exportSession {
|
||||||
Self.exportVideoData(session: exportSession, completion: completion)
|
Self.exportVideoData(session: exportSession, features: features, completion: completion)
|
||||||
} else if let error = info?[PHImageErrorKey] as? Error {
|
} else if let error = info?[PHImageErrorKey] as? Error {
|
||||||
completion(.failure(.videoExport(error)))
|
completion(.failure(.videoExport(error)))
|
||||||
} else {
|
} else {
|
||||||
|
@ -242,7 +242,7 @@ extension DraftAttachment {
|
||||||
completion(.failure(.noVideoExportSession))
|
completion(.failure(.noVideoExportSession))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Self.exportVideoData(session: session, completion: completion)
|
Self.exportVideoData(session: session, features: features, completion: completion)
|
||||||
} else {
|
} else {
|
||||||
let fileData: Data
|
let fileData: Data
|
||||||
do {
|
do {
|
||||||
|
@ -300,9 +300,12 @@ extension DraftAttachment {
|
||||||
return (data, type)
|
return (data, type)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func exportVideoData(session: AVAssetExportSession, completion: @escaping (Result<(Data, UTType), ExportError>) -> Void) {
|
private static func exportVideoData(session: AVAssetExportSession, features: InstanceFeatures, completion: @escaping (Result<(Data, UTType), ExportError>) -> Void) {
|
||||||
session.outputFileType = .mp4
|
session.outputFileType = .mp4
|
||||||
session.outputURL = FileManager.default.temporaryDirectory.appendingPathComponent("exported_video_\(UUID())").appendingPathExtension("mp4")
|
session.outputURL = FileManager.default.temporaryDirectory.appendingPathComponent("exported_video_\(UUID())").appendingPathExtension("mp4")
|
||||||
|
if let configuration = features.mediaAttachmentsConfiguration {
|
||||||
|
session.fileLengthLimit = Int64(configuration.videoSizeLimit)
|
||||||
|
}
|
||||||
session.exportAsynchronously {
|
session.exportAsynchronously {
|
||||||
guard session.status == .completed else {
|
guard session.status == .completed else {
|
||||||
completion(.failure(.videoExport(session.error!)))
|
completion(.failure(.videoExport(session.error!)))
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class InstanceFeatures: ObservableObject {
|
||||||
@Published public private(set) var charsReservedPerURL = 23
|
@Published public private(set) var charsReservedPerURL = 23
|
||||||
@Published public private(set) var maxPollOptionChars: Int?
|
@Published public private(set) var maxPollOptionChars: Int?
|
||||||
@Published public private(set) var maxPollOptionsCount: Int?
|
@Published public private(set) var maxPollOptionsCount: Int?
|
||||||
|
@Published public private(set) var mediaAttachmentsConfiguration: Instance.MediaAttachmentsConfiguration?
|
||||||
|
|
||||||
public var localOnlyPosts: Bool {
|
public var localOnlyPosts: Bool {
|
||||||
switch instanceType {
|
switch instanceType {
|
||||||
|
@ -211,6 +212,7 @@ public class InstanceFeatures: ObservableObject {
|
||||||
maxPollOptionChars = pollsConfig.maxCharactersPerOption
|
maxPollOptionChars = pollsConfig.maxCharactersPerOption
|
||||||
maxPollOptionsCount = pollsConfig.maxOptions
|
maxPollOptionsCount = pollsConfig.maxOptions
|
||||||
}
|
}
|
||||||
|
mediaAttachmentsConfiguration = instance.configuration?.mediaAttachments
|
||||||
|
|
||||||
_featuresUpdated.send()
|
_featuresUpdated.send()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1400"
|
LastUpgradeVersion = "1500"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|
|
@ -113,6 +113,7 @@ public class Client {
|
||||||
var urlRequest = URLRequest(url: url, timeoutInterval: timeoutInterval)
|
var urlRequest = URLRequest(url: url, timeoutInterval: timeoutInterval)
|
||||||
urlRequest.httpMethod = request.method.name
|
urlRequest.httpMethod = request.method.name
|
||||||
urlRequest.httpBody = request.body.data
|
urlRequest.httpBody = request.body.data
|
||||||
|
urlRequest.setValue("application/json", forHTTPHeaderField: "Accept")
|
||||||
for (name, value) in request.headers {
|
for (name, value) in request.headers {
|
||||||
urlRequest.setValue(value, forHTTPHeaderField: name)
|
urlRequest.setValue(value, forHTTPHeaderField: name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,20 @@ import Foundation
|
||||||
struct MastodonError: Decodable, CustomStringConvertible {
|
struct MastodonError: Decodable, CustomStringConvertible {
|
||||||
var description: String
|
var description: String
|
||||||
|
|
||||||
|
init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
if let error = try container.decodeIfPresent(String.self, forKey: .error) {
|
||||||
|
self.description = error
|
||||||
|
} else if let message = try container.decodeIfPresent(String.self, forKey: .message) {
|
||||||
|
self.description = message
|
||||||
|
} else {
|
||||||
|
throw DecodingError.keyNotFound(CodingKeys.error, .init(codingPath: container.codingPath, debugDescription: "Missing error or message key"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case description = "error"
|
case error
|
||||||
|
// used by pixelfed
|
||||||
|
case message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1770,8 +1770,9 @@
|
||||||
D6D4DDC4212518A000E1C4BB /* Project object */ = {
|
D6D4DDC4212518A000E1C4BB /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
|
BuildIndependentTargetsInParallel = YES;
|
||||||
LastSwiftUpdateCheck = 1430;
|
LastSwiftUpdateCheck = 1430;
|
||||||
LastUpgradeCheck = 1400;
|
LastUpgradeCheck = 1500;
|
||||||
ORGANIZATIONNAME = Shadowfacts;
|
ORGANIZATIONNAME = Shadowfacts;
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
D6A4531229EF64BA00032932 = {
|
D6A4531229EF64BA00032932 = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1430"
|
LastUpgradeVersion = "1500"
|
||||||
wasCreatedForAppExtension = "YES"
|
wasCreatedForAppExtension = "YES"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1400"
|
LastUpgradeVersion = "1500"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|
Loading…
Reference in New Issue