2021-07-06 23:32:14 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Support;
|
|
|
|
|
2021-07-20 23:12:18 +08:00
|
|
|
use App\Constants\TalkModeConstant;
|
2021-07-28 23:08:07 +08:00
|
|
|
use App\Service\Group\GroupMemberService;
|
2021-07-12 22:00:48 +08:00
|
|
|
use App\Service\UserFriendService;
|
2021-07-06 23:32:14 +08:00
|
|
|
|
|
|
|
class UserRelation
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 判断是否是好友或者群成员关系
|
|
|
|
*
|
|
|
|
* @param int $user_id 用户ID
|
|
|
|
* @param int $receiver_id 接收者ID
|
|
|
|
* @param int $talk_type 对话类型
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public static function isFriendOrGroupMember(int $user_id, int $receiver_id, int $talk_type)
|
|
|
|
{
|
2021-07-20 23:12:18 +08:00
|
|
|
if ($talk_type == TalkModeConstant::PRIVATE_CHAT) {
|
2021-07-23 21:34:29 +08:00
|
|
|
return di()->get(UserFriendService::class)->isFriend($user_id, $receiver_id, true);
|
2021-07-20 23:12:18 +08:00
|
|
|
} else if ($talk_type == TalkModeConstant::GROUP_CHAT) {
|
2021-07-28 23:08:07 +08:00
|
|
|
return di()->get(GroupMemberService::class)->isMember($receiver_id, $user_id);
|
2021-07-06 23:32:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|