Pixelfed workaround.
This commit is contained in:
parent
7342c9f231
commit
94ee40ba44
|
@ -22,6 +22,33 @@ public extension MastodonClientAuthenticated {
|
|||
target: Mastodon.Media.update(id, description, focus),
|
||||
withBearerToken: token)
|
||||
|
||||
return try await downloadJson(UploadedAttachment.self, request: request)
|
||||
let (data, response) = try await urlSession.data(for: request)
|
||||
|
||||
// TODO: Pixelfed.social returns some list instead of single media!
|
||||
// return try await downloadJson(UploadedAttachment.self, request: request)
|
||||
|
||||
guard (response as? HTTPURLResponse)?.status?.responseType == .success else {
|
||||
throw NetworkError.notSuccessResponse(response)
|
||||
}
|
||||
|
||||
do {
|
||||
return try JSONDecoder().decode(UploadedAttachment.self, from: data)
|
||||
} catch {
|
||||
do {
|
||||
let list = try JSONDecoder().decode([UploadedAttachment].self, from: data)
|
||||
print("[Error] Instead of single item server retured list of others media attachments!")
|
||||
|
||||
if let entity = list.first(where: { item in item.id == id }) {
|
||||
return entity
|
||||
}
|
||||
|
||||
throw NetworkError.unknownError
|
||||
} catch {
|
||||
let json = String(data: data, encoding: .utf8)!
|
||||
print(json)
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -967,7 +967,7 @@
|
|||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
CURRENT_PROJECT_VERSION = 6;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
@ -1004,7 +1004,7 @@
|
|||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
CURRENT_PROJECT_VERSION = 6;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
|
Loading…
Reference in New Issue