Pilsburgh / django-forum

Automatically exported from code.google.com/p/django-forum
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

E-Mail Notifications / Thread Subscription #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by mand...@gmail.com on 11 Dec 2007 at 12:24

GoogleCodeExporter commented 9 years ago
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.

Original comment by rwpoul...@gmail.com on 11 Dec 2007 at 12:29

GoogleCodeExporter commented 9 years ago
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?

Original comment by mand...@gmail.com on 11 Dec 2007 at 3:33

GoogleCodeExporter commented 9 years ago
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.

Original comment by rwpoul...@gmail.com on 11 Dec 2007 at 3:56

GoogleCodeExporter commented 9 years ago
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).

Original comment by mand...@gmail.com on 11 Dec 2007 at 4:05

GoogleCodeExporter commented 9 years ago
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!)

Original comment by rwpoul...@gmail.com on 11 Dec 2007 at 4:09

GoogleCodeExporter commented 9 years ago
Gotcha.

Original comment by mand...@gmail.com on 11 Dec 2007 at 10:53

GoogleCodeExporter commented 9 years ago
Ok, here's the first whack at a patch.  Let me know what you think.

Original comment by mand...@gmail.com on 9 Feb 2008 at 3:26

Attachments:

GoogleCodeExporter commented 9 years ago
I forgot to try the BCC header, let me do that now.

Original comment by mand...@gmail.com on 9 Feb 2008 at 3:46

GoogleCodeExporter commented 9 years ago
just found django.core.mail.send_mass_mail()

Original comment by mand...@gmail.com on 9 Feb 2008 at 3:50

GoogleCodeExporter commented 9 years ago
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!

Original comment by rwpoul...@gmail.com on 10 Feb 2008 at 12:54

GoogleCodeExporter commented 9 years ago
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.

Original comment by mand...@gmail.com on 10 Feb 2008 at 2:57

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

Original comment by mand...@gmail.com on 10 Feb 2008 at 4:13

GoogleCodeExporter commented 9 years ago
* 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

Original comment by mand...@gmail.com on 10 Feb 2008 at 5:24

Attachments:

GoogleCodeExporter commented 9 years ago
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.

Original comment by mand...@gmail.com on 10 Feb 2008 at 4:05

GoogleCodeExporter commented 9 years ago
minor update

Original comment by mand...@gmail.com on 11 Feb 2008 at 6:00

Attachments:

GoogleCodeExporter commented 9 years ago
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)
>  

Original comment by mand...@gmail.com on 15 Feb 2008 at 1:32

GoogleCodeExporter commented 9 years ago
Committed to latest SVN. Thank you for your fantastic contribution!

Original comment by rwpoul...@gmail.com on 15 Apr 2008 at 1:04