juho-jaakkola / elgg-chat

Chat-like messaging plugin for Elgg
10 stars 6 forks source link

Avoid E-mail notifications about receiving chat messages when recipient is online #9

Open Pasley70 opened 9 years ago

Pasley70 commented 9 years ago

Proposal for discussion: When a user want notifications about new chat messages via e-mail (Settings in User-Tools), the user also receives e-mails notifications DURING chatting. Sender/Recipient get E-Mails with content that they have already read :-)

Maybe you can check here, if the recipient is online and prevent the e-mail-notification in this case?

/actions/chat/messages/save.php

        // Send email notification if user has enabled it
        $email_notification = elgg_get_plugin_user_setting('email_notification', $member->getGUID(), 'chat');
        if ($email_notification == 'on') {
            $subject = elgg_echo('chat:notification:subject:newpost');
            $body = elgg_echo('chat:notification:newpost', array($user->name, $chat->title, $message, $chat->getURL()));
            notify_user($member->getGUID(), elgg_get_site_entity()->getGUID(), $subject, $body, null, 'email');
        }

In the user-settings (tools) then it could mean: "Notifiy my about new messages vie email when i am offline."