Forum OpenACS Development: Incoming E-Mail Idea

Collapse
Posted by Malte Sussdorff on
Incoming E-Mail currently works by having multiple callback implementations which first check if the "to_addr" of the e-mail is something they want to work on (e.g. bounce- or notifications-), otherwise they leave the e-mail as such.

But we could save ourselve some time in processing if we just support a syntax like "mailto:object_id@yoursite.com";. Then incoming e-mail could look up the object_type, and then call the callback implementation specific to this object_type. If object_type = 'content_item', use content_type instead.

====

ad_proc -public -callback acs_mail_lite::incoming_object_email {
-array:required
-object_id:required
} {
}

callback acs_mail_lite::incoming_object_email -impl $object_type -array email -object_id $object_id

====

ad_proc -public -callback acs_mail_lite::incoming_object_email -impl user {
-array:required
-object_id:required
} {
Implementation of mail through support for incoming emails
} {
# get a reference to the email array
upvar $array email

# make the bodies an array
template::util::list_of_lists_to_array $email(bodies) email_body

if {[exists_and_not_null email_body(text/html)]} {
set body $email_body(text/html)
} else {
set body $email_body(text/plain)
}

set reply_to_addr "[party::get_by_email $email(from)]@[ad_url]"

acs_mail_lite::complex_send \
-from_addr $from_addr \
-reply_to $reply_to_addr \
-to_addr $to_addr \
-subject $email(subject) \
-body $body \
-single_email \
-send_immediately
}

========

Obviously you could have implementations for:

forums_forum: Start a new topic
forums_message: Reply to an existing topic
group: Send an e-mail to all group members
pm_project: add a comment to a project
pm_task: add a comment to a task

Collapse
2: Re: Incoming E-Mail Idea (response to 1)
Posted by Malte Sussdorff on
A not so straight forward approach would be to allow multiple implementations like this:

=======

ad_proc -public -callback acs_mail_lite::incoming_object_email _user {
-array:required
-object_id:required
} {
}

callback acs_mail_lite::incoming_object_email_$object_type -array email -object_id $object_id

===========

Feedback is welcome which method to choose. I don't think it requires a TIP, but please correct me if I'm wrong.

Also state if you think the idea is rubbish.