if (!$defaultPreviousPost || !$userModel->isUserIgnored($user, $defaultPreviousPost['user_id']))
{
$previousPost = $defaultPreviousPost;
}
else
{
// need to recalculate the last post that they would've seen
$previousPost = false;
foreach ($latestPosts AS $latestPost)
{
if (!$userModel->isUserIgnored($user, $latestPost['user_id']))
{
// this is the most recent post they didn't ignore
$previousPost = $latestPost;
break;
}
}
}
if (!$previousPost || $previousPost['post_date'] < $autoReadDate)
{
// always alert
}
else if ($previousPost['post_date'] > $user['thread_read_date'])
{
// user hasn't read the thread since the last alert, don't send another one
continue;
}