empty message

jaron - September 21, 2009 - 06:14
Project:Privatemsg
Version:7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

i'm posting this as a bug report, but it might be a feature request, i'm not really sure...
in the current build of pm it seems that it is possible to send an empty message. i found this when i inadvertently clicked on 'send message' before i typed anything. to my surprise, it actually sent a message which was blank. would it be possible to add a check to see if a message has been written?

and then one implication of this which i'm not sure how to deal with would be that if the privatemsg system checks to see if a message has been written when the user hits 'send message', how will the 'remove myself from the thread' button work with the pm_forward sub-module? the functionality of that is such that a user can remove themselves without writing a response simply by forwarding the thread without anyone in the 'to' field but with the button clicked to remove themselves. this functionality is great, but if the pm system checks to make sure a message has been written, it would result in an error, correct? any way around this?

#1

Berdir - October 8, 2009 - 14:35
Category:bug report» feature request

This is more or less much be design, atleast for the new message form. You can *either* send a message with an empty subject (subject will be set to first 50 characters of body then) or an empty body but not both.

However, as the reply form does have the subject pre-set, it does not make much sense to send a reply with empty body. Of course, if we change that behavior, the privatemsg_forward module needs to be updated.

I'm changing this to a feature request, because it's not actually a bug imho.

#2

Berdir - October 14, 2009 - 21:05
Status:active» needs review

The attached patch blocks empty replies in the API and the form without breaking privatemsg_forward (Untested, though...).

It does that by simply validating this in _privatemsg_validate_message(). The downside is that the message textarea is not marked as an required field but FAPI doesn't allow us to do so. Alternatively, we could set required to TRUE and let privatemsg_forward remove it again.

AttachmentSize
privatemsg_empty_body.patch 1008 bytes

#3

nbz - October 18, 2009 - 23:19

Do we also want a required check on the form? Something like?

<?php
  $form
['privatemsg']['body'] = array(
...
   
// Make body required for replies.
   
'#required'          => empty($thread_id) ? FALSE : TRUE,
  );
?>

?

#4

Berdir - October 18, 2009 - 23:28

@nbz

The issue is we can't have the required optional then. For example, #548188: add/remove somebody to/from some discussion integrates itself into the reply form and relies on the fact that you can submit that form without writing something into that field. If something has been written, it does add a reply and if not, it just forwards the thread.

However, we need to update http://blog.worldempire.ch/api/function/privatemsg_reply then and make $body a required param.

#5

Berdir - October 19, 2009 - 21:16

Made the $body param to privatemsg_reply() required...

AttachmentSize
privatemsg_empty_body2.patch 1.23 KB

#6

Berdir - October 19, 2009 - 22:50

Added some tests for this and also extended the existing tests for the write/reply form. It does probably not test everything but it's a start that we can extend if there are bugs reported with a special use case.

AttachmentSize
privatemsg_empty_body3.patch 11.27 KB

#7

Berdir - October 22, 2009 - 17:44
Version:6.x-1.x-dev» 7.x-1.x-dev
Status:needs review» fixed

Added to 6.x-1.x-dev and 7.x-1.x-dev.

#8

System Message - November 5, 2009 - 17:50
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.