Skip to content
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

How to only send webmentions from "live" objects? #30

Closed
philgyford opened this issue Mar 30, 2022 · 0 comments · Fixed by #37
Closed

How to only send webmentions from "live" objects? #30

philgyford opened this issue Mar 30, 2022 · 0 comments · Fixed by #37

Comments

@philgyford
Copy link

I've added MentionableMixin to a Post model, that has statuses of "Draft" and "Published", and I'm trying to work out how I can ensure that webmentions are only sent when a Post object's saved and it's in "Published" state. At the moment, overriding the save() method, I can't figure out a way to do it.

My initial thought is to give MentionableMixin a get_allow_outgoing_webmentions() method that, by default, just returns the value of allow_outgoing_webmentions. Child classes could override this with something like:

    def get_allow_outgoing_webmentions(self):
        if self.allow_outgoing_webmentions and self.status == LIVE:
            return True
        else:
            return False

Then the existing MentionableMixin.save() method could check that instead of allow_outgoing_webmentions before handling them.

I guess add a matching get_allow_incoming_webmentions() method for completeness too.

beatonma added a commit that referenced this issue Sep 29, 2022
…ixin.

This returns the value of `allow_outgoing_webmentions` by default but
may be overridden with custom logic.
@beatonma beatonma mentioned this issue Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant