getstream-io - 如何检查通知是否是提及
问题描述
我正在使用 stream-laravel,我想将 @-mentions 集成到我的帖子模型中。我现在添加activityNotify()
了帖子中提到的用户。这工作正常。但是,当我检索通知提要时,动词是“发布”,因为活动当然是发布。
对于前端,我想知道它何时是@提及。处理这个问题的最佳方法是什么?
我像这样通知@提及用户
public function activityNotify()
{
$notify = collect();
foreach ($this->mentions as $mention) {
$userNotification = \FeedManager::getNotificationFeed($mention);
$notify->push($userNotification);
}
return $notify;
}
我的通知输出如下所示:
0 => array:10 [▼
"activities" => array:1 [▼
0 => [
"actor" => App\User {#1652 ▶}
"body" => "Hey @john Doe"
"foreign_id" => "CommunityPost:37"
"id" => "26428c80-3cee-11ea-8080-80013d33eb64"
"object" => CommunityPost {#1683 ▶}
"origin" => null
"target" => ""
"time" => "2020-01-22T08:06:53.000000"
"verb" => "post"
]
]
"activity_count" => 1
"actor_count" => 1
"created_at" => "2020-01-22T08:06:53.970618"
"group" => "post_2020-01-22_26428c80-3cee-11ea-8080-80013d33eb64_"
"id" => "26d6a746-3cee-11ea-8080-80000fca6a99.post_2020-01-22_26428c80-3cee-11ea-8080-80013d33eb64_"
"is_read" => false
"is_seen" => false
"updated_at" => "2020-01-22T08:06:53.970618"
"verb" => "post"
]
解决方案
可能最简单的方法是解析活动主体字段并搜索@username
. 找到后,将活动呈现为提及而不是常规帖子。
您还可以将自定义数据添加到活动中;IE。添加一个提到的用户 ID 自定义字段并包含所有提到的用户的 ID。
推荐阅读
- javascript - 无法设置未定义打字稿的属性 0
- python-3.x - 尝试为 python3 安装 pytables
- powershell - 根据 Powershell 中的列值删除 CSV 行
- javascript - 如何同时测试表单上的所有输入?
- javascript - 如果我的登录数据无效,帮助文本没有显示我的错误并且我的错误消息没有出现
- matlab - Matlab:树状图轴背景颜色
- javascript - 鼠标悬停在 Chrome 浏览器上的日期和时间选择器图标上时的光标指针
- kubernetes - MiniKube,通过 localhost:3306 访问数据库 pod?
- node.js - 使用 aws-sdk 在 Docker 容器中运行 Node 应用程序
- c# - 我可以在 C# 中将字符串附加到 Func 吗?