From 392137b4033793620fcd36d641625b5591b046bf Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 24 Sep 2008 11:08:34 -0400 Subject: change foreign links flags code to use bitmasks Zach was doing a lot of integer comparisons on the Foreign_link sync fields. I switched them to use named bitmasks instead. I also switched the semantics of bit 3 to be the opposite of what Zach had -- I find lots of double-negatives in a checkbox to be hard to read. darcs-hash:20080924150834-5ed1f-54cd945f61e43bc06768037c60c1e6180a8feead.gz --- lib/common.php | 7 +++++++ lib/util.php | 17 ++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/common.php b/lib/common.php index 60c820ee6..015ecd639 100644 --- a/lib/common.php +++ b/lib/common.php @@ -28,6 +28,13 @@ define('MAX_AVATAR_SIZE', 256 * 1024); define('NOTICES_PER_PAGE', 20); +define('FOREIGN_NOTICE_SEND', 1); +define('FOREIGN_NOTICE_RECV', 2); +define('FOREIGN_NOTICE_SEND_REPLY', 4); + +define('FOREIGN_FRIEND_SEND', 1); +define('FOREIGN_FRIEND_RECV', 2); + define_syslog_variables(); # append our extlib dir as the last-resort place to find libs diff --git a/lib/util.php b/lib/util.php index a45f4a214..901e3ac46 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1110,17 +1110,12 @@ function common_broadcast_notice($notice, $remote=false) { // Check to see if notice should go to Twitter $flink = Foreign_link::getForeignLink($notice->profile_id, 1); // 1 == Twitter - if ($flink->noticesync >= 1) { - $ok_to_send = true; - - // Check to see whether user wants to filter @-replies - if ($flink->noticesync == 3) { - if (preg_match('/(?:^|\s)@([A-Za-z0-9_\-\.]{1,64})/', $notice->content)) { - $ok_to_send = false; - } - } - - if ($ok_to_send) { + if ($flink->noticesync & FOREIGN_NOTICE_SEND) { + + // If it's not a reply, or if the user WANTS to send replies... + + if (!$notice->reply_to || ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY)) { + $result = common_twitter_broadcast($notice, $flink); if (!$result) { -- cgit v1.2.3-54-g00ecf