delivery-method-procs.tcl

Notification Delivery Methods Functions to support notification delivery methods. A delivery method is a means by which a notification is sent to a user. "Email" is a common one, but others, like "sms", may exist. The delivery method integration is done via acs-service-contract: any new delivery method must implement this service contract.

Location:
packages/notifications/tcl/delivery-method-procs.tcl
Created:
2002-05-24
Author:
Ben Adida
CVS Identification:
$Id: delivery-method-procs.tcl,v 1.16.2.3 2022/07/12 14:02:11 antoniop Exp $

Procedures in this file

Detailed information

notification::delivery::delete (public)

 notification::delivery::delete -delivery_method_id delivery_method_id

Unregister a delivery method with the notification service.

Switches:
-delivery_method_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 notification::apm::unregister_email_delivery_method notification::apm::unregister_email_delivery_method (private) notification::delivery::delete notification::delivery::delete notification::apm::unregister_email_delivery_method->notification::delivery::delete db_exec_plsql db_exec_plsql (public) notification::delivery::delete->db_exec_plsql

Testcases:
No testcase defined.

notification::delivery::get_id (public)

 notification::delivery::get_id -short_name short_name

Return the delivery_method_id from the short_name.

Switches:
-short_name (required)

Partial Call Graph (max 5 caller/called nodes):
%3 faq::apm_callback::enable_intervals_and_methods faq::apm_callback::enable_intervals_and_methods (private) notification::delivery::get_id notification::delivery::get_id faq::apm_callback::enable_intervals_and_methods->notification::delivery::get_id news::install::enable_intervals_and_methods news::install::enable_intervals_and_methods (private) news::install::enable_intervals_and_methods->notification::delivery::get_id notification::apm::unregister_email_delivery_method notification::apm::unregister_email_delivery_method (private) notification::apm::unregister_email_delivery_method->notification::delivery::get_id notification::apm::update_email_delivery_method_impl notification::apm::update_email_delivery_method_impl (private) notification::apm::update_email_delivery_method_impl->notification::delivery::get_id notification::new notification::new (public) notification::new->notification::delivery::get_id db_string db_string (public) notification::delivery::get_id->db_string

Testcases:
No testcase defined.

notification::delivery::get_impl_key (private)

 notification::delivery::get_impl_key \
    -delivery_method_id delivery_method_id

Return the service contract implementation key for notification delivery methods

Switches:
-delivery_method_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 notification::delivery::scan_replies notification::delivery::scan_replies (public) notification::delivery::get_impl_key notification::delivery::get_impl_key notification::delivery::scan_replies->notification::delivery::get_impl_key notification::delivery::send notification::delivery::send (public) notification::delivery::send->notification::delivery::get_impl_key db_string db_string (public) notification::delivery::get_impl_key->db_string

Testcases:
No testcase defined.

notification::delivery::new (public)

 notification::delivery::new [ -delivery_method_id delivery_method_id ] \
    -sc_impl_id sc_impl_id -short_name short_name \
    -pretty_name pretty_name

Register a new delivery method with the notification service.

Switches:
-delivery_method_id (optional)
-sc_impl_id (required)
-short_name (required)
-pretty_name (required)

Partial Call Graph (max 5 caller/called nodes):
%3 notification::apm::register_email_delivery_method notification::apm::register_email_delivery_method (private) notification::delivery::new notification::delivery::new notification::apm::register_email_delivery_method->notification::delivery::new package_instantiate_object package_instantiate_object (public) notification::delivery::new->package_instantiate_object

Testcases:
No testcase defined.

notification::delivery::scan_replies (public)

 notification::delivery::scan_replies \
    -delivery_method_id delivery_method_id

scan for replies. Every delivery method allows for replies. This is the wrapper proc that indicates to the delivery method service contract implementation that it's time to scan for replies.

Switches:
-delivery_method_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 notification::reply::sweep::scan_all_replies notification::reply::sweep::scan_all_replies (private) notification::delivery::scan_replies notification::delivery::scan_replies notification::reply::sweep::scan_all_replies->notification::delivery::scan_replies acs_sc::invoke acs_sc::invoke (public) notification::delivery::scan_replies->acs_sc::invoke notification::delivery::get_impl_key notification::delivery::get_impl_key (private) notification::delivery::scan_replies->notification::delivery::get_impl_key

Testcases:
No testcase defined.

notification::delivery::send (public)

 notification::delivery::send -delivery_method_id delivery_method_id \
    [ -reply_object_id reply_object_id ] \
    -notification_type_id notification_type_id \
    [ -from_user_id from_user_id ] -to_user_id to_user_id \
    -subject subject -content_text content_text \
    -content_html content_html [ -file_ids file_ids ]

do the delivery of certain content to a particular user using a particular delivery method. This is just a wrapper proc that sets up the call to the service contract implementation for a given delivery method.

Switches:
-delivery_method_id (required)
-reply_object_id (optional)
-notification_type_id (required)
-from_user_id (optional)
-to_user_id (required)
-subject (required)
-content_text (required)
-content_html (required)
-file_ids (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 notification::sweep::sweep_notifications notification::sweep::sweep_notifications (private) notification::delivery::send notification::delivery::send notification::sweep::sweep_notifications->notification::delivery::send acs_sc::invoke acs_sc::invoke (public) notification::delivery::send->acs_sc::invoke notification::delivery::get_impl_key notification::delivery::get_impl_key (private) notification::delivery::send->notification::delivery::get_impl_key notification::security::can_notify_user notification::security::can_notify_user (public) notification::delivery::send->notification::security::can_notify_user

Testcases:
No testcase defined.

notification::delivery::update_sc_impl_id (private)

 notification::delivery::update_sc_impl_id \
    [ -delivery_method_id delivery_method_id ] -sc_impl_id sc_impl_id

Register a new service contract implementation with an existing delivery method.

Switches:
-delivery_method_id (optional)
-sc_impl_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 notification::apm::update_email_delivery_method_impl notification::apm::update_email_delivery_method_impl (private) notification::delivery::update_sc_impl_id notification::delivery::update_sc_impl_id notification::apm::update_email_delivery_method_impl->notification::delivery::update_sc_impl_id db_dml db_dml (public) notification::delivery::update_sc_impl_id->db_dml

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

ad_library {

    Notification Delivery Methods

    Functions to support notification delivery methods. A delivery method is a means by which
    a notification is sent to a user. "Email" is a common one, but others, like "sms", may exist.

    The delivery method integration is done via acs-service-contract: any new delivery method must implement
    this service contract.

    @creation-date 2002-05-24
    @author Ben Adida <ben@openforce.biz>
    @cvs-id $Id: delivery-method-procs.tcl,v 1.16.2.3 2022/07/12 14:02:11 antoniop Exp $

}

namespace eval notification::delivery {}


d_proc -private notification::delivery::get_impl_key {
    {-delivery_method_id:required}
} {
    Return the service contract implementation key for notification delivery methods
} {
    return [db_string select_impl_key {}]
}

d_proc -public notification::delivery::send {
    {-delivery_method_id:required}
    {-reply_object_id ""}
    {-notification_type_id:required}
    {-from_user_id ""}
    {-to_user_id:required}
    {-subject:required}
    {-content_text:required}
    {-content_html:required}
    {-file_ids ""}
} {
    do the delivery of certain content to a particular user using a particular delivery method.
    This is just a wrapper proc that sets up the call to the service contract implementation for
    a given delivery method.
} {
    #need to check if its ok to notify this user in this way.  For now just checks if they are an approved user.
    if { ![notification::security::can_notify_user -user_id $to_user_id -delivery_method_id $delivery_method_id] } {
        ns_log debug "notification::delivery::send: Blocked notification to $to_user_id subject:$subject"
        return "Blocked"
    }

    # Get the implementation key
    set impl_key [get_impl_key -delivery_method_id $delivery_method_id]

    # Prepare the arguments
    set args [list $from_user_id $to_user_id $reply_object_id $notification_type_id $subject $content_text $content_html $file_ids]

    # Make the generic call
    return [acs_sc::invoke -contract NotificationDeliveryMethod -operation Send -call_args $args -impl $impl_key]
}

d_proc -public notification::delivery::scan_replies {
    {-delivery_method_id:required}
} {
    scan for replies.

    Every delivery method allows for replies. This is the wrapper proc that
    indicates to the delivery method service contract implementation that it's time to
    scan for replies.
} {
    # Get the implementation key
    set impl_key [get_impl_key -delivery_method_id $delivery_method_id]

    # Prepare the arguments
    set args [list]

    # ns_log Notice "NOTIF-DELIV-METHOD: about to call acs_sc on $impl_key"

    # Make the generic call
    return [acs_sc::invoke -contract NotificationDeliveryMethod -operation ScanReplies -call_args $args -impl $impl_key]
}

d_proc -public notification::delivery::new {
    {-delivery_method_id ""}
    {-sc_impl_id:required}
    {-short_name:required}
    {-pretty_name:required}
} {
    Register a new delivery method with the notification service.
} {
    set extra_vars [ns_set create s \
                        delivery_method_id $delivery_method_id \
                        sc_impl_id $sc_impl_id \
                        short_name $short_name \
                        pretty_name $pretty_name \
                       ]

    return [package_instantiate_object \
                -extra_vars $extra_vars \
                "notification_delivery_method"]
}

d_proc -public notification::delivery::delete {
    {-delivery_method_id:required}
} {
    Unregister a delivery method with the notification service.
} {
    db_exec_plsql delete {}
}

d_proc -private notification::delivery::update_sc_impl_id {
    {-delivery_method_id ""}
    {-sc_impl_id:required}
} {
    Register a new service contract implementation with an existing delivery method.
} {
    db_dml update {}
}

d_proc -public notification::delivery::get_id {
    {-short_name:required}
} {
    Return the delivery_method_id from the short_name.
} {
    return [db_string select_delivery_method_id {}]
}


# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: