Please note that the Akismet plugin is much more defensive and careful when performing this operation.

I did not study internals yet, but here's the code:
```
// Assumption alert:
// We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
// is changed automatically by another plugin.  Unfortunately WordPress doesn't provide an unambiguous way to
// determine why the transition_comment_status action was triggered.  And there are several different ways by which
// to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
// We'll assume that this is an explicit user action if POST or GET has an 'action' key.
if (isset($_POST['action']) || isset($_GET['action'])) {
  if ($new_status == 'spam' && ($old_status == 'approved' || $old_status == 'unapproved' || !$old_status)) {
    return akismet_submit_spam_comment($comment->comment_ID);
  }
  elseif ($old_status == 'spam' && ($new_status == 'approved' || $new_status == 'unapproved')) {
    return akismet_submit_nonspam_comment($comment->comment_ID);
  }
}
add_action('transition_comment_status', 'akismet_transition_comment_status', 10, 3);
```

It's perfectly possible that this code only attempts to play nicely with older WP versions (backwards compatibility), but based on my studies some weeks ago, I think that the comment moderation actions are indeed a huge can of worms.  So let's be careful and double-check this.