Resolve body part URL handlers based on part mimetype
ClosedPublic

Authored by dvratil on Oct 18 2017, 7:54 AM.

Details

Summary

This solves ambiguity of URL handlers where multiple URL handlers from
different plugins can handle the same URL or just handle URLs generically,
in which case the first plugin in the list wins regardless of if the
same formatter actually produced the body part.

Diff Detail

Repository
R94 PIM: Message Library
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dvratil created this revision.Oct 18 2017, 7:54 AM
Restricted Application added a project: KDE PIM. · View Herald TranscriptOct 18 2017, 7:54 AM
Restricted Application added a subscriber: KDE PIM. · View Herald Transcript
dvratil updated this revision to Diff 20932.Oct 18 2017, 8:00 AM

Add fallback to URL handlers without mimetype

dvratil updated this revision to Diff 20933.Oct 18 2017, 8:03 AM

Minor improvement

I think it makes more sense to just enable the URLHandlers if one plugin is used (this was the behaviour) before @vkrause 's cleanup. Than you just need to check if the URLHandler is already registered.

vkrause accepted this revision.Oct 18 2017, 3:26 PM

This makes sense and looks good to me. I still fail to understand why this worked before though, I just moved this code to a different location :)

Mapping this to the render plugin that was used is tricky, as we do not persist that information, nor will it always be a single plugin responsible for drawing one part, so I think the mimetype approach works well for this.

Looking forward, I think the URL handling has a deeper problem by using BodyPart rather than MessagePart anyway. While changing that we might want to re-think the URL schema used by makeLink() to disambiguate on that level already.

This revision is now accepted and ready to land.Oct 18 2017, 3:26 PM

This makes sense and looks good to me. I still fail to understand why this worked before though, I just moved this code to a different location :)
Mapping this to the render plugin that was used is tricky, as we do not persist that information, nor will it always be a single plugin responsible for drawing one part, so I think the mimetype approach works well for this.

Wait we know excatly, that a plugin was used for one email, when DefaultRendererPrivate::renderWithFactory retruns true. So adding afterwarts the loading for URLHandler here would result in the correct URLHandlers loaded. This was done before too.

While changing that we might want to re-think the URL schema used by makeLink() to disambiguate on that level already.

+1

This revision was automatically updated to reflect the committed changes.

This makes sense and looks good to me. I still fail to understand why this worked before though, I just moved this code to a different location :)
Mapping this to the render plugin that was used is tricky, as we do not persist that information, nor will it always be a single plugin responsible for drawing one part, so I think the mimetype approach works well for this.

Wait we know excatly, that a plugin was used for one email, when DefaultRendererPrivate::renderWithFactory retruns true. So adding afterwarts the loading for URLHandler here would result in the correct URLHandlers loaded. This was done before too.

It's more complicated than that I'm afraid, some parts delegate to others bypassing DRP, and it is possible to have multiple plugins render content (although we don't do that atm). The use-case I have in mind is the booking information extractor rendering a summary banner before to the message content. So I think we need to tie this to the link URL, not the part.

Independent of that, where is the code that did this before? I'm still wondering how I missed that.

It's more complicated than that I'm afraid, some parts delegate to others bypassing DRP, and it is possible to have multiple plugins render content (although we don't do that atm). The use-case I have in mind is the booking information extractor rendering a summary banner before to the message content. So I think we need to tie this to the link URL, not the part.

But yes make the URLlinks unique is the better way to fix this properly.

Independent of that, where is the code that did this before? I'm still wondering how I missed that.

oh you are right - I thought there was code doing that, so it was luck, that the plugins were loaded the right order :)