mod_deliver.c.patch   [plain text]


--- /tmp/jabberd-2.1.24.1/sm/mod_deliver.c	2008-04-27 02:57:18.000000000 -0700
+++ ./jabberd2/sm/mod_deliver.c	2008-11-24 14:21:54.000000000 -0800
@@ -38,7 +38,15 @@ static mod_ret_t _deliver_in_sess(mod_in
             if(pkt->from != NULL)
                 jid_free(pkt->from);
 
+            /* Apple: Use sender masquerading if defined */
+            if ((mi->mod->mm->sm->masq_sender_replacement != NULL) &&
+                (aci_check(mi->mod->mm->sm->acls, "masquerade_sender", sess->jid))) {
+                pkt->from = jid_new(mi->mod->mm->sm->pc, mi->mod->mm->sm->masq_sender_replacement, -1);
+                log_debug(ZONE, "Masquerading message \"from\" attribute, swapping \"%s\" with \"%s\"", 
+                    jid_user(sess->jid), mi->mod->mm->sm->masq_sender_replacement);
+            } else {
             pkt->from = jid_dup(sess->jid);
+            }
             nad_set_attr(pkt->nad, 1, -1, "from", jid_full(pkt->from), 0);
         }
 
@@ -83,6 +91,20 @@ static mod_ret_t _deliver_pkt_user(mod_i
         /* unmatched messages will fall through (XMPP-IM r20 s11 rule 2) */
     }
 
+    /* If support for Apple Notification is enabled, messages are forwarded 
+        to all active sessions for the destination JID if that JID contains no resource. */
+    if ((mi->mod->mm->sm->apple_notification_component_addr != NULL) && 
+            (! strncmp(jid_full(pkt->from), mi->mod->mm->sm->apple_notification_component_addr, 
+                strlen(mi->mod->mm->sm->apple_notification_component_addr))) &&
+            (pkt->type & pkt_MESSAGE)) {
+        pkt_t dup_pkt;
+        for(sess = user->sessions; sess != NULL; sess = sess->next) {
+            dup_pkt = pkt_dup(pkt, NULL, NULL);
+            pkt_sess(dup_pkt, sess);
+        }
+        pkt_free(pkt);
+        return mod_HANDLED;
+    }
     return mod_PASS;
 }