Skip to content

Commit f2c53f4

Browse files
committed
fixed logic bug
1 parent 2308f20 commit f2c53f4

1 file changed

Lines changed: 42 additions & 44 deletions

File tree

Action.php

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -197,56 +197,53 @@ private function processMail(): bool
197197
$toMe = (in_array('to_me', $this->_cfg->other) && $this->_comment->ownerId == $this->_comment->authorId) ? true : false;
198198

199199
//向博主发信
200-
if ($this->_comment->parent == 0) {
201-
if (in_array($this->_comment->status, $this->_cfg->status) && in_array('to_owner', $this->_cfg->other) && ($toMe || $this->_comment->ownerId != $this->_comment->authorId)) {
202-
if (!$this->_cfg->mail) {
203-
self::widget('\Widget\Users\Author@temp' . $this->_comment->cid, ['uid' => $this->_comment->ownerId])->to($user);
204-
$this->_email->reciver = $user->mail;
205-
} else {
206-
$this->_email->reciver = $this->_cfg->mail;
207-
}
208-
if (!$this->_cfg->name) {
209-
self::widget('\Widget\Users\Author@temp' . $this->_comment->cid, ['uid' => $this->_comment->ownerId])->to($user);
210-
$this->_email->reciverName = $user->name;
211-
} else {
212-
$this->_email->reciverName = $this->_cfg->name;
213-
}
214-
215-
// 设置邮件回复信息
216-
$this->_email->replyTo = $this->_comment->mail; //评论者的邮箱
217-
$this->_email->replyToName = $this->_comment->author;
218-
$this->authorMail()->sendMail();
200+
if ($this->_comment->parent == 0 && in_array($this->_comment->status, $this->_cfg->status) && in_array('to_owner', $this->_cfg->other) && ($toMe || $this->_comment->ownerId != $this->_comment->authorId)) {
201+
if (!$this->_cfg->mail) {
202+
self::widget('\Widget\Users\Author@temp' . $this->_comment->cid, ['uid' => $this->_comment->ownerId])->to($user);
203+
$this->_email->reciver = $user->mail;
204+
} else {
205+
$this->_email->reciver = $this->_cfg->mail;
206+
}
207+
if (!$this->_cfg->name) {
208+
self::widget('\Widget\Users\Author@temp' . $this->_comment->cid, ['uid' => $this->_comment->ownerId])->to($user);
209+
$this->_email->reciverName = $user->name;
210+
} else {
211+
$this->_email->reciverName = $this->_cfg->name;
219212
}
220-
} else {
221-
/** 向访客发信 */
222-
if ($this->_comment->status == 'approved' && in_array('to_guest', $this->_cfg->other)) {
223-
/** 如果联系我的邮件地址为空,则使用文章作者的邮件地址 */
224-
if (!$this->_cfg->contactme) {
225-
if (!isset($user) || !$user) {
226-
self::widget('\Widget\Users\Author@temp' . $this->_comment->cid, array('uid' => $this->_comment->ownerId))->to($user);
227-
}
228-
$this->_comment->contactme = $user->mail;
229-
} else {
230-
$this->_comment->contactme = $this->_cfg->contactme;
231-
}
232213

233-
$original = $this->_db->fetchRow($this->_db->select('author', 'mail', 'text')
234-
->from('table.comments')
235-
->where('coid = ?', $this->_comment->parent));
236-
if (in_array('to_me', $this->_cfg->other) || $this->_comment->mail != $original['mail']) {
237-
$this->_comment->originalText = $original['text'];
238-
$this->_comment->originalAuthor = $original['author'];
239-
240-
$this->_email->reciver = $original['mail'];
241-
$this->_email->reciverName = $original['author'];
242-
$this->_email->replyTo = $this->_comment->mail; //当前评论者的邮箱
243-
$this->_email->replyToName = $this->_comment->author ? $this->_comment->author : $this->_options->title;
244-
$this->guestMail()->sendMail();
214+
// 设置邮件回复信息
215+
$this->_email->replyTo = $this->_comment->mail; //评论者的邮箱
216+
$this->_email->replyToName = $this->_comment->author;
217+
$this->authorMail()->sendMail();
218+
}
219+
220+
/** 向访客发信 */
221+
if ($this->_comment->parent !== 0 && $this->_comment->status == 'approved' && in_array('to_guest', $this->_cfg->other)) {
222+
/** 如果联系我的邮件地址为空,则使用文章作者的邮件地址 */
223+
if (!$this->_cfg->contactme) {
224+
if (!isset($user) || !$user) {
225+
self::widget('\Widget\Users\Author@temp' . $this->_comment->cid, array('uid' => $this->_comment->ownerId))->to($user);
245226
}
227+
$this->_comment->contactme = $user->mail;
228+
} else {
229+
$this->_comment->contactme = $this->_cfg->contactme;
230+
}
231+
232+
$original = $this->_db->fetchRow($this->_db->select('author', 'mail', 'text')
233+
->from('table.comments')
234+
->where('coid = ?', $this->_comment->parent));
235+
if (in_array('to_me', $this->_cfg->other) || $this->_comment->mail != $original['mail']) {
236+
$this->_comment->originalText = $original['text'];
237+
$this->_comment->originalAuthor = $original['author'];
238+
239+
$this->_email->reciver = $original['mail'];
240+
$this->_email->reciverName = $original['author'];
241+
$this->_email->replyTo = $this->_comment->mail; //当前评论者的邮箱
242+
$this->_email->replyToName = $this->_comment->author ? $this->_comment->author : $this->_options->title;
243+
$this->guestMail()->sendMail();
246244
}
247245
}
248246

249-
unset($this->_comment); //销毁评论对象
250247
return true;
251248
}
252249

@@ -383,6 +380,7 @@ public function sendMail(): bool|string|NULL
383380
$mailer->ClearReplyTos();
384381

385382
unset($this->_email); //销毁对象
383+
unset($this->_comment); //销毁评论对象
386384
return $result;
387385
}
388386

0 commit comments

Comments
 (0)