+ $ids = $inbox->unpack();
+ if (in_array(intval($notice_id), $ids)) {
+ // Already in there, we probably re-ran some inbox adds
+ // due to an error. Skip the dupe silently.
+ return true;
+ }
+
+ $result = $inbox->query(sprintf('UPDATE inbox '.
+ 'set notice_ids = concat(cast(0x%08x as binary(4)), '.
+ 'substr(notice_ids, 1, %d)) '.
+ 'WHERE user_id = %d',
+ $notice_id,
+ 4 * (self::MAX_NOTICES - 1),
+ $user_id));
+
+ if ($result) {
+ self::blow('inbox:user_id:%d', $user_id);
+ }
+
+ return $result;
+ }
+
+ static function bulkInsert($notice_id, $user_ids)
+ {
+ foreach ($user_ids as $user_id)
+ {
+ Inbox::insertNotice($user_id, $notice_id);
+ }
+ }