ApplyAgreeHandler.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Module\AppGame\Handler\Friend;
  3. use App\Module\AppGame\Handler\BaseHandler;
  4. use App\Module\Friend\Enums\ERROR_CODE;
  5. use App\Module\Friend\Services\FriendService;
  6. use Google\Protobuf\Internal\Message;
  7. use Uraus\Kku\Request\RequestFriendApplyAgree;
  8. use Uraus\Kku\Response\ResponseFriendApplyAgree;
  9. /**
  10. * 处理同意好友申请请求
  11. */
  12. class ApplyAgreeHandler extends BaseHandler
  13. {
  14. /**
  15. * 是否需要登录
  16. * @var bool
  17. */
  18. protected bool $need_login = true;
  19. /**
  20. * 处理同意好友申请请求
  21. *
  22. * @param RequestFriendApplyAgree $data 同意好友申请请求数据
  23. * @return ResponseFriendApplyAgree 同意好友申请响应
  24. */
  25. public function handle(Message $data): Message
  26. {
  27. // 创建响应对象
  28. $response = new ResponseFriendApplyAgree();
  29. // 获取请求参数
  30. $applyId = $data->getApplyId();
  31. // 参数验证
  32. if (empty($applyId)) {
  33. // ResponseFriendApplyAgree没有错误码字段,只能返回空响应
  34. return $response;
  35. }
  36. // 调用服务同意好友申请
  37. $result = FriendService::acceptFriendRequest($this->user_id, $applyId);
  38. // ResponseFriendApplyAgree没有返回字段,无法设置结果
  39. // 客户端需要通过其他方式(如刷新好友列表)来确认操作结果
  40. return $response;
  41. }
  42. }