acs_mail_lite::unique_id_create (private)
acs_mail_lite::unique_id_create [ -unique_id unique_id ] \ [ -package_id package_id ] [ -party_id party_id ] \ [ -object_id object_id ] [ -other other ]
Defined in packages/acs-mail-lite/tcl/email-inbound-procs.tcl
Returns a unique_id for an outbound email header message-id. Signs unique_id when package_id, party_id, object_id, and/or other info are supplied. party_id is not supplied if its value is empty string or 0. package_id not supplied when it is the default acs-mail-lite package_id. If unique_id is empty string, creates a unique_id then processes it.
- Switches:
- -unique_id (optional)
- -package_id (optional)
- -party_id (optional)
- -object_id (optional)
- -other (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_mail_lite_inbound_procs_check
Source code: # remove quotes, adjust last_at_idx if { [string match "<*>" $unique_id] } { set unique_id [string range $unique_id 1 end-1] } set envelope_prefix [acs_mail_lite::bounce_prefix ] if { ![string match "${envelope_prefix}*" $unique_id ] } { set unique_id2 $envelope_prefix append unique_id2 $unique_id set unique_id $unique_id2 } set last_at_idx [string last "@" $unique_id] if { $last_at_idx < 0 } { set unique_id $envelope_prefix append unique_id [string range [mime::uniqueID] 1 end-1] set last_at_idx [string last "@" $unique_id] } set bounce_domain [acs_mail_lite::address_domain] if { [string range $unique_id $last_at_idx+1 end-1] ne $bounce_domain } { # Use bounce's address_domain instead # because message-id may also be used as originator set unique_id [string range $unique_id 0 $last_at_idx] append unique_id $bounce_domain } set aml_package_id [apm_package_id_from_key "acs-mail-lite"] if { ( $package_id ne "" && $package_id ne $aml_package_id ) || ( $party_id ne "" && $party_id ne "0" ) || $object_id ne "" || $other ne "" } { # Sign this message-id, and map message-id to values set uid [string range $unique_id 0 $last_at_idx-1] set domain [string range $unique_id $last_at_idx+1 end] set uid_list [split $uid "."] if { [llength $uid_list] == 3 } { # Assume this is a unique id from mime::uniqueID # Replace clock seconds of uniqueID with a random integer # since cs is used to build signature, which defeats purpose. set uid_partial [lindex $uid_list 0] # Suppose: # max_chars = at least the same as length of clock seconds # It will be 10 for a while.. # so use eleven 9's # Some cycles are saved by using a constant append uid_partial "." [util::random_range 99999999999] append uid_partial "." [lindex $uid_list 2] set uid $uid_partial } # Just sign the uid part set max_age [parameter::get -parameter "IncomingMaxAge" -package_id $aml_package_id ] ns_log Dev "acs_mail_lite::unique_id_create max_age '${max_age}'" if { $max_age eq "" || $max_age eq "0" } { # A max_age of 0 or '' expires instantly. # User expects signature to not expire. set signed_unique_id_list [ad_sign $uid] set delim "-" } else { set signed_unique_id_list [ad_sign -max_age $max_age $uid] set delim "+" } set signed_unique_id [join $signed_unique_id_list $delim] # Since signature is part of uniqueness of unique_id, # use uid + signature for msg_id set msg_id $uid append msg_id "-" $signed_unique_id set datetime_cs [clock seconds] db_dml acs_mail_lite_send_msg_id_map_w1 { insert into acs_mail_lite_send_msg_id_map (msg_id,package_id,party_id,object_id,other,datetime_cs) values (:msg_id,:package_id,:party_id,:object_id,:other,:datetime_cs) } set unique_id "<" append unique_id $msg_id "@" $domain ">" } return $unique_idXQL Not present: PostgreSQL, Oracle Generic XQL file: packages/acs-mail-lite/tcl/email-inbound-procs.xql