Create a basic Messages system
For 0.8.8, I need to create a basic Message system. For now, Messages will have to be created by signed in users because I don't have emailing setup, although in the future I could expand it so you can save a long URL so non-authenticated users can return to their messages (and use captchas). Messages should be threaded so the admins and user can respond to each other.
Ideas for attributes:
- Sender (foreign key)
- Date sent (aka created at) - datetime
- Responding to (ID of original message) - int
- Message subject (nil if a response) - string (255 chars)
- Message body - text (4 MB, should probably cap at something like 8192 or 16384 chars)
- Unread by admins - boolean
- Unread by user - boolean
- Visible to the user (default: true) - boolean
- Deleted (default: false) - boolean
- Last edited at (aka updated at) - datetime
Messages should be editable for 10 minutes. If created at != updated at, it should say "Last edited at ".
If a Message is deleted, it should just set visible to user to false and deleted to true. I should retain the actual Message and collapse it by default, similar to how I have tables for Searches setup. Alternatively, I could use the "Checkbox/Label Trick" described here, as I likely won't have HTML table shenanigans to worry about.
I should also consider allowing Markdown - I think RedCarpet seems like a good Markdown parser, and allowing Markdown would let users be more expressive. This is a nice tutorial for RedCarpet.
Definition of Done:
-
Flesh out model -
Implement messaging system -
Implement edit timers -
Enable banned users to use only the messaging system to appeal their bans (will need to modify ban checking behavior to not auto-log out banned users for this) -
Validation - Cannot reply to locked thread -
Validation - Cannot edit Message in locked thread -
Validation - Cannot hide Message in locked thread -
Validation - Cannot delete Message in locked thread -
Validation - Cannot create new Message in locked Conversation -
Validation - Check for minimum & maximum Conversation subject lengths -
Validation - Check for minimum & maximum Message body lengths -
Validation - System ID should NOT be able to be Conversation user_id or target_id or creator_id - only created_by -
Validation - System ID should NOT be able to be Message sender_id - only created_by -
Validation - Message body_plaintext not required because that is done before_save
in the model (which isafter_validation
) -
Write tests for Conversation searches - User account panel -
Write tests for Conversation searches - Admin panel -
Validation - User can only see Conversations they are the user_id/target_id for via Account panel, regardless of role -
Test - User who is Admin can see every Conversation, but only from Admin panel -
Test - Sending a Message should increase the unread counter for the target User -
Test - Opening a Message should clear/reduce the unread counter for User via Account panel -
Test - Opening a Message should clear/reduce the unread counter for User via Admin panel -
Test - User should start typing a reply, then the edit timer expires - the Message edit should not be allowed to save -
Test - Admin should start typing a reply, then the edit timer expires - the Message edit should not be allowed to save -
Test - User should start typing a reply, then the Conversation gets locked - the Message should not be allowed to save -
Test - Admin should start typing a reply, then the Conversation gets locked - the Message should not be allowed to save -
Test - User cannot see reply that is published as Hidden -
Test - User account panel cannot see the identity of the sender of a Message that is sent anonymously -
Test - Admin panel can see the identity of the sender of a Message that is sent anonymously -
Test - User account panel cannot see Deleted messages -
Test - Admin panel can see Deleted messages -
Test - Cannot edit Message in locked thread via Admin panel -
Test - Cannot edit Message in locked thread via Account panel -
Test - Cannot hide Message in locked thread via Admin panel -
Test - Cannot delete Message in locked thread via Account panel