diff --git a/Tusker/Models/Draft.swift b/Tusker/Models/Draft.swift index c35cd22c..191a40c8 100644 --- a/Tusker/Models/Draft.swift +++ b/Tusker/Models/Draft.swift @@ -120,12 +120,28 @@ extension MastodonController { var acctsToMention = [String]() var visibility = Preferences.shared.defaultPostVisibility + var contentWarning = "" if let inReplyToID = inReplyToID, let inReplyTo = persistentContainer.status(for: inReplyToID) { acctsToMention.append(inReplyTo.account.acct) acctsToMention.append(contentsOf: inReplyTo.mentions.map(\.acct)) visibility = inReplyTo.visibility + + if !inReplyTo.spoilerText.isEmpty { + switch Preferences.shared.contentWarningCopyMode { + case .doNotCopy: + break + case .asIs: + contentWarning = inReplyTo.spoilerText + case .prependRe: + if inReplyTo.spoilerText.lowercased().starts(with: "re:") { + contentWarning = inReplyTo.spoilerText + } else { + contentWarning = "re: \(inReplyTo.spoilerText)" + } + } + } } if let mentioningAcct = mentioningAcct { acctsToMention.append(mentioningAcct) @@ -140,6 +156,8 @@ extension MastodonController { draft.text = acctsToMention.map { "@\($0) " }.joined() draft.initialText = draft.text draft.visibility = visibility + draft.contentWarning = contentWarning + draft.contentWarningEnabled = !contentWarning.isEmpty return draft }