beatonma / django-wm

Automatic Webmention functionality for Django models
https://beatonma.org/webmentions_tester/
GNU General Public License v3.0
12 stars 2 forks source link

Webmentions being accepted by pages that aren't Mentionable #39

Closed philgyford closed 1 year ago

philgyford commented 1 year ago

If I link to a page on my own site that doesn't represent an object with MentionableMixin then it registers a mention to that URL. This results in a Webmention object that has no target_object etc.

For example, on this page representing a Post (the only model on the site that has MentionableMixin) I link to this page https://www.gyford.com/phil/creators/8kk28/ . This results in these Webmentions:

Screenshot 2022-10-01 at 22 05 07

With the relevant one like this:

Screenshot 2022-10-01 at 22 05 22

I'm not sure why this happens, given the target URL (/phil/creators/8kk28/) doesn't match the URL of the only MentionableMixin model?

beatonma commented 1 year ago

This is intended behaviour but I'm happy to add a setting to disable it.

The behaviour you expected was how it worked originally. I enabled model-less mentions soon after (1.something) so that pages like a root homepage (that don't necessarily map to any particular model instance) could be mentioned.

The name of MentionableMixin and the readme still somewhat imply that it is a requirement so sorry for the confusion. I'm planning to fill out the wiki to make the various workings of the library less cryptic in general.

philgyford commented 1 year ago

Ah, that makes sense. I did only expect objects that are "Mentionable", and have their URL set up appropriately, to be able to receive mentions.

I probably wouldn't have thought much of it now, except I had some code that started throwing errors – an RSS feed of mentions that expected the presence of a target_object, which I also expected to always be a Post. For now I can make it just ignore any mentions that don't have a target_object.

beatonma commented 1 year ago

You can now (3.1.0) use settings.WEBMENTIONS_INCOMING_TARGET_MODEL_REQUIRED = True to ignore any incoming mentions that do not resolve to a model instance.

philgyford commented 1 year ago

This is great! Thank you so much for this. It seems to work perfectly.