mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-07 18:07:05 +00:00
no message
This commit is contained in:
parent
eb6c335b8a
commit
91f9aa8693
@ -466,17 +466,14 @@ class ReportController extends AbstractController
|
||||
* @apiGroup report
|
||||
* @apiName unread
|
||||
*
|
||||
* @apiParam {Number} [userid] 用户id
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function unread(): array
|
||||
{
|
||||
$userid = intval(trim(Request::input("userid")));
|
||||
$user = empty($userid) ? User::auth() : User::find($userid);
|
||||
|
||||
$user = User::auth();
|
||||
//
|
||||
$data = Report::whereHas("Receives", function (Builder $query) use ($user) {
|
||||
$query->where("userid", $user->userid)->where("read", 0);
|
||||
})->orderByDesc('created_at')->paginate(Base::getPaginate(50, 20));
|
||||
|
||||
@ -356,14 +356,7 @@ class User extends AbstractModel
|
||||
$user = self::authInfo();
|
||||
if (!$user) {
|
||||
if (Base::headerOrInput('token')) {
|
||||
throw new ApiException('身份已失效,请重新登录', [
|
||||
'token' => Base::headerOrInput('token'),
|
||||
'tokenDecode' => Doo::tokenDecode(Base::headerOrInput('token')),
|
||||
'userToken' => Doo::userToken(),
|
||||
'userId' => Doo::userId(),
|
||||
'userEmail' => Doo::userEmail(),
|
||||
'userEncrypt' => Doo::userEncrypt(),
|
||||
], -1);
|
||||
throw new ApiException('身份已失效,请重新登录', [], -1);
|
||||
} else {
|
||||
throw new ApiException('请登录后继续...', [], -1);
|
||||
}
|
||||
@ -409,20 +402,23 @@ class User extends AbstractModel
|
||||
/**
|
||||
* 生成 token
|
||||
* @param self $userinfo
|
||||
* @param bool $force 获取新的token
|
||||
* @param bool $refresh 获取新的token
|
||||
* @return string
|
||||
*/
|
||||
public static function generateToken($userinfo, $force = false)
|
||||
public static function generateToken($userinfo, $refresh = false)
|
||||
{
|
||||
if (!$force && Doo::userId() == $userinfo->userid) {
|
||||
$token = Doo::userToken();
|
||||
} else {
|
||||
if ($userinfo->bot) {
|
||||
$days = 0;
|
||||
} else {
|
||||
$days = max(1, intval(Base::settingFind('system', 'token_valid_days', 7)));
|
||||
if (!$refresh) {
|
||||
if (Doo::userId() != $userinfo->userid
|
||||
|| Doo::userEmail() != $userinfo->email
|
||||
|| Doo::userEncrypt() != $userinfo->encrypt) {
|
||||
$refresh = true;
|
||||
}
|
||||
}
|
||||
if ($refresh) {
|
||||
$days = $userinfo->bot ? 0 : max(1, intval(Base::settingFind('system', 'token_valid_days', 7)));
|
||||
$token = Doo::tokenEncode($userinfo->userid, $userinfo->email, $userinfo->encrypt, $days);
|
||||
} else {
|
||||
$token = Doo::userToken();
|
||||
}
|
||||
unset($userinfo->encrypt);
|
||||
unset($userinfo->password);
|
||||
|
||||
@ -9,24 +9,30 @@ use FFI;
|
||||
|
||||
class Doo
|
||||
{
|
||||
private static $doo = null;
|
||||
private static $token = null;
|
||||
private static $language = null;
|
||||
private static $doo;
|
||||
|
||||
/**
|
||||
* 加载模块
|
||||
* char转为字符串
|
||||
* @param $text
|
||||
* @return string
|
||||
*/
|
||||
private static function string($text): string
|
||||
{
|
||||
return FFI::string($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 装载
|
||||
* @param $token
|
||||
* @param $language
|
||||
* @return null
|
||||
*/
|
||||
public static function load($token = null, $language = null)
|
||||
{
|
||||
if (self::$doo === null) {
|
||||
self::$doo = FFI::cdef(<<<EOF
|
||||
self::$doo = FFI::cdef(<<<EOF
|
||||
void initialize(char* work, char* token, char* lang);
|
||||
char* license();
|
||||
char* licenseDecode(char* license);
|
||||
bool licenseSave(char* license);
|
||||
char* licenseSave(char* license);
|
||||
int userId();
|
||||
char* userExpiredAt();
|
||||
char* userEmail();
|
||||
@ -37,31 +43,32 @@ class Doo
|
||||
char* tokenDecode(char* val);
|
||||
char* translate(char* val, char* val);
|
||||
char* md5s(char* text, char* password);
|
||||
EOF, app_path("Module/Lib/doo.so"));
|
||||
self::$token = $token ?: Base::headerOrInput('token');
|
||||
self::$language = $language ?: Base::headerOrInput('language');
|
||||
}
|
||||
self::$doo->initialize("/var/www", self::$token, self::$language);
|
||||
return self::$doo;
|
||||
EOF, app_path("Module/Lib/doo.so"));
|
||||
$token = $token ?: Base::headerOrInput('token');
|
||||
$language = $language ?: Base::headerOrInput('language');
|
||||
self::$doo->initialize("/var/www", $token, $language);
|
||||
}
|
||||
|
||||
/**
|
||||
* char转为字符串
|
||||
* @param $text
|
||||
* @return string
|
||||
* 获取实例
|
||||
* @param $token
|
||||
* @param $language
|
||||
* @return mixed
|
||||
*/
|
||||
private static function string($text)
|
||||
{
|
||||
return FFI::string($text);
|
||||
public static function doo($token = null, $language = null) {
|
||||
if (self::$doo == null) {
|
||||
self::load($token, $language);
|
||||
}
|
||||
return self::$doo;
|
||||
}
|
||||
|
||||
/**
|
||||
* License
|
||||
* @return array
|
||||
*/
|
||||
public static function license()
|
||||
public static function license(): array
|
||||
{
|
||||
$array = Base::json2array(self::string(self::load()->license()));
|
||||
$array = Base::json2array(self::string(self::doo()->license()));
|
||||
|
||||
$ips = explode(",", $array['ip']);
|
||||
$array['ip'] = [];
|
||||
@ -95,35 +102,37 @@ class Doo
|
||||
* @param $license
|
||||
* @return array
|
||||
*/
|
||||
public static function licenseDecode($license)
|
||||
public static function licenseDecode($license): array
|
||||
{
|
||||
return Base::json2array(self::string(self::load()->licenseDecode($license)));
|
||||
return Base::json2array(self::string(self::doo()->licenseDecode($license)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存License
|
||||
* @param $license
|
||||
* @return bool
|
||||
*/
|
||||
public static function licenseSave($license)
|
||||
public static function licenseSave($license): void
|
||||
{
|
||||
return (bool)self::load()->licenseSave($license);
|
||||
$res = self::string(self::doo()->licenseSave($license));
|
||||
if ($res != 'success') {
|
||||
throw new ApiException($res ?: 'LICENSE 保存失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前会员ID(来自请求的token)
|
||||
* @return int
|
||||
*/
|
||||
public static function userId()
|
||||
public static function userId(): int
|
||||
{
|
||||
return intval(self::load()->userId());
|
||||
return intval(self::doo()->userId());
|
||||
}
|
||||
|
||||
/**
|
||||
* token是否过期(来自请求的token)
|
||||
* @return bool
|
||||
*/
|
||||
public static function userExpired()
|
||||
public static function userExpired(): bool
|
||||
{
|
||||
$expiredAt = self::userExpiredAt();
|
||||
return $expiredAt != 'forever' && Carbon::parse($expiredAt)->isBefore(Carbon::now());
|
||||
@ -131,49 +140,49 @@ class Doo
|
||||
|
||||
/**
|
||||
* token过期时间(来自请求的token)
|
||||
* @return bool
|
||||
* @return string
|
||||
*/
|
||||
public static function userExpiredAt()
|
||||
public static function userExpiredAt(): string
|
||||
{
|
||||
return self::string(self::load()->userExpiredAt());
|
||||
return self::string(self::doo()->userExpiredAt());
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前会员邮箱地址(来自请求的token)
|
||||
* @return string
|
||||
*/
|
||||
public static function userEmail()
|
||||
public static function userEmail(): string
|
||||
{
|
||||
return self::string(self::load()->userEmail());
|
||||
return self::string(self::doo()->userEmail());
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前会员Encrypt(来自请求的token)
|
||||
* @return string
|
||||
*/
|
||||
public static function userEncrypt()
|
||||
public static function userEncrypt(): string
|
||||
{
|
||||
return self::string(self::load()->userEncrypt());
|
||||
return self::string(self::doo()->userEncrypt());
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前会员token(来自请求的token)
|
||||
* @return string
|
||||
*/
|
||||
public static function userToken()
|
||||
public static function userToken(): string
|
||||
{
|
||||
return self::string(self::load()->userToken());
|
||||
return self::string(self::doo()->userToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建帐号
|
||||
* @param $email
|
||||
* @param $password
|
||||
* @return User|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
|
||||
* @return User|null
|
||||
*/
|
||||
public static function userCreate($email, $password)
|
||||
public static function userCreate($email, $password): User|null
|
||||
{
|
||||
$data = Base::json2array(self::string(self::load()->userCreate($email, $password)));
|
||||
$data = Base::json2array(self::string(self::doo()->userCreate($email, $password)));
|
||||
if (Base::isError($data)) {
|
||||
throw new ApiException($data['msg'] ?: '注册失败');
|
||||
}
|
||||
@ -192,9 +201,9 @@ class Doo
|
||||
* @param int $days 有效时间(天)
|
||||
* @return string
|
||||
*/
|
||||
public static function tokenEncode($userid, $email, $encrypt, $days = 7)
|
||||
public static function tokenEncode($userid, $email, $encrypt, int $days = 7): string
|
||||
{
|
||||
return self::string(self::load()->tokenEncode($userid, $email, $encrypt, $days));
|
||||
return self::string(self::doo()->tokenEncode($userid, $email, $encrypt, $days));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,30 +211,30 @@ class Doo
|
||||
* @param $token
|
||||
* @return array
|
||||
*/
|
||||
public static function tokenDecode($token)
|
||||
public static function tokenDecode($token): array
|
||||
{
|
||||
return Base::json2array(self::string(self::load()->tokenDecode($token)));
|
||||
return Base::json2array(self::string(self::doo()->tokenDecode($token)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译
|
||||
* @param string $text
|
||||
* @param $text
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
public static function translate($text, $type = "")
|
||||
public static function translate($text, string $type = ""): string
|
||||
{
|
||||
return self::string(self::load()->translate($text, $type));
|
||||
return self::string(self::doo()->translate($text, $type));
|
||||
}
|
||||
|
||||
/**
|
||||
* md5防破解
|
||||
* @param string $text
|
||||
* @param $text
|
||||
* @param string $password
|
||||
* @return string
|
||||
*/
|
||||
public static function md5s($text, $password = "")
|
||||
public static function md5s($text, string $password = ""): string
|
||||
{
|
||||
return self::string(self::load()->md5s($text, $password));
|
||||
return self::string(self::doo()->md5s($text, $password));
|
||||
}
|
||||
}
|
||||
|
||||
@ -412,3 +412,13 @@ error
|
||||
我要签到
|
||||
|
||||
关键词不能为空
|
||||
|
||||
LICENSE 格式错误
|
||||
LICENSE 保存失败
|
||||
邮箱地址格式错误
|
||||
LICENSE 已过期
|
||||
LICENSE 无效
|
||||
帐号数量已上限
|
||||
创建成功
|
||||
数据库连接失败
|
||||
邮箱地址已存在
|
||||
|
||||
@ -14804,5 +14804,82 @@
|
||||
"de": "Anonyme nachrichten werden über diese anonymen nachrichten übermittelt, ohne dass ihre identität aufgezeichnet wird",
|
||||
"fr": "Un message anonyme sera envoyé à l’autre partie via un message anonyme (bot) et aucune information d’identification de vous ne sera enregistrée",
|
||||
"id": "Pesan anonim akan dikirim ke pihak lain melalui pesan anonim (robot) yang tidak akan merekam informasi identitas anda"
|
||||
},
|
||||
{
|
||||
"key": "LICENSE 已过期",
|
||||
"zh": "",
|
||||
"zh-CHT": "LICENSE 已過期",
|
||||
"en": "LICENSE has expired",
|
||||
"ko": "라이선스가 만료되었습니다",
|
||||
"ja": "ライセンスの期限が切れました",
|
||||
"de": "Der maßstab ist ververfallen",
|
||||
"fr": "La licence a expiré",
|
||||
"id": "LICENSE sudah habis masa berlakunya"
|
||||
},
|
||||
{
|
||||
"key": "邮箱地址格式错误",
|
||||
"zh": "",
|
||||
"zh-CHT": "郵箱地址格式錯誤",
|
||||
"en": "The email address format is incorrect",
|
||||
"ko": "전자 우편 주소의 형식이 잘못되었습니다",
|
||||
"ja": "メールアドレスの書式が間違っています。",
|
||||
"de": "Die e-mail-adresse ist falsch geschrieben",
|
||||
"fr": "Adresse e-mail format incorrect",
|
||||
"id": "Alamat email berada dalam format yang salah"
|
||||
},
|
||||
{
|
||||
"key": "数据库连接失败",
|
||||
"zh": "",
|
||||
"zh-CHT": "數據庫連接失敗",
|
||||
"en": "Database connection failure",
|
||||
"ko": "데이터베이스 연결 실패",
|
||||
"ja": "データベースの接続に失敗しました",
|
||||
"de": "Datenbankzugriff fehlgeschlagen",
|
||||
"fr": "Connexion base de données échouée",
|
||||
"id": "Koneksi database gagal"
|
||||
},
|
||||
{
|
||||
"key": "帐号数量已上限",
|
||||
"zh": "",
|
||||
"zh-CHT": "帳號數量已上限",
|
||||
"en": "The number of accounts reached the upper limit. Procedure",
|
||||
"ko": "계정의 최대 수량이 설정되었습니다",
|
||||
"ja": "アカウント数が上限になりました。",
|
||||
"de": "Die anzahl der kontonummern wurde begrenzt",
|
||||
"fr": "Nombre de comptes limité",
|
||||
"id": "Nomor rekening dibatasi"
|
||||
},
|
||||
{
|
||||
"key": "LICENSE 格式错误",
|
||||
"zh": "",
|
||||
"zh-CHT": "LICENSE 格式錯誤",
|
||||
"en": "LICENSE format error",
|
||||
"ko": "라이선스 형식 오류",
|
||||
"ja": "ライセンスのフォーマットが間違っています",
|
||||
"de": "Das format ist fehlerhaft",
|
||||
"fr": "Format de licence incorrect",
|
||||
"id": "LICENSE salah format"
|
||||
},
|
||||
{
|
||||
"key": "LICENSE 保存失败",
|
||||
"zh": "",
|
||||
"zh-CHT": "LICENSE 保存失敗",
|
||||
"en": "LICENSE saving failure",
|
||||
"ko": "라이선스 저장에 실패했습니다",
|
||||
"ja": "ライセンス保存に失敗しました",
|
||||
"de": "Der schisma hat abgebrochen",
|
||||
"fr": "Échec de l’enregistrement de la licence",
|
||||
"id": "LICENSE gagal menyelamatkan"
|
||||
},
|
||||
{
|
||||
"key": "LICENSE 无效",
|
||||
"zh": "",
|
||||
"zh-CHT": "LICENSE 無效",
|
||||
"en": "Invalid LICENSE",
|
||||
"ko": "라이선스가 유효하지 않습니다",
|
||||
"ja": "ライセンス無効です",
|
||||
"de": "University of the mathe.",
|
||||
"fr": "La licence est invalide",
|
||||
"id": "LICENSE tidak valid"
|
||||
}
|
||||
]
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""]
|
||||
["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""]
|
||||
2
resources/assets/js/store/actions.js
vendored
2
resources/assets/js/store/actions.js
vendored
@ -2697,7 +2697,7 @@ export default {
|
||||
let url = $A.apiUrl('../ws');
|
||||
url = url.replace("https://", "wss://");
|
||||
url = url.replace("http://", "ws://");
|
||||
url += "?action=web&token=" + state.userToken;
|
||||
url += `?action=web&token=${state.userToken}&language=${languageType}`;
|
||||
//
|
||||
const wgLog = $A.openLog;
|
||||
const wsRandom = $A.randomString(16);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user