Lee
Well-known member
I have setup the following content type for the alert handler class:

I then have this protected php function:
and then this code actually send the alert:
I also have a template with this name: alert_user_alert_tls_new_thought, which I think is named correctly...? I also had this working at one point but don't recall what I changed that broke it.
The alert is being added to the database and the bubble is showing the alert as sent correctly, but then showing no new alerts when accessed.
Does anybody please have any ideas what is wrong?

I then have this protected php function:
PHP:
protected function sendAlert($alertType, $to, $fromUser)
{
/* Load the Alert Repo */
$alertRepo = $this->repository('XF:UserAlert');
$alertRepo->alert(
$to,
$fromUser->user_id,
$fromUser->username,
'tls_thoughts',
'',
$alertType,
[],
['autoRead' => true]
);
}
and then this code actually send the alert:
PHP:
$thoughtsWatching = $this->finder('TLS\Thoughts:ThoughtWatch');
$thoughtsWatchingResult = $thoughtsWatching->fetch();
$fromUser = \XF::visitor();
foreach($thoughtsWatchingResult as $thoughtsWatchingData)
{
$user = \XF::em()->find('XF:User', $thoughtsWatchingData->user_id);
/* Send an alert on Submission */
if($thoughtsWatchingData->user_id != \XF::visitor()->user_id)
{
$this->sendAlert('new_thought', $user, $fromUser);
}
}
I also have a template with this name: alert_user_alert_tls_new_thought, which I think is named correctly...? I also had this working at one point but don't recall what I changed that broke it.
The alert is being added to the database and the bubble is showing the alert as sent correctly, but then showing no new alerts when accessed.
Does anybody please have any ideas what is wrong?