Skip to content

Commit dbb2034

Browse files
committed
feat(feed): ( isses #337 ) 动态评论增加 at 人功能
1 parent 28ea574 commit dbb2034

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

app/AtMessage/Resources/Comment.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,33 @@
2727

2828
class Comment implements ResourceInterface
2929
{
30+
/**
31+
* The comment resource.
32+
* @var \Zhiyi\Plus\Models\Comment
33+
*/
3034
protected $comment;
35+
36+
/**
37+
* The sender
38+
* @var \Zhiyi\Plus\Models\User
39+
*/
3140
protected $sender;
3241

42+
/**
43+
* Create the resource.
44+
* @param \Zhiyi\Plus\Models\Comment $comment
45+
* @param \Zhiyi\Plus\Models\User $sender
46+
*/
3347
public function __construct(CommentModel $comment, UserModel $sender)
3448
{
3549
$this->comment = $comment;
3650
$this->sender = $sender;
3751
}
3852

53+
/**
54+
* Get the resourceable type.
55+
* @return string
56+
*/
3957
public function type(): string
4058
{
4159
$alise = ModelTypes::$types[CommentModel::class] ?? null;
@@ -47,11 +65,19 @@ public function type(): string
4765
return $alise;
4866
}
4967

68+
/**
69+
* Get the resourceable id.
70+
* @return int
71+
*/
5072
public function id(): int
5173
{
5274
return $this->comment->id;
5375
}
5476

77+
/**
78+
* Get the resourceable push message.
79+
* @return string
80+
*/
5581
public function message(): string
5682
{
5783
return sprintf('%s在评论中@了你', $this->sender->name);

packages/slimkit-plus-feed/src/API2/FeedCommentController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Zhiyi\Plus\Services\Push;
2626
use Zhiyi\Plus\Http\Controllers\Controller;
2727
use Zhiyi\Plus\Models\Comment as CommentModel;
28+
use Zhiyi\Plus\AtMessage\AtMessageHelperTrait;
2829
use Zhiyi\Plus\Models\UserCount as UserCountModel;
2930
use Zhiyi\Plus\Packages\Currency\Processes\User as UserProcess;
3031
use Zhiyi\Component\ZhiyiPlus\PlusComponentFeed\Models\FeedPinned;
@@ -34,6 +35,8 @@
3435

3536
class FeedCommentController extends Controller
3637
{
38+
use AtMessageHelperTrait;
39+
3740
/**
3841
* List comments of the feed.
3942
*
@@ -217,6 +220,9 @@ public function store(
217220
}
218221
$comment->load('user');
219222

223+
// 发送 at 数据
224+
$this->sendAtMessage($comment->body, $user, $comment);
225+
220226
return $response->json([
221227
'message' => '操作成功',
222228
'comment' => $comment,

0 commit comments

Comments
 (0)