From 930ec7ccff384fd8b64e59359c46589578148b27 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 16 Feb 2022 22:12:56 -0500 Subject: [PATCH] Handle gotosocial gif attachments --- Pachyderm/Model/Attachment.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Pachyderm/Model/Attachment.swift b/Pachyderm/Model/Attachment.swift index 2e4282589a..309e9fcff0 100644 --- a/Pachyderm/Model/Attachment.swift +++ b/Pachyderm/Model/Attachment.swift @@ -56,6 +56,23 @@ extension Attachment { case gifv case audio case unknown + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + switch try container.decode(String.self) { + // gotosocial uses "gif" for gif images + case "image", "gif": + self = .image + case "video": + self = .video + case "gifv": + self = .gifv + case "audio": + self = .audio + default: + self = .unknown + } + } } }