def METHOD_NAME(request, msgtype="inbox"):
    """Apply action to selected messages."""
    msgids = request.POST.getlist("id")
    if len(msgids) == 0:
        contrib_messages.add_message(
            request, contrib_messages.ERROR, _("No messages selected. Please try again.")
        )
    else:
        if "delete" in request.POST:
            return delete(request, msgtype=msgtype)
        elif "mark_read" in request.POST and msgtype == "inbox":
            messages = InboxMessage.objects.filter(pk__in=msgids, to=request.user)
            messages.update(read=True)
        elif "mark_unread" in request.POST and msgtype == "inbox":
            messages = InboxMessage.objects.filter(pk__in=msgids, to=request.user)
            messages.update(read=False)
    return redirect("messages.%s" % msgtype)