'For blocking via inbox.'

@require_oauth2_scope('privatemessages')
@noresponse(VUser(), VModhash(), thing=VByName('id'))
@api_doc(api_section.messages)
def POST_block(self, thing):

    if (not thing):
        return
    if (thing.author_id == c.user._id):
        return
    try:
        sr = (Subreddit._byID(thing.sr_id) if thing.sr_id else None)
    except NotFound:
        sr = None
    if (getattr(thing, 'from_sr', False) and sr):
        if (not (sr.is_moderator(c.user) or c.user_is_admin)):
            BlockedSubredditsByAccount.block(c.user, sr)
        return
    is_modmail = (isinstance(thing, Message) and sr and sr.is_moderator_with_perms(c.user, 'mail'))
    if (not is_modmail):
        inbox_cls = Inbox.rel(Account, thing.__class__)
        rels = inbox_cls._fast_query(c.user, thing, ('inbox', 'selfreply', 'mention'))
        if (not any(rels.values())):
            return
    block_acct = Account._byID(thing.author_id)
    display_author = getattr(thing, 'display_author', None)
    if ((block_acct.name in g.admins) or display_author):
        return
    c.user.add_enemy(block_acct)
    g.events.report_event(subreddit=sr, target=thing, request=request, context=c, event_type='ss.block_user')
