Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: gautamg on June 02, 2015, 03:59:20 AM

Title: Alerts, Notifications are not working
Post by: gautamg on June 02, 2015, 03:59:20 AM
Alerts, Notification System is not working properly. Users are not receiving email and alerts when when some one send them messages, mentions their name or any thing happened to their topics. Even Administrator is not receiving email/alerts of new member sign up and all.
I have check all the notification setting in admin area and all good.
is it something only happening with my site.?

Please provide a solution if anyone knows about the issue.

Thanks,
Amar
Title: Re: Alerts, Notifications are not working
Post by: Dragooon on June 02, 2015, 04:31:48 AM
Are they enabled in profile? Do they receive alerts within the forum?
Title: Re: Alerts, Notifications are not working
Post by: gautamg on June 02, 2015, 04:43:45 AM
Yes, they are enabled in the profile.Attached is the screenshot of the notification settings.
Title: Re: Alerts, Notifications are not working
Post by: Illori on June 02, 2015, 05:20:51 AM
are you sure that email is working on this server? i get emails for alerts etc for 2.1 on my test install just fine.
Title: Re: Alerts, Notifications are not working
Post by: Dragooon on June 02, 2015, 05:24:31 AM
Do you receive alerts within the notification centre on the forum?
Title: Re: Alerts, Notifications are not working
Post by: gautamg on June 02, 2015, 05:31:20 AM
Quote from: Illori on June 02, 2015, 05:20:51 AM
are you sure that email is working on this server? i get emails for alerts etc for 2.1 on my test install just fine.

Yes Email is working fine on my server.
Title: Re: Alerts, Notifications are not working
Post by: gautamg on June 02, 2015, 05:37:57 AM
Alerts works some time and do not work other time. I received last alert on May 13, I'v had this happen many times.
Title: Re: Alerts, Notifications are not working
Post by: gautamg on June 02, 2015, 05:40:23 AM
I am using SMF 2.1 Beta 1 that was released in November in 2014.
Title: Re: Alerts, Notifications are not working
Post by: Illori on June 02, 2015, 05:44:15 AM
Quote from: gautamg on June 02, 2015, 05:40:23 AM
I am using SMF 2.1 Beta 1 that was released in November in 2014.

you should upgrade to the version on github for many bug fixes.
Title: Re: Alerts, Notifications are not working
Post by: gautamg on June 02, 2015, 05:51:01 AM
Quote from: Illori on June 02, 2015, 05:44:15 AM
Quote from: gautamg on June 02, 2015, 05:40:23 AM
I am using SMF 2.1 Beta 1 that was released in November in 2014.

you should upgrade to the version on github for many bug fixes.

I have installed many of the mods and have done a lot of customization.
Is there any way to update so I can keep the customization safe.
Title: Re: Alerts, Notifications are not working
Post by: Dragooon on June 02, 2015, 05:54:42 AM
You shouldn't have done that, if you kept a track of your changes you can upgrade and re-apply them.
Title: Re: Alerts, Notifications are not working
Post by: gautamg on June 02, 2015, 06:14:35 AM
My site is live with thousands of users and topis. To update and reapply the customization is not easy :( .
Can you suggesting me something to look in to in order to fix the notification issue.

Title: Re: Alerts, Notifications are not working
Post by: Antes on June 02, 2015, 06:15:49 AM
Quote from: gautamg on June 02, 2015, 06:14:35 AM
My site is live with thousands of users and topis. To update and reapply the customization is not easy :( .
Can you suggesting me something to look in to in order to fix the notification issue.



Debug the code, find the issue creating the conflict or problem and fix it.
Title: Re: Alerts, Notifications are not working
Post by: Kindred on June 02, 2015, 06:38:22 AM
Why would you have used the beta version on a live site with thousands of users?

We have big warnings all over the place that tell you not to use the beta1 version on a live site?

The version thatbyou are running has hundreds of known issues...  And we do not support the beta with patches.   When beta 2 comes out, the only way to upgrade will be to replace all files.

So, basically, you have put yourself in a no win situation...
Title: Re: Alerts, Notifications are not working
Post by: gautamg on June 02, 2015, 07:30:06 AM
Quote from: Antes on June 02, 2015, 06:15:49 AM
Quote from: gautamg on June 02, 2015, 06:14:35 AM
My site is live with thousands of users and topis. To update and reapply the customization is not easy :( .
Can you suggesting me something to look in to in order to fix the notification issue.



Debug the code, find the issue creating the conflict or problem and fix it.

Yes, this is the only things I can do now.
Title: Re: Alerts, Notifications are not working
Post by: Kindred on June 02, 2015, 07:41:25 AM
the thing is....   there are literally hundreds of fixes to the code from the version that you are currently using -- so, even fixing this ONE issue will still leave you with BUCKETS of things which are broken

Your best bet would actually be to forget about your mods and do the real upgrade.

and next time, document your personal customizations ...   oh yeah... and don't use a beta version on a live site.
Title: Re: Alerts, Notifications are not working
Post by: 1Chope on June 02, 2015, 03:31:49 PM
What op said is true and it is still on 2.1 beta 2. I installed the latest version today in a directory just to test it. The only notification that is working is likes notification, other notification which includes QUOTE, MENTIONED, etc are not working. Feel free to check it out in the live server  http://celebrityng.com/smf
Title: Re: Alerts, Notifications are not working
Post by: lc62003 on June 02, 2015, 03:33:44 PM
Notifications and alerts are not working on a live server even with the latest from Git.   :P
Title: Re: Alerts, Notifications are not working
Post by: Dragooon on June 02, 2015, 03:43:46 PM
Do you have post approval enabled? And were the posts requiring approval?
Title: Re: Alerts, Notifications are not working
Post by: lc62003 on June 02, 2015, 04:21:22 PM
Not on my site.
Title: Re: Alerts, Notifications are not working
Post by: Dragooon on June 02, 2015, 04:48:01 PM
I tried on my localhost and it works for me, are the profile settings correct for the person receiving the alerts?
Title: Re: Alerts, Notifications are not working
Post by: Kindred on June 02, 2015, 05:59:30 PM
Seems to work for me as well
Title: Re: Alerts, Notifications are not working
Post by: live627 on June 02, 2015, 09:37:22 PM
Quote from: gautamg on June 02, 2015, 05:40:23 AM
I am using SMF 2.1 Beta 1 that was released in November in 2014.
Ah,  there's your problem. That release has a bug where alert emails never get sent.
Title: Re: Alerts, Notifications are not working
Post by: Illori on June 03, 2015, 07:18:01 AM
Quote from: live627 on June 02, 2015, 09:37:22 PM
Quote from: gautamg on June 02, 2015, 05:40:23 AM
I am using SMF 2.1 Beta 1 that was released in November in 2014.
Ah,  there's your problem. That release has a bug where alert emails never get sent.

that was a bug with the email for resetting your password, not for notifications/alerts.
Title: Re: Alerts, Notifications are not working
Post by: lc62003 on June 03, 2015, 09:42:46 AM
Quote from: Dragooon on June 02, 2015, 04:48:01 PM
I tried on my localhost

To be quite honest, I believe this is why many of the bugs persist.  Localhost simply is not the same as a live server.  I already outed (here) an upgrade bug that didn't occur on localhost.   ;)
Title: Re: Alerts, Notifications are not working
Post by: Kindred on June 03, 2015, 10:30:45 AM
Well, I have it installed and running on an actual site/server...  and it works correctly for me
Title: Re: Alerts, Notifications are not working
Post by: lc62003 on June 03, 2015, 10:44:49 AM
Quote from: Kindred on June 03, 2015, 10:30:45 AM
Well, I have it installed and running on an actual site/server...  and it works correctly for me

I didn't say that was the case for this particular bug.  Just saying it's more relevant for troubleshooting or even bug discovery in general.   ;)
Title: Re: Alerts, Notifications are not working
Post by: lc62003 on June 03, 2015, 04:31:22 PM
Alerts work for me using a legacy version of  Likes-Notify.php in the ./Sources/tasks folder.



<?php

/**
 * This task handles notifying users when something is liked.
 *
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines http://www.simplemachines.org
 * @copyright 2014 Simple Machines and individual contributors
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.1 Alpha 1
 */

class Likes_Notify_Background extends SMF_BackgroundTask
{
public function execute()
{
global $smcFunc$sourcedir;

$author false;
// We need to figure out who the owner of this is.
if ($this->_details['content_type'] == 'msg')
{
$request $smcFunc['db_query']('''
SELECT mem.id_member, mem.id_group, mem.id_post_group, mem.additional_groups, b.member_groups
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}members AS mem ON (m.id_member = mem.id_member)
INNER JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
WHERE id_msg = {int:msg}'
,
array(
'msg' => $this->_details['content_id'],
)
);
if ($row $smcFunc['db_fetch_assoc']($request))
{
// Before we assign the author, let's just check that the author can see the board this is in...
// as it'd suck to notify someone their post was liked when in a board they can't see.
$groups explode(','$row['additional_groups']);
$groups[] = $row['id_group'];
$groups[] = $row['id_post_group'];
$allowed explode(','$row['member_groups']);

// If the user is in group 1 anywhere, they can see everything anyway.
if (in_array(1$groups) || count(array_intersect($allowed$groups)) != 0)
$author $row['id_member'];
}
$smcFunc['db_free_result']($request);
}
else
{
// This isn't something we know natively how to support. Call the hooks, if they're dealing with it, return false, otherwise return the user id.
$hook_results call_integration_hook('integrate_find_like_author', array($this->_details['content_type'], $this->_details['content_id']));
foreach ($hook_results as $result)
if (!empty($result))
{
$author $result;
break;
}
}

// If we didn't have a member... leave.
if (empty($author))
return true;

// If the person who sent the notification is the person whose content it is, do nothing.
if ($author == $this->_details['sender_id'])
return true;

require_once($sourcedir '/Subs-Notify.php');
$prefs getNotifyPrefs($author$this->_details['content_type'] . '_like'true);

// The likes setup doesn't support email notifications because that would be too many emails.
// As a result, the value should really just be non empty.

// Check the value. If no value or it's empty, they didn't want alerts, oh well.
if (empty($prefs[$author][$this->_details['content_type'] . '_like']))
return true;

// Issue, update, move on.
$smcFunc['db_insert']('insert',
'{db_prefix}user_alerts',
array('alert_time' => 'int''id_member' => 'int''id_member_started' => 'int''member_name' => 'string',
'content_type' => 'string''content_id' => 'int''content_action' => 'string''is_read' => 'int''extra' => 'string'),
array($this->_details['time'], $author$this->_details['sender_id'], $this->_details['sender_name'],
$this->_details['content_type'], $this->_details['content_id'], 'like'0''),
array('id_alert')
);

updateMemberData($author, array('alerts' => '+'));

return true;
}
}
?>





It is essentially the same as the current Git file minus the "anti spam" code.


// Don't spam the alerts: if there is an existing unread alert of the
// requested type for the target user from the sender, don't make a new one.
$request = $smcFunc['db_query']('', '
SELECT id_alert
FROM {db_prefix}user_alerts
WHERE id_member = {int:id_member}
AND is_read = 0
AND content_type = {string:content_type}
AND content_id = {int:content_id}
AND content_action = {string:content_action}',
array(
'id_member' => $author,
'content_type' => $this->_details['content_type'],
'content_id' => $this->_details['content_id'],
'content_action' => 'like',
)
);

if ($smcFunc['db_num_rows']($request) > 0)
return true;
$smcFunc['db_free_result']($request);



Just out of curiosity if your alerts are working, does your file contain the above code?  If so why does it not work for my site?
Title: Re: Alerts, Notifications are not working
Post by: Dragooon on June 03, 2015, 04:43:08 PM
Are no alerts being issued before you remove the code? Not even one?
Title: Re: Alerts, Notifications are not working
Post by: lc62003 on June 03, 2015, 04:46:31 PM
Quote from: Dragooon on June 03, 2015, 04:43:08 PM
Are no alerts being issued before you remove the code? Not even one?

Correct.  None whatsoever. 
Title: Re: Alerts, Notifications are not working
Post by: Dragooon on June 03, 2015, 04:47:44 PM
Do you have any rows in user_alerts table?
Title: Re: Alerts, Notifications are not working
Post by: lc62003 on June 03, 2015, 04:52:45 PM
Actually yes.  The alert queue shows up in the alert notifications with the addition of the legacy Likes-Notify file since they lie in wait from the database.