修复微信机器人好友上线通知由于好友模型失效导致的无法通知的问题
This commit is contained in:
@@ -227,17 +227,23 @@ class WechatNotificationService
|
|||||||
|
|
||||||
protected function getUserFriends(int $userId)
|
protected function getUserFriends(int $userId)
|
||||||
{
|
{
|
||||||
// 假定有好友表
|
$user = User::find($userId);
|
||||||
if (\Illuminate\Support\Facades\Schema::hasTable('friends')) {
|
if (! $user) {
|
||||||
return \Illuminate\Support\Facades\DB::table('friends')
|
return collect([]);
|
||||||
->join('users', 'users.id', '=', 'friends.friend_id')
|
|
||||||
->where('friends.user_id', $userId)
|
|
||||||
->whereNotNull('users.wxid')
|
|
||||||
->select('users.*')
|
|
||||||
->get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return collect([]);
|
// 谁把当前用户加为了好友(当前用户是 towho),谁就应该收到上线通知
|
||||||
|
$watcherNames = \App\Models\FriendRequest::where('towho', $user->username)
|
||||||
|
->pluck('who');
|
||||||
|
|
||||||
|
if ($watcherNames->isEmpty()) {
|
||||||
|
return collect([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return User::whereIn('username', $watcherNames)
|
||||||
|
->whereNotNull('wxid')
|
||||||
|
->where('wxid', '!=', '')
|
||||||
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getUserSpouse(User $user)
|
protected function getUserSpouse(User $user)
|
||||||
|
|||||||
Reference in New Issue
Block a user