Forum OpenACS Development: 0.1d of a reminder package

Collapse
Posted by Randy Kunkee on
I have implemented a 0.1d version of a reminder package.  This is a request for comments.

Package name: reminder
Table: reminders

To set a reminder, the user calls reminder__new (a Tcl entry point should probably be provided).

Here is the sql for creating reminder__new:

CREATE OR REPLACE FUNCTION reminder__new(
        integer,                -- reminder.object_id%TYPE
        integer,                -- reminder.reminder_from_id%TYPE
        integer,                -- reminder.reminder_to_id%TYPE
        timestamptz,            -- reminder.reminder_time%TYPE
        varchar                -- reminder.reminder_msg%TYPE
)
RETURNS integer
AS 'declare
        new__object_id          alias for $1;
        new__from_id            alias for $2;
        new__to_id              alias for $3;
        new__when              alias for $4;
        new__msg                alias for $5;
    begin
        insert into reminders
                (object_id, reminder_from_id, reminder_to_id, reminder_time, reminder_msg)
        values
                (new__object_id, new__from_id, new__to_id, new__when, new__msg);
            return 0;
    end;'
LANGUAGE 'plpgsql';

This works with the table defined below.  A reminder-init.tcl schedules reminder::task::email_reminder, which sends an email out at the specified time (using code shameless ripped from the Project Manager package -- thank you).  Currently it sweeps for reminders every 60 seconds, but this will become a package parameter.  As I've written this, I've thought of several other things that could be done better, but for now I'm resisting temptation and wanting to make sure I'm on the right track of providing what people want, and especially something that can be used by the Calendar package (Dirk?).

create table reminders (
        object_id              integer
                                constraint reminders_object_id_fk
                                references acs_objects(object_id)
                                on delete cascade,
        reminder_from_id        integer
                                constraint reminders_to_id_fk
                                references parties(party_id)
                                on delete cascade,
        reminder_to_id          integer
                                constraint reminders_from_id_fk
                                references parties(party_id)
                                on delete cascade,
        reminder_time          timestamptz, -- constraint > now
        reminder_msg            varchar(1000),
        constraint reminders_unique
        unique (object_id, reminder_to_id,reminder_time)
);

comment on table reminders is '
        Table reminders maps the many to many relationship between
        a reminder and a party and the owner of the reminder.
';

comment on column reminders.object_id is '
        The object that owns this reminder.
';

comment on column reminders.reminder_from_id is '
        The party_id from whom the message will appear to be sent.
        Defaults to the owner_id of the object if null.
';

comment on column reminders.reminder_to_id is '
        The party_id to whom to send the reminder.
';

comment on column reminders.reminder_time is '
        The time to send out the reminder.
';

comment on column reminders.reminder_msg is '
        Message to send/display.
';

Collapse
Posted by Jade Rubick on
Will the reminders be recurring? Now it looks like they'll just get one email in the future?
Collapse
Posted by Randy Kunkee on
The initial idea was that if somebody wanted multiple reminders, the requesting package would perform multiple reminder__new calls.  However, I think it would be nice to have that feature.  (This could get complicated - there are multiple reminders about a single event and reminders associated with a recurring event.)  Other ideas I have are:

- handle destination party ids that are groups of people and email everyone in the group.
- handle bounces and notify somebody if the email didn't make it.
- require positive feedback from the receiver and notify the caller if a confirmation isn't received within a certain period of time (perhaps leave it to the caller to handle the second part).
- add a sequence (perhaps reminder_id) that can be stored by the caller and used to update or delete the reminder (probably should do this one soon).
- maybe allow arbitrary actions other than email.  Perhaps this is going too far, i.e. at that point its like creating an 'at' command.
- provide some sort of message template to free packages of having to construct a message (not sure if this would really be useful).

Collapse
Posted by Malte Sussdorff on
I'd add a "method", which defines what delivery procedure to use (this way enabling IM, SMS or RSS in addition to e-mail).

I'd handle reccuring reminders as well internally with the option to nag the reciever til he confirms (so the system automatically sends out the reminder but only informs the caller once the confirmation is recieved).

Don't bother yourself with the message template as all the packages that are going to use the reminder system, will have to decide how to create the reminder internally anyway.

You are missing the differentiation between HTML and plain/text. Maybe there are even more types of content when sending a reminder, but at least these two have to be present so you can send out alternative e-mails. If a package only provides your e.g. with html content, start a converter to store the text content as well.

While we are at it, create a user preference that will allow the user to decide if he wants to recieve reminders in e-mail or text format. Once this works, it should be extended to let users decide, which reminder(types) he wants to recieve via which method in what format.

Last but not least, a small description on how to move from notifications to reminders would be nice as well (unless you see these two as totally seperate pieces of software).

Collapse
Posted by Randy O'Meara on
Malte,

Is there a facility in place (in general) to set user preferences as you describe? Or, could the new ams service possibly be used to extend an object type for this?

Collapse
Posted by Malte Sussdorff on
It would be great if there was one single place to setup user preferences, but to my knowledge there does not exist one. Therefore you have two options.

a) Expand the APM with a user_preferences table: "package_id,parameter_id,party_id,value" and store the values there

b) Do it on your own in the reminder package.

I do not thing that the new ams service could be used for this, but maybe the ASM people have more of an insight there.