fix: 修复我的机器人不回复的情况

This commit is contained in:
kuaifan 2025-04-21 18:28:56 +08:00
parent 92d757662a
commit 19eb05269b
2 changed files with 9 additions and 7 deletions

View File

@ -210,7 +210,7 @@ class UserDevice extends AbstractModel
$row = self::whereHash($hash)->first(); $row = self::whereHash($hash)->first();
if ($row) { if ($row) {
// 判断是否过期 // 判断是否过期
if (Carbon::parse($row->expired_at)->isPast()) { if ($row->expired_at && Carbon::parse($row->expired_at)->isPast()) {
self::forget($row); self::forget($row);
return null; return null;
} }
@ -237,11 +237,11 @@ class UserDevice extends AbstractModel
if (empty($token)) { if (empty($token)) {
$token = Doo::userToken(); $token = Doo::userToken();
$userid = Doo::userId(); $userid = Doo::userId();
$expiredAt = Doo::userExpiredAt() ?: null; $expiredAt = Doo::userExpiredAt();
} else { } else {
$info = Doo::tokenDecode($token); $info = Doo::tokenDecode($token);
$userid = $info['userid'] ?? 0; $userid = $info['userid'] ?? 0;
$expiredAt = $info['expired_at'] ?? null; $expiredAt = $info['expired_at'];
} }
$deviceData = [ $deviceData = [
'detail' => Base::array2json(self::getDeviceInfo($_SERVER['HTTP_USER_AGENT'] ?? '')), 'detail' => Base::array2json(self::getDeviceInfo($_SERVER['HTTP_USER_AGENT'] ?? '')),

View File

@ -181,12 +181,12 @@ class Doo
/** /**
* token过期时间来自请求的token * token过期时间来自请求的token
* @return string * @return string|null
*/ */
public static function userExpiredAt(): string public static function userExpiredAt(): ?string
{ {
$expiredAt = self::string(self::doo()->userExpiredAt()); $expiredAt = self::string(self::doo()->userExpiredAt());
return $expiredAt === 'forever' ? '' : $expiredAt; return $expiredAt === 'forever' ? null : $expiredAt;
} }
/** /**
@ -263,7 +263,9 @@ class Doo
*/ */
public static function tokenDecode($token): array public static function tokenDecode($token): array
{ {
return Base::json2array(self::string(self::doo()->tokenDecode($token))); $array = Base::json2array(self::string(self::doo()->tokenDecode($token)));
$array['expired_at'] = $array['expired_at'] === 'forever' ? null : $array['expired_at'];
return $array;
} }
/** /**