'Accept an invite to moderate the specified subreddit.
The authenticated user must have been invited to moderate the subreddit
by one of its current moderators.
See also: [/api/friend](#POST_api_friend) and
[/subreddits/mine](#GET_subreddits_mine_{where}).'

@require_oauth2_scope('modself')
@validatedForm(VUser(), VModhash())
@api_doc(api_section.moderation, uses_site=True)
def POST_accept_moderator_invite(self, form, jquery):

    rel = c.site.get_moderator_invite(c.user)
    if (not c.site.remove_moderator_invite(c.user)):
        c.errors.add(errors.NO_INVITE_FOUND)
        form.set_error(errors.NO_INVITE_FOUND, None)
        return
    permissions = rel.get_permissions()
    ModAction.create(c.site, c.user, 'acceptmoderatorinvite')
    c.site.add_moderator(c.user, permissions=rel.get_permissions())
    notify_user_added('accept_moderator_invite', c.user, c.user, c.site)
    jquery.refresh()
