Export to GitHub

django-forum - issue #8

E-Mail Notifications / Thread Subscription


Posted on Dec 11, 2007 by Massive Rabbit

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.

Comment #1

Posted on Dec 11, 2007 by Happy Rabbit

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.

Comment #2

Posted on Dec 11, 2007 by Massive Rabbit

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?

Comment #3

Posted on Dec 11, 2007 by Happy Rabbit

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.

Comment #4

Posted on Dec 11, 2007 by Massive Rabbit

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).

Comment #5

Posted on Dec 11, 2007 by Happy Rabbit

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!)

Comment #6

Posted on Dec 11, 2007 by Massive Rabbit

Gotcha.

Comment #7

Posted on Feb 9, 2008 by Massive Rabbit

Ok, here's the first whack at a patch. Let me know what you think.

Attachments

Comment #8

Posted on Feb 9, 2008 by Massive Rabbit

I forgot to try the BCC header, let me do that now.

Comment #9

Posted on Feb 9, 2008 by Massive Rabbit

just found django.core.mail.send_mass_mail()

Comment #10

Posted on Feb 10, 2008 by Happy Rabbit

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!

Comment #11

Posted on Feb 10, 2008 by Massive Rabbit

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.

Comment #12

Posted on Feb 10, 2008 by Massive Rabbit

This helps ;) http://www.rossp.org/blog/2006/jul/11/sending-e-mails-templates/

Comment #13

Posted on Feb 10, 2008 by Massive Rabbit
  • 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
Attachments

Comment #14

Posted on Feb 10, 2008 by Massive Rabbit

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.

Comment #15

Posted on Feb 11, 2008 by Massive Rabbit

minor update

Attachments

Comment #16

Posted on Feb 15, 2008 by Massive Rabbit

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)

Comment #17

Posted on Apr 15, 2008 by Happy Rabbit

Committed to latest SVN. Thank you for your fantastic contribution!

Status: Fixed

Labels:
Type-Enhancement Priority-Medium