Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding multiple (annoying) alerts for non-core alert types #59

Merged
merged 1 commit into from
Jul 2, 2013
Merged

Avoiding multiple (annoying) alerts for non-core alert types #59

merged 1 commit into from
Jul 2, 2013

Conversation

Shade-
Copy link
Contributor

@Shade- Shade- commented Jul 1, 2013

As discussed here, if you're using an extra pack of alerts or whatever plugin that supports MyAlerts, users can receive more than one notification for the same event. If you are a) mentioned, b) quoted in a c) reply of a thread you've made and d) you've subscribed to, MyAlerts will send you 4 alerts with the same purpose, assuming you've installed MentionMe + Plugins Alerts Pack.

This came up to my mind just now after months. I was looking for something to improve my MyAlerts extensions and got the solution scratching my head a little bit. It's quite easy but really effective as we can make a great use of PHP sessions to store subsequent calls and data to check whether if an alert has been already delivered for that specific thread or not and act dependently on it.

        if(!session_id()) {
            session_start();
        }

        if(!empty($tid)) {
            if($tid == $_SESSION['tid'] && $type != $_SESSION['type']) {
                return;
            } else {
                unset($_SESSION['tid']);
                unset($_SESSION['type']);
                $_SESSION['tid'] = $tid;
                $_SESSION['type'] = $type;
            }
        }

It's just easy as this snippet. We check for both the tid and the type of alert because if you reply to a thread, the user sees the alert and you reply once again to the same thread, the tid will be the same and the alert won't be generated (we want at least one to be delivered 馃槃).

This seems the best solution with a transparent approach to me. No wasted queries and just a small change to make the MyAlerts experience much smarter for both developers and users.

@euantorano
Copy link
Contributor

Looks like a good idea. I'll test it and see if it helps for me too. Removing extra queries is always welcome :) Thanks Shade.

@nntoan
Copy link

nntoan commented Jul 2, 2013

And where we can put these codes ? Alert.class.php ?

@Shade-
Copy link
Contributor Author

Shade- commented Jul 2, 2013

Yes, as you can see in the commit

euantorano added a commit that referenced this pull request Jul 2, 2013
Avoiding multiple (annoying) alerts for non-core alert types
@euantorano euantorano merged commit c66eb87 into MyBBStuff:master Jul 2, 2013
@WildcardSearch
Copy link
Contributor

Looking good guys. Can't wait to test.

Nice work as always @Shade-

@Shade- Shade- deleted the patch-2 branch July 3, 2013 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants