Project

General

Profile

Feature #2189

Add personal option to issue mail when something new happens in my social network (directly or daily)

Added by Yannick Warnier over 8 years ago. Updated about 7 years ago.

Status:
Feature implemented
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
21/10/2010
Due date:
% Done:

100%

Estimated time:
3.00 h
Spent time:
Complexity:
Normal
SCRUM pts - complexity:
5

Description

The daily thing might be complicated (to be left for following release?), but appart from that this is just one more option to show in the user profile fields.

Associated revisions

Revision a6078eb7 (diff)
Added by Julio Montoya over 8 years ago

Adding notification feature see #2189 (personal option to issue mail when something new happens)

Revision 0df6764e (diff)
Added by jmontoyaa almost 2 years ago

Fix exercise max score (when setting LP prerequisites) see #2189

History

#1

Updated by Yannick Warnier over 8 years ago

  • Status changed from New to Assigned
  • Assignee set to Julio Montoya
#2

Updated by Julio Montoya over 8 years ago

  • Status changed from Assigned to Needs more info
  • Assignee changed from Julio Montoya to Yannick Warnier
  • SCRUM pts - complexity changed from 3 to 5

what does "when something new happens" exactly means?

#3

Updated by Yannick Warnier over 8 years ago

  • Status changed from Needs more info to Assigned
  • Assignee changed from Yannick Warnier to Julio Montoya

For now, just make it when he receives a message or an invitation from somebody else ("You have received a new message from Michela Barbuda: 'Hello Yannick, I wonder if you are studying right now... blablabla'") with a maximum of 150 characters and the rest comes with a "Read the complete message" with a link to the message.

Also when there is a new message in one of my groups.

The settings to be added (to user_extra_field) are:
  • mail_notify_invitation (con opciones: "At once", "Daily", "No")
  • mail_notify_message (con opciones: "At once", "Daily", "No")
  • mail_notify_group_message (con opciones: "At once", "Daily", "No")

All mails should be registered in a special table (I think one already exists) that is browsed by a cron process (there's another task without destination version by Juan Carlos RaƱa about cron).

If the option is set to "At once", then the email is sent directly (it is registered in the table anyway, with a sent datetime).

The table should be defined as something like this (any improvement suggestion is welcome, including checking that it is stored in UTC):

CREATE TABLE mail_notify (
id bigint PRIMARY KEY not null,
dest_user_id int not null,
dest_mail varchar (255),
mail_title varchar(255),
mail_content text,
send_freq smallint default 1,
created_at datetime not null,
sent_at datetime null);
ALTER TABLE mail_notify ADD index mail_notify_sent_index (sent_at);
ALTER TABLE mail_notify ADD index mail_notify_freq_index (sent_at, send_freq, created_at);

send_freq is 1 for "at once", 4 for "hourly", 8 for "daily" (this leaves a few possibilities to add intermediary frequencies later on, and it makes it compatible with binary format) This table has to work as a standalone table (for efficiency reasons), so that the cron can simply query all notifications with "WHERE sent_at IS NULL", and then query them in order of:
  • all the mails that have to be sent "now" (technically, that never happens because these mails are sent straight away)
  • all the mails that have to be sent "hourly" and that have a "sent_at" of null
  • all the mails that have to be sent daily and that have a "sent_at" of null

A small class to manage that would be nice (so the cron can just load the class, then launch:

$notify = new Notification();
$notify->send('daily');

and nothing more...

I realize now this might take a little over 3 hours, so maybe we shouldn't implement it now, but if you feel motivated, I think it makes sense (and I think the only boring part is actually getting these notification options into the user settings screen).

As an additional information, I feel like we are missing something in the extra_user_fields table, which would be a flag saying that something is a "system" field, so that it cannot be edited in the profiling screen.

This is great! I like this task :-)

#4

Updated by Yannick Warnier over 8 years ago

I think it should be in Chamilo 1.8.8 (it's a great new feature). Julio, have a look at it. We'll try and release 1.8.8 alpha tomorrow after you implement this and a few more bug fixes (trying to sort them out right now and implementing smaller features).

#5

Updated by Julio Montoya over 8 years ago

  • % Done changed from 0 to 50

If the option is set to "At once", then the email is sent directly (it is registered in the table anyway, with a sent datetime).

why we should save that record? Maybe for history purposes?

#6

Updated by Yannick Warnier over 8 years ago

Yes, for history purposes: it is important to know that a message was sent to the user (even if the e-mail failed later on).

#7

Updated by Yannick Warnier over 8 years ago

To make the queries faster, we could set the table to fixed length fields only (as we only send 150 characters as a message anyway).

That would be:

CREATE TABLE mail_notify (
id bigint PRIMARY KEY not null,
dest_user_id int not null,
dest_mail char (255),
mail_title char(255),
mail_content char(255),
send_freq smallint default 1,
created_at datetime not null,
sent_at datetime null);
ALTER TABLE mail_notify ADD index mail_notify_sent_index (sent_at);
ALTER TABLE mail_notify ADD index mail_notify_freq_index (sent_at, send_freq, created_at);

#8

Updated by Julio Montoya over 8 years ago

Yannick Warnier wrote:

To make the queries faster, we could set the table to fixed length fields only (as we only send 150 characters as a message anyway).

That would be:
[...]

Ok, i will call the table "notification" as well as the class is that's fine?

#10

Updated by Julio Montoya over 8 years ago

  • Status changed from Assigned to Needs more info
  • Assignee changed from Julio Montoya to Yannick Warnier
#11

Updated by Yannick Warnier over 8 years ago

  • Assignee changed from Yannick Warnier to Julio Montoya
  • Target version changed from 1.8.8 alpha to 1.8.8 beta

Did you actually try it in order to get the e-mail? I tried it locally but my exim is not well configured yet and I didn't receive any e-mail.

On the other side, I have fixed a typo in the field name here: http://code.google.com/p/chamilo/source/detail?r=48f41cc8ce40dea406f35701892ff218b8ec0338&repo=classic

I need to try it out on the dev server but it doesn't block the alpha anymore

#12

Updated by Julio Montoya over 8 years ago

I test it in http://chamilodev.beeznest.com and is working well

BUT, all emails are sent by the admin (so you don't know who sent you the message) AND there's not a header in the message something like:

Hello XXX 

You have a message from YYYY. 

YYY's message begins: 

bla bla bla

#13

Updated by Julio Montoya over 8 years ago

  • Assignee changed from Julio Montoya to Yannick Warnier
  • % Done changed from 50 to 60
#14

Updated by Julio Montoya over 8 years ago

in order to sent emails that are in the queue you need to call

http://chamilodev.beeznest.com/main/cron/notification.php

#15

Updated by Yannick Warnier over 8 years ago

  • Status changed from Needs more info to Assigned
  • Target version changed from 1.8.8 beta to 1.8.8 stable

OK, then this needs to be documented in the installation manual (documentation/installation_guide.html) before the stable.

#17

Updated by Yannick Warnier about 7 years ago

  • Target version changed from 1.9 Stable to 1.9 Beta
#18

Updated by Yannick Warnier about 7 years ago

  • Status changed from Assigned to Feature implemented
  • % Done changed from 60 to 100

The documentation has been added to the install guide (cron section) and the weekly stuff will be done in #4845

Also available in: Atom PDF