Saves a new comment and sends any notification emails.
343448
def save(self, request):
        
        comment = self.get_comment_object()
        obj = comment.content_object
        if request.user.is_authenticated():
            comment.user = request.user
        comment.by_author = request.user == getattr(obj, "user", None)
        comment.ip_address = ip_for_request(request)
        comment.replied_to_id = self.data.get("replied_to")

        # YaCms's duplicate check that also checks `replied_to_id`.
        lookup = {
            "content_type": comment.content_type,
            "object_pk": comment.object_pk,
            "user_name": comment.user_name,
            "user_email": comment.user_email,
            "user_url": comment.user_url,
            "replied_to_id": comment.replied_to_id,
        }
        for duplicate in self.get_comment_model().objects.filter(**lookup):
            if (duplicate.submit_date.date() == comment.submit_date.date() and
                    duplicate.comment == comment.comment):
                return duplicate

        comment.save()
        comment_was_posted.send(sender=comment.__class__, comment=comment,
                                request=request)
        notify_emails = split_addresses(settings.COMMENTS_NOTIFICATION_EMAILS)
        if notify_emails:
            subject = ugettext("New comment for: ") + str(obj)
            context = {
                "comment": comment,
                "comment_url": add_cache_bypass(comment.get_absolute_url()),
                "request": request,
                "obj": obj,
            }
            send_mail_template(subject, "email/comment_notification",
                               settings.DEFAULT_FROM_EMAIL, notify_emails,
                               context)
        return comment
1356773
public function onAfterWrite()
    {
        parent::onAfterWrite();

        // Deal with sending the status emails
        if ($this->isChanged('Status')) {
            $notifications = Notification::get()
                ->filter("Status", $this->Status);
                
            // Loop through available notifications and send
            foreach ($notifications as $notification) {
                $notification->sendNotification($this);
            }
        }
    }
238450
def create_notifications(users, notification_model, notification_type, related_object):
    
    # shortcuts for readability
    Notification = notification_model

    # text
    additional = related_object.__dict__ if related_object else ''
    notification_text = TEXTS[notification_type] % additional

    # loop users, notification settings check is done in Notification model
    for user in users:

        n = Notification(
            to_user=user,
            type=notification_type,
            text=notification_text
        )
        # attach related object if present
        if related_object:
            n.related_object = related_object
        # create notification and send according to user settings
        n.save()
340825
public function SendReviewReportNotification()
    {
        $this->SaveActionIdToComment();
        $oMail = TDataMailProfile::GetProfile('report-review');
        $aData = array();
        $oShop = TdbShop::GetInstance();
        $oArticle = &$this->GetFieldShopArticle();
        $aData['sArticleName'] = $oArticle->GetName();
        $aData['sReviewId'] = $this->id;
        $aData['sReviewTitle'] = $this->fieldTitle;
        $aData['sReviewText'] = $this->fieldComment;
        $aData['sReviewAuthor'] = $this->fieldAuthorName;
        $aData['sUnlockReviewLink'] = "<a href='".$this->GetUnlockURL(true)."'>".TGlobal::OutHtml(TGlobal::Translate('chameleon_system_shop_article_review.action.publish_comment')).'</a> ';
        $aData['sDeleteReviewLink'] = "<a href='".$this->GetDeleteWithActionIdURL(true)."'>".TGlobal::OutHtml(TGlobal::Translate('chameleon_system_shop_article_review.action.delete_comment')).'</a> ';
        $aData['shopname'] = $oShop->GetName();
        $oMail->AddDataArray($aData);
        $oMail->SendUsingObjectView('emails', 'Customer');
    }
875317
public function notifyCreate()
    {
        if (\Yii::$app->reviews2->notifyEmails) {
            foreach (\Yii::$app->reviews2->notifyEmails as $email) {
                \Yii::$app->mailer->compose('@skeeks/cms/reviews2/mail/new-message', [
                    'model' => $this
                ])
                    ->setFrom([\Yii::$app->cms->adminEmail => \Yii::$app->cms->appName])
                    ->setTo($email)
                    ->setSubject(\Yii::t('skeeks/reviews2', "Added a new review") . " #" . $this->id)
                    ->send();
            }
        }
    }
618013
def send_reminder(self, user, sender=None, **kwargs):
        """"""
        if user.is_active:
            return False
        token = RegistrationTokenGenerator().make_token(user)
        kwargs.update({"token": token})
        self.email_message(
            user, self.reminder_subject, self.reminder_body, sender, **kwargs
        ).send()
1318048
def comment_sent(comment)
      users = ::User.all.select {|user| user.is_admin? || user.can_review?}
      bcc = users.map {|user| user.email}
      @comment = comment
      @who_name = comment.user.profile.name
      mail bcc: bcc, subject: 'CFP MagmaConf - New comment'
    end
738855
def do_email_notification(self, comment, entry, site):
        
        if not self.mail_comment_notification_recipients:
            return

        template = loader.get_template(
            'comments/zinnia/entry/email/notification.txt')
        context = {
            'comment': comment,
            'entry': entry,
            'site': site,
            'protocol': PROTOCOL
        }
        subject = _('[%(site)s] New comment posted on "%(title)s"') % \
            {'site': site.name, 'title': entry.title}
        message = template.render(context)

        send_mail(
            subject, message,
            settings.DEFAULT_FROM_EMAIL,
            self.mail_comment_notification_recipients,
            fail_silently=not settings.DEBUG
        )
227697
def add_comment(self, post=None, name=None, email=None, pub_date=None,
                    website=None, body=None):
        
        if post is None:
            if not self.posts:
                raise CommandError("Cannot add comments without posts")
            post = self.posts[-1]
        post["comments"].append({
            "user_name": name,
            "user_email": email,
            "submit_date": pub_date,
            "user_url": website,
            "comment": body,
        })
741759
def send_comment(results)
      dir = "#{Dir.pwd}/"
      results['messages'].each do |r|
        filename = results['filePath'].gsub(dir, '')
        method = r['severity'] > 1 ? 'fail' : 'warn'
        send(method, r['message'], file: filename, line: r['line'])
      end
    end
1179600
def reply(self, reply_comment):
        
        payload = '{ "Comment": "' + reply_comment + '"}'
        endpoint = 'https://outlook.office.com/api/v2.0/me/messages/' + self.message_id + '/reply'

        self._make_api_call('post', endpoint, data=payload)
718565
public function sendCommentSpamRequestMail( $comment, $updatePath ) {

		$siteName		= $this->coreProperties->getSiteName();
		$fromEmail		= $this->mailProperties->getSenderEmail();
		$fromName		= $this->mailProperties->getSenderName();
		$contactEmail	= $this->mailProperties->getContactEmail();

		// Send Mail
		$this->getMailer()->compose( self::MAIL_COMMENT_SPAM_REQUEST, [ 'coreProperties' => $this->coreProperties, 'comment' => $comment, 'updatePath' => $updatePath ] )
			->setTo( $contactEmail )
			->setFrom( [ $fromEmail => "$fromName | $siteName" ] )
			->setSubject( "Spam Request | " . $this->coreProperties->getSiteName() )
			//->setTextBody( "heroor" )
			->send();
	}
120115
public function updateComment()
    {
        $newComment = $_POST['comment'] ?? null;
        $commentId = $_POST['commentId'] ?? null;

        if (!$newComment || !$commentId || !$comment = get_comment($commentId)) {
            wp_send_json_error('Missing variables');
        }

        if (!current_user_can('edit_comment', $comment->comment_ID) && !($comment->user_id == get_current_user_id())) {
            wp_send_json_error('Missing authorization');
        }

        // Validate nonce
        if (!check_ajax_referer("update-comment_$comment->comment_ID", 'nonce', false)) {
            wp_send_json_error('Nonce failed');
        }

        $comment->comment_content = $newComment;
        if (wp_update_comment((array) $comment)) {
            wp_send_json_success('Update was successful');
        }

        wp_send_json();
    }
746739
def update_letter_comment(self, letter_comment_id, letter_comment_dict):
        
        return self._create_put_request(
            resource=LETTER_COMMENTS,
            billomat_id=letter_comment_id,
            send_data=letter_comment_dict
        )
36658
def notify(cls, user_or_email, instance):
        """"""
        return super(InstanceEvent, cls).notify(user_or_email,
                                                object_id=instance.pk)
1344796
function newComment($post_id, array $comment)
    {
        $params = array(1, $this->username, $this->password, $post_id, $comment);

        return $this->sendRequest('wp.newComment', $params);
    }
607062
public function sendNotificationsReply($tid, $cur_posting, $new_pid, $post)
    {
        Container::get('hooks')->fire('model.post.send_notifications_reply_start', $tid, $cur_posting, $new_pid, $post);

        // Get the post time for the previous post in this topic
        $previous_post_time = DB::forTable('posts')
            ->select('posted')
            ->where('topic_id', $tid)
            ->order_by_desc('id');
        $previous_post_time = Container::get('hooks')->fireDB(
            'model.post.send_notifications_reply_previous',
            $previous_post_time
        );
        $previous_post_time = $previous_post_time->find_one();

        // Get any subscribed users that should be notified (banned users are excluded)
//        $result['where'] = array(
//            array('fp.read_forum' => 'IS NULL'),
//            array('fp.read_forum' => '1')
//        );
        $result['select'] = ['u.id', 'u.email', 'u.notify_with_post', 'u.language'];

        $result = DB::forTable('users')
                    ->table_alias('u')
                    ->select_many($result['select'])
                    ->inner_join(DB::prefix().'topic_subscriptions', ['u.id', '=', 's.user_id'], 's')
//                    ->left_outer_join('forum_perms', array('fp.forum_id', '=', $cur_posting['id']), 'fp', true)
//                    ->left_outer_join('forum_perms', array('fp.group_id', '=', 'u.group_id'))
            ->left_outer_join(
                DB::prefix().'forum_perms',
                '(fp.group_id=u.group_id AND fp.forum_id='. $cur_posting['id'].')',
                'fp'
            )
                    ->left_outer_join(DB::prefix().'online', ['u.id', '=', 'o.user_id'], 'o')
                    ->left_outer_join(DB::prefix().'bans', ['u.username', '=', 'b.username'], 'b')
                    ->where_raw('COALESCE(o.logged, u.last_visit)>'.$previous_post_time->posted)
                    ->where_null('b.username')
                    ->where_raw('(fp.read_forum IS NULL OR fp.read_forum=1)')
                    ->where('s.topic_id', $tid)
                    ->where_not_equal('u.id', User::get()->id);
        $result = Container::get('hooks')->fireDB('model.post.send_notifications_reply_query', $result);
        $result = $result->find_many();

        if ($result) {
            $notification_emails = [];

            $censored_message = Utils::trim(Utils::censor($post['message']));

            if (ForumSettings::get('o_censoring') == '1') {
                $cleaned_message = Container::get('email')->bbcode2email($censored_message, -1);
            } else {
                $cleaned_message = Container::get('email')->bbcode2email($post['message'], -1);
            }

            // Loop through subscribed users and send emails
            foreach ($result as $cur_subscriber) {
                // Is the subscription email for $cur_subscriber['language'] cached or not?
                if (!isset($notification_emails[$cur_subscriber['language']])) {
//                    if (file_exists(ForumEnv::get('FORUM_ROOT').'lang/'.$cur_subscriber['language'].
//                        '/mail_templates/new_reply.tpl')) {
                        $mail_tpl = Lang::getMailTemplate('new_reply')->text;
                    if ($mail_tpl) {
                        // Load the "new reply" template
//                        $mail_tpl = trim(file_get_contents(ForumEnv::get('FORUM_ROOT').'lang/'.
//                            $cur_subscriber['language'].'/mail_templates/new_reply.tpl'));
                        $mail_tpl = Container::get('hooks')->fire(
                            'model.post.send_notifications_reply_mail_tpl',
                            $mail_tpl
                        );

                        // Load the "new reply full" template (with post included)
//                        $mail_tpl_full = trim(file_get_contents(ForumEnv::get('FORUM_ROOT').'lang/'.
//                            $cur_subscriber['language'].'/mail_templates/new_reply_full.tpl'));
                        $mail_tpl_full = Lang::getMailTemplate('new_reply_full')->text;

                        $mail_tpl_full = Container::get('hooks')->fire(
                            'model.post.send_notifications_reply_mail_tpl_full',
                            $mail_tpl_full
                        );

                        // The first row contains the subject (it also starts with "Subject:")
                        $first_crlf = strpos($mail_tpl, "\n");
                        $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
                        $mail_subject = Container::get('hooks')->fire(
                            'model.post.send_notifications_reply_mail_subject',
                            $mail_subject
                        );
                        $mail_message = trim(substr($mail_tpl, $first_crlf));

                        $first_crlf = strpos($mail_tpl_full, "\n");
                        $mail_subject_full = trim(substr($mail_tpl_full, 8, $first_crlf-8));
                        $mail_message_full = trim(substr($mail_tpl_full, $first_crlf));

                        $mail_subject = str_replace('<topic_subject>', $cur_posting['subject'], $mail_subject);
                        $mail_message = str_replace('<topic_subject>', $cur_posting['subject'], $mail_message);
                        $mail_message = str_replace('<replier>', $post['username'], $mail_message);
                        $mail_message = str_replace(
                            '<post_url>',
                            Router::pathFor('viewPost', ['pid' => $new_pid]).'#p'.$new_pid,
                            $mail_message
                        );
                        $mail_message = str_replace(
                            '<unsubscribe_url>',
                            Router::pathFor('unsubscribeTopic', ['id' => $tid]),
                            $mail_message
                        );
                        $mail_message = str_replace(
                            '<board_mailer>',
                            ForumSettings::get('o_board_title'),
                            $mail_message
                        );
                        $mail_message = Container::get('hooks')->fire(
                            'model.post.send_notifications_reply_mail_message',
                            $mail_message
                        );

                        $mail_subject_full = str_replace(
                            '<topic_subject>',
                            $cur_posting['subject'],
                            $mail_subject_full
                        );
                        $mail_message_full = str_replace(
                            '<topic_subject>',
                            $cur_posting['subject'],
                            $mail_message_full
                        );
                        $mail_message_full = str_replace('<replier>', $post['username'], $mail_message_full);
                        $mail_message_full = str_replace('<message>', $cleaned_message, $mail_message_full);
                        $mail_message_full = str_replace(
                            '<post_url>',
                            Router::pathFor('viewPost', ['pid' => $new_pid]).'#p'.$new_pid,
                            $mail_message_full
                        );
                        $mail_message_full = str_replace(
                            '<unsubscribe_url>',
                            Router::pathFor('unsubscribeTopic', ['id' => $tid]),
                            $mail_message_full
                        );
                        $mail_message_full = str_replace(
                            '<board_mailer>',
                            ForumSettings::get('o_board_title'),
                            $mail_message_full
                        );
                        $mail_message_full = Container::get('hooks')->fire(
                            'model.post.send_notifications_reply_mail_message_full',
                            $mail_message_full
                        );

                        $notification_emails[$cur_subscriber['language']][0] = $mail_subject;
                        $notification_emails[$cur_subscriber['language']][1] = $mail_message;
                        $notification_emails[$cur_subscriber['language']][2] = $mail_subject_full;
                        $notification_emails[$cur_subscriber['language']][3] = $mail_message_full;

                        $mail_subject = $mail_message = $mail_subject_full = $mail_message_full = null;
                    }
                }

                // We have to double check here because the templates could be missing
                if (isset($notification_emails[$cur_subscriber['language']])) {
                    if ($cur_subscriber['notify_with_post'] == '0') {
                        Container::get('email')->dispatchMail(
                            $cur_subscriber['email'],
                            $notification_emails[$cur_subscriber['language']][0],
                            $notification_emails[$cur_subscriber['language']][1]
                        );
                    } else {
                        Container::get('email')->dispatchMail(
                            $cur_subscriber['email'],
                            $notification_emails[$cur_subscriber['language']][2],
                            $notification_emails[$cur_subscriber['language']][3]
                        );
                    }
                }
            }

            Container::get('hooks')->fire('model.post.send_notifications_reply');

            unset($cleaned_message);
        }
    }