damus icon indicating copy to clipboard operation
damus copied to clipboard

add optional toggle to load remote images

Open radixrat opened this issue 2 years ago • 34 comments

Potential solution for https://github.com/damus-io/damus/issues/124 once toggled all images come from robohash instead of loading from remote profiles

radixrat avatar Dec 23 '22 19:12 radixrat

Looks like if a profile update event comes in it will update self.picture and this was getting leveraged so needed to set the restrict condition to only reference robohash instead of picture ?? robohash

ghost avatar Dec 23 '22 19:12 ghost

option-off option-off-view option-on option-on-view option-on-full-profile

ghost avatar Dec 23 '22 20:12 ghost

when swapping the setting any profiles that were immediately loaded on home view before toggling will still show with previous setting until you scroll down to get more profiles, but I believe this should be blocking anymore remote requests aside from robohash

ghost avatar Dec 23 '22 20:12 ghost

Maybe we can have a picker with 3 or 4 options:

  • Load all images (insecure) -> will load http and https images
  • Load secured images -> will only load https images
  • Load contact images -> will only load people in our contact list
  • No external images -> will only load robot hash

We can simplify it with 3 options I think

0xtlt avatar Dec 23 '22 20:12 0xtlt

Maybe we can have a picker with 3 or 4 options:

  • Load all images (insecure) -> will load http and https images
  • Load secured images -> will only load https images
  • Load contact images -> will only load people in our contact list
  • No external images -> will only load robot hash

We can simplify it with 3 options I think

yeh I think your load all images, load contacts only, and load no external would be good. http/https won’t matter as much if they are worried about ip logging. I’ll have to see if we have a way of determining relation of profile when this image url is set. Thanks.

ghost avatar Dec 23 '22 20:12 ghost

Added three levels of choice:

  • Everyone (default)
  • Friends Only
  • Restricted
Screenshot 2022-12-23 at 10 15 11 PM Screenshot 2022-12-23 at 10 15 18 PM

Not following jb55:

Screenshot 2022-12-23 at 10 15 49 PM

After following:

Screenshot 2022-12-23 at 10 16 14 PM

Everyone else in feed I am not following from this dummy account: Screenshot 2022-12-23 at 10 16 37 PM

ghost avatar Dec 24 '22 03:12 ghost

@jb55 let me know if this is something we might be interested in for future or if you have any alternate suggestions, I just heard some people talking about it in forums so thought I would take a shot at it.

ghost avatar Dec 24 '22 03:12 ghost

Working for me but "Restricted" should be more expressive for non tech people

0xtlt avatar Dec 24 '22 10:12 0xtlt

Hey! I just made a PR to your PR branch: https://github.com/radixrat/damus/pull/1

It contains the working version with enum update :)

0xtlt avatar Dec 24 '22 12:12 0xtlt

Hey! I just made a PR to your PR branch: radixrat#1

It contains the working version with enum update :)

nice, this is much cleaner, I merged it, thanks! What is your opinion on a better word for "Restricted"? would "Block All" give a better indication to end user?

ghost avatar Dec 24 '22 12:12 ghost

In the code you merged, I changed by "Restricted (no remote image)"

Maybe "Block images" can be better

0xtlt avatar Dec 24 '22 14:12 0xtlt

Another thing : If we're going to block profile images, we might block post images/gif as well So, all external contents

0xtlt avatar Dec 24 '22 14:12 0xtlt

Another thing : If we're going to block profile images, we might block post images/gif as well So, all external contents

Yeh believe this could be expanded to cover all image cases, I know there is a block of code that currently restricts image loading to only friends should_show_images in EventView, I think this setting could be leveraged there.

One thing is I think we would want to have a friends of friends option in this case as well

ghost avatar Dec 24 '22 14:12 ghost

Applied same policy to should_show_images we used for profile restrictions, so image loading should follow this setting now as well. One thing I think would be safer is to set the default to Friends of Friends instead of Everyone, the reason the code was initially put in place was to stop the porn bots so setting default to everyone would bring that issue back.

when set to everyone can view images: Screenshot 2022-12-24 at 9 55 01 AM

When restricted it will block: Screenshot 2022-12-24 at 9 55 23 AM

ghost avatar Dec 24 '22 14:12 ghost

Agreed with the default to friends only

I think we can activate friends of friends but if we add this option, I think we need to keep the friend only option too And the option friends of friends can be time consuming to develop

Then maybe an improvement for a next time in another PR (or maybe someone can make it)

0xtlt avatar Dec 24 '22 16:12 0xtlt

Agreed with the default to friends only

I think we can activate friends of friends but if we add this option, I think we need to keep the friend only option too And the option friends of friends can be time consuming to develop

Then maybe an improvement for a next time in another PR (or maybe someone can make it)

Friends of friends is already implemented in contacts module, I added it alongside friends so options now are:

  • Everyone
  • Friends Only
  • Friend of Friends
  • Block Images

Friends of Friends is current default.

think that should cover everything so far.

ghost avatar Dec 24 '22 16:12 ghost

Can we invert friends and friends of friends in the list ?

0xtlt avatar Dec 24 '22 16:12 0xtlt

Can we invert friends and friends of friends in the list ?

done. makes mores sense with this ordering less restrictive -> more restrictive

ghost avatar Dec 24 '22 16:12 ghost

let remote_image_policy: RemoteImagePolicy = RemoteImagePolicy(rawValue: UserDefaults.standard.string(forKey: "remote_image_policy")!) ?? .friendsOfFriends

this can cause crash if optional string UserDefaults.standard.string(forKey: "remote_image_policy")! unwrapped is nil, added a fallback with coalesce, then the existing coalesce outside the brackets should be effective after that point when RemoteImagePolicy comes back nil

ghost avatar Dec 24 '22 19:12 ghost

sorry this got left behind... haven't had a change to review this one yet and looks like it needs rebased

jb55 avatar Dec 31 '22 20:12 jb55

rebased to current upstream

ghost avatar Dec 31 '22 21:12 ghost

Related - I'm actually working on a Core ML porn detector that uses AI to return a value between 0 and 1 for images, where 1 would be extreme content. In the settings you could turn AI detection on.

BenGWeeks avatar Jan 09 '23 11:01 BenGWeeks

Oh!

0xtlt avatar Jan 09 '23 11:01 0xtlt

Related - I'm actually working on a Core ML porn detector that uses AI to return a value between 0 and 1 for images, where 1 would be extreme content. In the settings you could turn AI detection on.

One issue is if it waits till it’s client side to detect, the image has already been retrieved so if you are at work or something it won’t save you from explaining why porn photos were downloaded 😂

I wonder if nostr has a way to mark nsfw at relay level so you never retrieve them. Then you can blame your friendosphere otherwise if they upload nsfw without marking it (or just have it set to never load images while at work)

ghost avatar Jan 09 '23 14:01 ghost

Looks like out of date again I’ll try to rebase, think I need to factor in this new preview pane, if the goal is to not load the images at all from remote sources, I noticed it paints an outline before user clicks so think the image is getting loaded remotely anyways even if show images bool is false, before it would not load the image at all

ghost avatar Jan 09 '23 14:01 ghost

Link would be downloaded but not the image itself until actually displayed or prefetched by the client.

On Mon, 9 Jan 2023 at 14:09, radixrat @.***> wrote:

Related - I'm actually working on a Core ML porn detector that uses AI to return a value between 0 and 1 for images, where 1 would be extreme content. In the settings you could turn AI detection on.

One issue is if it waits till it’s client side to detect, the image has already been retrieved so if you are at work or something it won’t save you from explaining why porn photos were downloaded 😂

— Reply to this email directly, view it on GitHub https://github.com/damus-io/damus/pull/127#issuecomment-1375679207, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEWI45XPQEUG3HMJSUINE3WRQL3NANCNFSM6AAAAAATIAEIBY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

paulrollo avatar Jan 09 '23 14:01 paulrollo

Link would be downloaded but not the image itself until actually displayed or prefetched by the client.

so the porn ML detection is based on url name instead of actual content of the image?

ghost avatar Jan 09 '23 14:01 ghost

Link would be downloaded but not the image itself until actually displayed or prefetched by the client.

so the porn ML detection is based on url name instead of actual content of the image?

I haven't submitted the PR for that yet. I don't think it replaces these options, just an additional option (might put it under "experimental"). You pass the image into a method.

BenGWeeks avatar Jan 09 '23 15:01 BenGWeeks

Link would be downloaded but not the image itself until actually displayed or prefetched by the client.

so the porn ML detection is based on url name instead of actual content of the image?

I haven't submitted the PR for that yet. I don't think it replaces these options, just an additional option (might put it under "experimental"). You pass the image into a method.

Yeh so this is a similar problem I am currently facing with the nice blurred preview pane (as opposed to old behaviour where it showed a link instead of blurred image), the image has to be client side before it can get a blurred version for the ImageCarousal, but by having the image client side to analyze it you've already loaded it from the remote source which means your work network sees you downloaded the porn content.

At least for the image carousal it would be better I think if we had a default image fallback if show images was toggled off @0xtlt not sure if you have any thoughts about this, for now I just left it with blurred preview pane as that is current default.

ghost avatar Jan 09 '23 15:01 ghost

not sure what the state of this is, but ideally I would like to not load blurred images by default. right now they are downloaded and blurred which is not good

jb55 avatar Jan 10 '23 19:01 jb55