docs: def message_remove(request, undo=False):
      """
      A ``POST`` to remove messages.
  
      :param undo:
          A Boolean that if ``True`` unremoves messages.
  
      POST can have the following keys:
  
          ``message_pks``
              List of message id's that should be deleted.
  
          ``next``
              String containing the URI which to redirect to after the keys are
              removed. Redirect defaults to the inbox view.
  
      The ``next`` value can also be supplied in the URI with ``?next=<value>``.
  
      """
      message_pks = request.POST.getlist('message_pks')
      redirect_to = request.GET.get(REDIRECT_FIELD_NAME,
                                    request.POST.get(REDIRECT_FIELD_NAME, False))
  
      if message_pks:
          # Check that all values are integers.
          valid_message_pk_list = set()
          for pk in message_pks:
              try: valid_pk = int(pk)
              except (TypeError, ValueError): pass
              else:
                  valid_message_pk_list.add(valid_pk)
  
          # Delete all the messages, if they belong to the user.
          now = get_datetime_now()
          changed_message_list = set()
          for pk in valid_message_pk_list:
              message = get_object_or_404(Message, pk=pk)
  
              # Check if the user is the owner
              if message.sender == request.user:
                  if undo:
                      message.sender_deleted_at = None
                  else:
                      message.sender_deleted_at = now
                  message.save()
                  changed_message_list.add(message.pk)
  
              # Check if the user is a recipient of the message
              if request.user in message.recipients.all():
                  mr = message.messagerecipient_set.get(user=request.user,
                                                        message=message)
                  if undo:
                      mr.deleted_at = None
                  else:
                      mr.deleted_at = now
                  mr.save()
                  changed_message_list.add(message.pk)
  
          # Send messages
          if (len(changed_message_list) > 0) and userena_settings.USERENA_USE_MESSAGES:
              if undo:
                  message = ungettext('Message is succesfully restored.',
                                      'Messages are succesfully restored.',
                                      len(changed_message_list))
              else:
                  message = ungettext('Message is successfully removed.',
                                      'Messages are successfully removed.',
                                      len(changed_message_list))
  
              messages.success(request, message, fail_silently=True)
  
      if redirect_to: return redirect(redirect_to)
      else: return redirect(reverse('userena_umessages_list'))