Issue 8: E-Mail Notifications / Thread Subscription
Status:  Fixed
Owner: ----
Closed:  Apr 2008
Reported by mand...@gmail.com, Dec 10, 2007
One feature I was thinking this needs is email/sms notification.  So you
get a message when someone responds to a message/post you wrote or thread
you started.  By default you would get it and have the option to opt-out on
anything as well.

I might give this a whirl and see how far I get, let me know if you would
also like this feature or have other input.

 
Dec 10, 2007
Project Member #1 rwpoul...@gmail.com
Nice idea - feel free to send through a patch.

A few quick thoughts:
* Would it make sense to send e-mails via the BCC field? That way you can handle
multiple users subscribing to a thread with one message
* I'd set it up so subscription happens to a thread, not to a post.
* Make it opt-in, not opt-out. It's polite.
Summary: E-Mail Notifications / Thread Subscription
Status: Accepted
Labels: -Type-Defect Type-Enhancement
Dec 10, 2007
#2 mand...@gmail.com
There could be a "subscribe" or "notify" checkbox near each "Create Post" textarea. 
The the app would look at the user and the thread to determine if you are subscribed
and check the box appropriately, if you uncheck it and post then you are unsubscribed.  

Or I could create a separate section with a user's "settings" on a thread?  Any
examples you already have in mind?
Dec 10, 2007
Project Member #3 rwpoul...@gmail.com
How about a quick model (paraphrased)

class Subscription:
    user = ForeignKey(User)
    thread = ForeignKey(Thread)

When displaying the 'Create Post' textarea, add a 'Subscribe to this thread'
checkbox. If the user is already subscribed, have it pre-checked. If they're not
subscribed, leave it unchecked.

We then need a view to enable a user to see their current subscriptions, with an easy
way to opt out. Perhaps a list of threads with title, last post date, last post user,
'Unsubscribe' link.
Dec 10, 2007
#4 mand...@gmail.com
We could add that checkbox in a column on the thread_list view like 'Subscribed'?  

Re: view to enable a user to see their current subscriptions 
I was planning on doing that in my user's profile (separate app).
Dec 10, 2007
Project Member #5 rwpoul...@gmail.com
I think a dedicated "Subscriptions" view is required so a user can quickly see what
they are subscribed to and unsubscribe immediately.

Also, an email signature with two links would be useful:
1) Unsubscribe from this thread
2) Unsubscribe from all threads

With no confirmation - just plain unsubscribe. 

I don't see this as a user profile-related issue; the profile is for stuff such as
"Date of Birth", "Dogs Name" and "Home Town". Subscriptions are a forum-specific
task, and should be part of a forum application rather than a profile application
(otherwise, you're implying two-way dependency. Yuck!)
Dec 11, 2007
#6 mand...@gmail.com
Gotcha.
Feb 9, 2008
#7 mand...@gmail.com
Ok, here's the first whack at a patch.  Let me know what you think.
subscriptions-patch.txt
8.7 KB   View   Download
Feb 9, 2008
#8 mand...@gmail.com
I forgot to try the BCC header, let me do that now.
Feb 9, 2008
#9 mand...@gmail.com
just found django.core.mail.send_mass_mail()
Feb 9, 2008
Project Member #10 rwpoul...@gmail.com
Fantastic contribution mandric!

If I can make a few minor suggestions:
* Using fail_silently=True means the whole thing won't bomb out on a dodgy e-mail address
* I would also like to see the e-mail message abstracted out to a template to prevent
the text being hard-coded within the view file.
* It appears as if send_mass_mail() itself is deprecated, however it's only 3 lines
long. Perhaps just using EmailMessage() directly with BCC is a simple straightforward
way to go?
* In the message template we should add a) a link to the thread, and b) a link to the
subscription view.

If I find time later today I'll merge in your code and then try to make these changes
I've listed... although there's a good chance you'll get to it first :)

Again, fantastic work and thanks for the contribution!
Status: Started
Feb 9, 2008
#11 mand...@gmail.com
Actually already working with EmailMessage ... saw the BCC option.  But for some
reason it didn't work.  (debugging)

As far as the rest, sounds good ... I'll get to it.
Feb 9, 2008
#13 mand...@gmail.com
* Email still has html encoded chars in it. like quotes.
* Update Subscriptions link in the thread seems out of place.  Would be nice to have
another form on that page to just update that sub.
* Updated HttpResponse calls to use return instead of raise since they're not Errors.
* Added email template and using link to thread in email.
* Using EmailMessage, BCC and fail_silently=True
subscriptions-patch2.txt
10.4 KB   View   Download
Feb 10, 2008
#14 mand...@gmail.com
Were you thinking people could unsubscribe without logging in?  We could add some
random string to each subscription that gets passed in the email sig so people don't
need to bother to login to unsubscribe from a thread.  I like that idea.  That would
also take care of the  where to put a 'update subscriptions' link in the thread
template.  It wouldn't be necessary.  We could just have one link to that update
subscriptions view.
Feb 11, 2008
#15 mand...@gmail.com
minor update
subscriptions-patch3.txt
10.3 KB   View   Download
Feb 15, 2008
#16 mand...@gmail.com
This one isn't part of the sub feature but just thought I'd past it here.  I ran into
a conflice when I also installed django-basic-blog which also uses a Post class.  So
User.post_set.all() had a conflict.  minor.

175a176,184
> @@ -169,7 +169,7 @@
>      method also updates models further up the heirarchy (Thread,Forum)
>      """
>      thread = models.ForeignKey(Thread)
> -    author = models.ForeignKey(User)
> +    author = models.ForeignKey(User, related_name="forum_post_set")
>      body = models.TextField()
>      time = models.DateTimeField(blank=True, null=True)
>  
Apr 14, 2008
Project Member #17 rwpoul...@gmail.com
Committed to latest SVN. Thank you for your fantastic contribution!
Status: Fixed