From: Joshua Judson Rosen Date: Sun, 12 Jan 2014 20:45:41 +0000 (-0500) Subject: Deliver SMS to @-ref'd users who want it, regardless of subscription. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2ce1b77314052247765fa6cc60af9769f401d078;p=quix0rs-gnu-social.git Deliver SMS to @-ref'd users who want it, regardless of subscription. --- diff --git a/lib/mail.php b/lib/mail.php index d967cfd796..7b6c1d50fe 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -437,14 +437,26 @@ function mail_broadcast_notice_sms($notice) $user = new User(); $UT = common_config('db','type')=='pgsql'?'"user"':'user'; + $replies = $notice->getReplies(); $user->query('SELECT nickname, smsemail, incomingemail ' . - "FROM $UT JOIN subscription " . + "FROM $UT LEFT OUTER JOIN subscription " . "ON $UT.id = subscription.subscriber " . - 'WHERE subscription.subscribed = ' . $notice->profile_id . ' ' . + 'AND subscription.subscribed = ' . $notice->profile_id . ' ' . 'AND subscription.subscribed != subscription.subscriber ' . + // Users (other than the sender) who `want SMS notices': + "WHERE $UT.id != " . $notice->profile_id . ' ' . "AND $UT.smsemail IS NOT null " . "AND $UT.smsnotify = 1 " . - 'AND subscription.sms = 1 '); + // ... where either the user _is_ subscribed to the sender + // (any of the "subscription" fields IS NOT null) + // and wants to get SMS for all of this scribe's notices... + 'AND (subscription.sms = 1 ' . + // ... or where the user was mentioned in + // or replied-to with the notice: + ($replies ? sprintf("OR $UT.id in (%s)", + implode(',', $replies)) + : '') . + ')'); while ($user->fetch()) { common_log(LOG_INFO,