I’ve updated this code snippet so it abides by your Discussion settings for the checkbox “Comment author must have a previously approved comment.”
I’ve also updated it to use the webmention_source_url
which is part of the comment meta data passed into the filter.
If you have that box checked and approve a webmention from a post on example.com, subsequent webmentions from example.com will be automatically approved. If that box is not checked, this automatic approval code won’t run.
This does override the other spam checks like maximum number of links and comment blacklist keywords. Generally, I think this is acceptable since the approval of a webmention from a source domain is a stronger signal than the approval of a name and email that was entered in a comment form.