Sphene Community Tools

Community

Copyright © 2007-2018 by Herbert Poul

You are not logged in.
Login
Register

Change Language:



AddThis Social Bookmark Button

A Django site.

Powered by Sphene Community Tools
Board » General » Feature Discussions » Private messages: first implementation

Hello Herbert,

I have been working on private messages this weekend and I come up with the attached patch. The job is not finished yet but I'd like to have some feedback.

What I did was to add a PostRecipient object which joins a Post to many User, also carrying the information about which type of recipient is - e.g. To, Cc, Bcc (this information is not used in any way yet). I also added a CategoryType to handle private messages, so they appear as a category in the category list. The category provides many of the informations you designed it for, such as a customized form an an hook for saving the PostRecipient records upon save.

A few things were not possible just using the categories: e.g. only display the messages an user is allowed to see when he displays the category. This is done at model level: Category.posts, Category.get_thread_list now constrain the returned queryset if the message is private: an user can see a message only if he is the author or is one of the recipients.

Notice that it is hard to define if an user is entitled to display a thread: he may have privileges on a few messages but not on all of them, so we can't take decision just looking at the first or the last post in a thread, and a query such "select all the thread in which at least a message is sent to or created by the current user" sounds quite inefficient and maybe not easy to write using the Django orm. For this reason, private messages don't create thread: when a message is answered, the threading is purposely broken (now, talking about that, I start seeing a solution: I may replicate the thread_id on the recipient record, so that it would be easy to spot all the threads where an user posted at least a message - and adding an extra recipient record with the author I would get rid of the "or he is the author part". mmm... I'll see if it can work tomorrow).

When editing a private message, an extra field is shown, where a list of recipients can be entered. It is a customised widget also performing validation; a tool popping up a window and allowing users search would be nice to have in the future.

I'd love to hear some feedback from you or any other user interested in the feature. Thank you.

Daniele Varrazzo
Develer s.r.l. -- http://www.develer.com
Attachments
hey, cool ..
i haven't had time yet to apply the patch and try it out, i just took a quick look (hopefully i'll have time in the next few days - haven't been at home over the weekend)

but one idea.. i would use the categories similar to the comments categorie - ie. every user receives one category where he has full per missions - and can create sub categories.. every user can only see his own categories.
to have a message in an "outbox" of one user and an "inbox" of another i would create multiple 'ThreadInformation' objects (similar to what happens when you move a thread from one category into another - a new ThreadInformation is created which points to the root of the posts)

this would solve the permission problem and will give you hierarchical categories for free (although a UI is still missing to create categories :( ) - and the statistics (number of threads, number of posts, etc. would work)
Hey, we have Signatures !!! Great, isn't it ? ;)
hey, cool ..
i haven't had time yet to apply the patch and try it out, i just took a quick look (hopefully i'll have time in the next few days - haven't been at home over the weekend)

but one idea.. i would use the categories similar to the comments categorie - ie. every user receives one category where he has full per missions - and can create sub categories.. every user can only see his own categories.
Mmm... this seems a very clean and straightforward way of creating private messages :) It's different from what I did, but at a first glance it seems better integrated with the current system architecture.

to have a message in an "outbox" of one user and an "inbox" of another i would create multiple 'ThreadInformation' objects (similar to what happens when you move a thread from one category into another - a new ThreadInformation is created which points to the root of the posts)

this would solve the permission problem and will give you hierarchical categories for free (although a UI is still missing to create categories :( ) - and the statistics (number of threads, number of posts, etc. would work)


It makes perfectly sense, I'll check this alternative way of implementing the thing.

Thank you very much,

-- Daniele
Daniele Varrazzo
Develer s.r.l. -- http://www.develer.com
Hi guys,

Was there any work done on this? I'm going to be working on Sphene quite a bit as we're planning to use it for our site and this is one of the itches that needs scratched. Instead of starting on my own implementation, it would make sense for me to go from here.

Thanks,
Benji.
hi benji,

thanks for your interest in SCT :)
sorry i don't know of any further development on this one.. i haven't looked into it ..
if you look into developing this feature and need a few hints, just let me know maybe i can help.. and it would be cool if you could contribute it back obviously, would be very welcome :) (you should probably use the current SVN version .. i'll soon create a new SCT release because there were quite a few new features and bug fixes..)
Hey, we have Signatures !!! Great, isn't it ? ;)
Thanks Herbert, I'll definitely be contributing back.

Would it make sense to have the messaging feature outside of the forum app?
hmm.. good question.. as i stated earlier in this thread one way would be to re-use a bit from the forum code by using a custom category type (similar how comments are complemented) .. would have the advantage that quite a bit of functionality would already be there (like rendering, attachments, etc.) .. but i think it would be much easier to simply create it separately and use the renderer of the forum.. i don't think there is much code to be reused anyway.. it would be cool if the 'post' form cood be reused, so if anyone customizes it (e.g. using a WYSIWYG editor) - that it is also used for private messages.. but i'm not sure how easy this can be done.. :(

for now i would simply go with the simplest solution - create a separate app outside the forum.. this way we have a useful messaging system we can build upon :)
Hey, we have Signatures !!! Great, isn't it ? ;)
Understood! I think a separate app is probably the best, especially as I don't know my way around the code yet.

Cheers :)
I've implemented private messages at my forum: http://ekrawiectwo.net. There is no need to reinvent the wheel. I've simply used django-messages and integrated it with SCT by adding 'Send message' link to user profiles.
The only drawback is that django-messages doesn't use SCT Groups so if you're using these then you may need to do some changes in django messages code.

If you have any questions feel free to ask.
I've implemented private messages at my forum: http://ekrawiectwo.net. There is no need to reinvent the wheel. I've simply used django-messages and integrated it with SCT by adding 'Send message' link to user profiles.
The only drawback is that django-messages doesn't use SCT Groups so if you're using these then you may need to do some changes in django messages code.

If you have any questions feel free to ask.
Good plan, will try it out. Thanks!

Please login to post a reply.



Powered by Sphene Community Tools