-
Notifications
You must be signed in to change notification settings - Fork 45
Adds support for PostImages.org for image hosting #1218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
nolanw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! couple nits
| private class ImgurUploadProviderAdapter: ImageUploadProvider { | ||
|
|
||
| func upload(_ image: UIImage, completion: @escaping (Result<ImageUploadResponse, Error>) -> Void) -> Progress { | ||
| return ImgurUploader.shared.upload(image) { result in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoding this singleton access seems weird. At minimum can we pass it in?
|
|
||
| // If they had "Off", set Imgur mode to anonymous for when they switch back | ||
| if imgurMode == "Off" { | ||
| defaults.set("Anonymous", forKey: Settings.imgurUploadMode.key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably use ImgurUploadMode (raw) values for this and "PostImages" below.
| @AppStorage(Settings.automaticTimg) private var timgLargeImages | ||
| @AppStorage(Settings.useNewSmiliePicker) private var useNewSmiliePicker | ||
| @AppStorage("imgur_upload_mode") private var imgurUploadMode: String = "Off" | ||
| @AppStorage("image_hosting_provider") private var imageHostingProvider: String = "Imgur" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to use ImageHostingProvider here instead of a plain String? I thought AppStorage could handle that but maybe I'm wrong.
| public init() { | ||
| let config = URLSessionConfiguration.ephemeral | ||
| config.httpAdditionalHeaders = [ | ||
| "User-Agent": "Awful iOS App" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We set a custom user-agent in Awful proper, would be nice to reuse that here. Could pass it in to the initializer maybe.
|
|
||
| // Move everyone to PostImages.org by default (they can switch back if they want) | ||
| defaults.set("PostImages", forKey: Settings.imageHostingProvider.key) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinking more about this. I don’t think we should forcibly move people over if they’ve manually chosen imgur. I do like changing the default for when nothing has been chosen.
if we still want to give a little push for people who intentionally chose imgur, maybe a one time alert somewhere suggesting the change and offering to make it?
This PR adds a new option to upload images to PostImages.org instead of Imgur. I've also taken away the option to completely disable image uploads since that caused some confusion.
The new option is under "Settings" under "Image Hosting". Postimages is made the default, and there's a little bit of text explaining the reason for the migration.
Imgur is still available in case users have a strong preference for it, and a protocol was put down in case we want to add other image hosts later.
The rational:
Imgur has been getting less reliable. Recent company layoffs, and the SSO for authentication has been hit or miss. See https://forums.somethingawful.com/showthread.php?threadid=3837546&userid=0&perpage=40&pagenumber=215#post547839086