Hi,

 

I've set-up my own instance of status.net, have integrated IM, SMS, Twitter and 
Facebook, and am currently quite happy with the solution.

 

However, I found the notifications of Direct Messages to be slightly lacking 
for my requirements - specifically there was no notification via SMS or Jabber.

 

I have therefore written the following to try to implement this, and thought I 
would share it on here. This was a fairly crude fix, but seems to be working (I 
only started using PHP about two weeks ago, so any suggestions for improvements 
are welcome):

 

newmessage.php
 
function notify($from, $to, $message)
{
mail_notify_message($message, $from, $to);
 
if(strlen($to->smsemail)>1){
mail_send_sms_message($message, $to);
}
 
if(strlen($to->jabber)>1){
$newMessage = jabber_format_notice($from, $message);
jabber_send_message($to->jabber,$newMessage);
}
// XXX: Jabber, SMS notifications... probably queued
}

 

 

/lib/mail.php
 
function mail_send_sms_message($message, $user)
{
return mail_send_sms_message_address($message,
$user->smsemail,
$user->incomingemail);
}
 
// As above but for a message object
 
function mail_send_sms_message_address($message, $smsemail, $incomingemail)
{
$to = $nickname . ' <' . $smsemail . '>';
 
// $other = $notice->getProfile();
 
common_log(LOG_INFO, 'Sending notice ' . $message->id .
' to ' . $smsemail, __FILE__);
 
$headers = array();
 
$headers['From'] = ($incomingemail) ? $incomingemail :
mail_notify_from();
$headers['To'] = $to;
// $headers['Subject'] = sprintf(_('%s status'),
// $other->getBestName());
 
$body = $message->content;
 
return mail_send($smsemail, $headers, $body);
}


                                          
_________________________________________________________________
View your other email accounts from your Hotmail inbox. Add them now.
http://clk.atdmt.com/UKM/go/186394592/direct/01/
_______________________________________________
StatusNet-dev mailing list
[email protected]
http://lists.status.net/mailman/listinfo/statusnet-dev

Reply via email to