2026-05-23 19:12:58 +08:00

1929 lines
52 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
import '../../../data_sources/models/enum/sc_props_type.dart';
/// token : ""
/// userCredential : {"expireTime":0,"releaseTime":0,"sign":"","sysOrigin":"","userId":0,"version":""}
/// userProfile : {"account":"","accountStatus":"","age":0,"bornDay":0,"bornMonth":0,"bornYear":0,"countryCode":"","countryId":0,"countryName":"","createTime":0,"del":false,"freezingTime":0,"id":0,"originSys":"","ownSpecialId":{"account":"","expiredTime":0},"sameRegion":false,"sysOriginChild":"","useProps":[{"expireTime":0,"propsResources":{"amount":0.0,"code":"","cover":"","expand":"","id":0,"name":"","sourceUrl":"","type":""},"userId":0}],"userAvatar":"","userNickname":"","userSex":0,"wearBadge":[{"animationUrl":"","badgeKey":"","badgeLevel":0,"badgeName":"","expireTime":0,"id":0,"milestone":0,"notSelectUrl":"","selectUrl":"","type":"","userId":0}]}
/// userSig : ""
class SocialChatLoginRes {
SocialChatLoginRes({
String? token,
SocialChatUserCredential? userCredential,
SocialChatUserProfile? userProfile,
String? userSig,
}) {
_token = token;
_userCredential = userCredential;
_userProfile = userProfile;
_userSig = userSig;
}
SocialChatLoginRes.fromJson(dynamic json) {
_token = json['token'];
_userCredential =
json['userCredential'] != null
? SocialChatUserCredential.fromJson(json['userCredential'])
: null;
_userProfile =
json['userProfile'] != null
? SocialChatUserProfile.fromJson(json['userProfile'])
: null;
_userSig = json['userSig'];
}
String? _token;
SocialChatUserCredential? _userCredential;
SocialChatUserProfile? _userProfile;
String? _userSig;
SocialChatLoginRes copyWith({
String? token,
SocialChatUserCredential? userCredential,
SocialChatUserProfile? userProfile,
String? userSig,
}) => SocialChatLoginRes(
token: token ?? _token,
userCredential: userCredential ?? _userCredential,
userProfile: userProfile ?? _userProfile,
userSig: userSig ?? _userSig,
);
String? get token => _token;
SocialChatUserCredential? get userCredential => _userCredential;
SocialChatUserProfile? get userProfile => _userProfile;
String? get userSig => _userSig;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['token'] = _token;
if (_userCredential != null) {
map['userCredential'] = _userCredential?.toJson();
}
if (_userProfile != null) {
map['userProfile'] = _userProfile?.toJson();
}
map['userSig'] = _userSig;
return map;
}
void setUserProfile(SocialChatUserProfile userInfo) {
_userProfile = userInfo;
}
}
/// account : ""
/// accountStatus : ""
/// age : 0
/// bornDay : 0
/// bornMonth : 0
/// bornYear : 0
/// countryCode : ""
/// countryId : 0
/// countryName : ""
/// createTime : 0
/// del : false
/// freezingTime : 0
/// id : 0
/// originSys : ""
/// ownSpecialId : {"account":"","expiredTime":0}
/// sameRegion : false
/// sysOriginChild : ""
/// useProps : [{"expireTime":0,"propsResources":{"amount":0.0,"code":"","cover":"","expand":"","id":0,"name":"","sourceUrl":"","type":""},"userId":0}]
/// userAvatar : ""
/// userNickname : ""
/// userSex : 0
/// wearBadge : [{"animationUrl":"","badgeKey":"","badgeLevel":0,"badgeName":"","expireTime":0,"id":0,"milestone":0,"notSelectUrl":"","selectUrl":"","type":"","userId":0}]
class SocialChatUserProfile {
SocialChatUserProfile({
String? account,
String? accountStatus,
num? age,
num? bornDay,
num? bornMonth,
num? bornYear,
String? countryCode,
String? countryId,
String? countryName,
num? createTime,
bool? del,
num? freezingTime,
String? id,
bool? firstRecharge,
num? charmLevel,
num? firstRechargeAmount,
num? wealthLevel,
num? heartbeatVal,
String? originSys,
OwnSpecialId? ownSpecialId,
String? vipLevel,
bool? sameRegion,
int? firstRechargeEndTime,
String? sysOriginChild,
List<UseProps>? useProps,
String? userAvatar,
String? roles,
String? inRoomId,
String? userNickname,
String? hobby,
String? familyId,
String? autograph,
num? userSex,
List<WearBadge>? wearBadge,
List<WearBadge>? wearHonor,
List<PersonPhoto>? backgroundPhotos,
List<PersonPhoto>? personalPhotos,
List<CPRes>? cpList,
List<CPRes>? closeFriendList,
bool? isCpRelation,
}) {
_account = account;
_accountStatus = accountStatus;
_age = age;
_bornDay = bornDay;
_inRoomId = inRoomId;
_bornMonth = bornMonth;
_bornYear = bornYear;
_countryCode = countryCode;
_countryId = countryId;
_countryName = countryName;
_createTime = createTime;
_del = del;
_freezingTime = freezingTime;
_id = id;
_originSys = originSys;
_charmLevel = charmLevel;
_firstRechargeAmount = firstRechargeAmount;
_wealthLevel = wealthLevel;
_heartbeatVal = heartbeatVal;
_ownSpecialId = ownSpecialId;
_vipLevel = vipLevel;
_sameRegion = sameRegion;
_isCpRelation = isCpRelation;
_firstRechargeEndTime = firstRechargeEndTime;
_firstRecharge = firstRecharge;
_sysOriginChild = sysOriginChild;
_useProps = useProps;
_userAvatar = userAvatar;
_roles = roles;
_userNickname = userNickname;
_hobby = hobby;
_familyId = familyId;
_autograph = autograph;
_userSex = userSex;
_wearBadge = wearBadge;
_wearHonor = wearHonor;
_backgroundPhotos = backgroundPhotos;
_personalPhotos = personalPhotos;
_cpList = cpList;
_closeFriendList = closeFriendList;
}
SocialChatUserProfile.fromJson(dynamic json) {
final sourceJson = json;
if (sourceJson is Map && sourceJson['userProfile'] is Map) {
json = sourceJson['userProfile'];
}
_account = json['account'];
_accountStatus = json['accountStatus'];
_age = json['age'];
_bornDay = json['bornDay'];
_inRoomId = json['inRoomId'];
_bornMonth = json['bornMonth'];
_bornYear = json['bornYear'];
_countryCode = json['countryCode'];
_countryId = json['countryId'];
_countryName = json['countryName'];
_createTime = json['createTime'];
_del = json['del'];
_freezingTime = json['freezingTime'];
_id = json['id'];
_originSys = json['originSys'];
_charmLevel = json['charmLevel'];
_firstRechargeAmount = json['firstRechargeAmount'];
_wealthLevel = json['wealthLevel'];
_heartbeatVal = json['heartbeatVal'];
_ownSpecialId =
json['ownSpecialId'] != null
? OwnSpecialId.fromJson(json['ownSpecialId'])
: null;
_vipLevel = _firstNonBlankString([
..._vipLevelHintValues(json),
..._vipLevelHintValues(sourceJson),
]);
_sameRegion = json['sameRegion'];
_isCpRelation = json['isCpRelation'];
_firstRechargeEndTime = json['firstRechargeEndTime'];
_firstRecharge = json['firstRecharge'];
_sysOriginChild = json['sysOriginChild'];
if (json['useProps'] != null) {
_useProps = [];
json['useProps'].forEach((v) {
_useProps?.add(UseProps.fromJson(v));
});
}
_userAvatar = json['userAvatar'] ?? json['avatar'];
_roles = json['roles'];
_userNickname = json['userNickname'];
_hobby = json['hobby'];
_familyId = json['familyId'];
_autograph = json['autograph'];
_userSex = json['userSex'];
if (json['wearBadge'] != null) {
_wearBadge = [];
json['wearBadge'].forEach((v) {
_wearBadge?.add(WearBadge.fromJson(v));
});
}
if (json['wearHonor'] != null) {
_wearHonor = [];
json['wearHonor'].forEach((v) {
_wearHonor?.add(WearBadge.fromJson(v));
});
}
if (json['backgroundPhotos'] != null) {
_backgroundPhotos = [];
json['backgroundPhotos'].forEach((v) {
_backgroundPhotos?.add(PersonPhoto.fromJson(v));
});
}
if (json['personalPhotos'] != null) {
_personalPhotos = [];
json['personalPhotos'].forEach((v) {
_personalPhotos?.add(PersonPhoto.fromJson(v));
});
}
final sourceCpList = sourceJson is Map ? sourceJson['cpList'] : null;
final sourceCloseFriendList =
sourceJson is Map ? sourceJson['closeFriendList'] : null;
final cpListJson = json['cpList'] ?? sourceCpList;
final closeFriendListJson =
json['closeFriendList'] ?? sourceCloseFriendList;
if (cpListJson != null) {
_cpList = [];
cpListJson.forEach((v) {
_cpList?.add(CPRes.fromJson(v));
});
}
if (closeFriendListJson != null) {
_closeFriendList = [];
closeFriendListJson.forEach((v) {
_closeFriendList?.add(CPRes.fromJson(v));
});
}
}
String? _account;
String? _accountStatus;
num? _age;
num? _bornDay;
num? _bornMonth;
num? _bornYear;
String? _countryCode;
String? _countryId;
String? _inRoomId;
String? _countryName;
num? _createTime;
bool? _del;
num? _freezingTime;
String? _id;
String? _originSys;
num? _charmLevel;
num? _firstRechargeAmount;
num? _wealthLevel;
num? _heartbeatVal;
OwnSpecialId? _ownSpecialId;
String? _vipLevel;
bool? _sameRegion;
bool? _isCpRelation;
int? _firstRechargeEndTime;
bool? _firstRecharge;
String? _sysOriginChild;
List<UseProps>? _useProps;
String? _userAvatar;
String? _roles;
String? _userNickname;
String? _hobby;
String? _familyId;
String? _autograph;
num? _userSex;
List<WearBadge>? _wearBadge;
List<WearBadge>? _wearHonor;
List<PersonPhoto>? _backgroundPhotos;
List<PersonPhoto>? _personalPhotos;
List<CPRes>? _cpList;
List<CPRes>? _closeFriendList;
SocialChatUserProfile copyWith({
String? account,
String? accountStatus,
num? age,
num? bornDay,
num? bornMonth,
num? bornYear,
String? countryCode,
String? countryId,
String? countryName,
num? createTime,
bool? del,
num? freezingTime,
String? id,
String? originSys,
String? inRoomId,
num? charmLevel,
num? firstRechargeAmount,
num? wealthLevel,
num? heartbeatVal,
OwnSpecialId? ownSpecialId,
String? vipLevel,
bool? sameRegion,
bool? isCpRelation,
int? firstRechargeEndTime,
bool? firstRecharge,
String? sysOriginChild,
List<UseProps>? useProps,
String? userAvatar,
String? roles,
String? userNickname,
String? hobby,
String? familyId,
String? autograph,
num? userSex,
List<WearBadge>? wearBadge,
List<WearBadge>? wearHonor,
List<PersonPhoto>? backgroundPhotos,
List<PersonPhoto>? personalPhotos,
List<CPRes>? cpList,
List<CPRes>? closeFriendList,
}) => SocialChatUserProfile(
account: account ?? _account,
accountStatus: accountStatus ?? _accountStatus,
age: age ?? _age,
bornDay: bornDay ?? _bornDay,
bornMonth: bornMonth ?? _bornMonth,
bornYear: bornYear ?? _bornYear,
inRoomId: inRoomId ?? _inRoomId,
countryCode: countryCode ?? _countryCode,
countryId: countryId ?? _countryId,
countryName: countryName ?? _countryName,
createTime: createTime ?? _createTime,
del: del ?? _del,
freezingTime: freezingTime ?? _freezingTime,
id: id ?? _id,
originSys: originSys ?? _originSys,
charmLevel: charmLevel ?? _charmLevel,
firstRechargeAmount: firstRechargeAmount ?? _firstRechargeAmount,
wealthLevel: wealthLevel ?? _wealthLevel,
heartbeatVal: heartbeatVal ?? _heartbeatVal,
ownSpecialId: ownSpecialId ?? _ownSpecialId,
vipLevel: vipLevel ?? _vipLevel,
sameRegion: sameRegion ?? _sameRegion,
isCpRelation: isCpRelation ?? _isCpRelation,
firstRechargeEndTime: firstRechargeEndTime ?? _firstRechargeEndTime,
firstRecharge: firstRecharge ?? _firstRecharge,
sysOriginChild: sysOriginChild ?? _sysOriginChild,
useProps: useProps ?? _useProps,
userAvatar: userAvatar ?? _userAvatar,
roles: roles ?? _roles,
userNickname: userNickname ?? _userNickname,
hobby: hobby ?? _hobby,
familyId: familyId ?? _familyId,
autograph: autograph ?? _autograph,
userSex: userSex ?? _userSex,
wearBadge: wearBadge ?? _wearBadge,
wearHonor: wearHonor ?? _wearHonor,
backgroundPhotos: backgroundPhotos ?? _backgroundPhotos,
personalPhotos: personalPhotos ?? _personalPhotos,
cpList: cpList ?? _cpList,
closeFriendList: closeFriendList ?? _closeFriendList,
);
String? get account => _account;
String? get inRoomId => _inRoomId;
String? get accountStatus => _accountStatus;
num? get age => (_age ?? 0) < 1 ? 18 : _age;
num? get bornDay => _bornDay;
num? get bornMonth => _bornMonth;
num? get bornYear => _bornYear;
String? get countryCode => _countryCode;
String? get countryId => _countryId;
String? get countryName => _countryName;
num? get createTime => _createTime;
bool? get del => _del;
num? get freezingTime => _freezingTime;
String? get id => _id;
String? get originSys => _originSys;
num? get charmLevel => _charmLevel;
num? get firstRechargeAmount => _firstRechargeAmount;
num? get wealthLevel => _wealthLevel;
num? get heartbeatVal => _heartbeatVal;
OwnSpecialId? get ownSpecialId => _ownSpecialId;
String? get vipLevel => _vipLevel;
bool? get sameRegion => _sameRegion;
bool? get isCpRelation => _isCpRelation;
int? get firstRechargeEndTime => _firstRechargeEndTime;
bool? get firstRecharge => _firstRecharge;
String? get sysOriginChild => _sysOriginChild;
List<UseProps>? get useProps => _useProps;
String? get userAvatar => _userAvatar;
String? get roles => _roles;
String? get userNickname => _userNickname;
String? get hobby => _hobby;
String? get familyId => _familyId;
String? get autograph => _autograph;
num? get userSex => _userSex;
List<WearBadge>? get wearBadge => _wearBadge;
List<WearBadge>? get wearHonor => _wearHonor;
List<PersonPhoto>? get backgroundPhotos => _backgroundPhotos;
List<PersonPhoto>? get personalPhotos => _personalPhotos;
List<CPRes>? get cpList => _cpList;
List<CPRes>? get closeFriendList => _closeFriendList;
void setFamilyId(String? familyId) {
_familyId = familyId;
AccountStorage().setCurrentUser(AccountStorage().getCurrentUser()!);
}
///清除荣耀信息避免发送消息个人信息数据太多超12kb,注意这个只在房间发消息的时候才用,因为荣耀这个属性数据在房间里面不用展示
void cleanWearHonor() {
_wearHonor?.clear();
}
///同上
void cleanWearBadge() {
_wearBadge?.clear();
}
void cleanUseProps() {
_useProps?.clear();
}
void cleanPhotos() {
_backgroundPhotos?.clear();
_personalPhotos?.clear();
_cpList?.clear();
_closeFriendList?.clear();
}
PropsResources? getHeaddress() {
PropsResources? pr;
_useProps?.forEach((value) {
final resource = value.propsResources;
if (socialChatIsAvatarFrameResource(resource)) {
pr = resource;
}
});
return pr;
}
PropsResources? getChatBox() {
PropsResources? pr;
_useProps?.forEach((value) {
if (value.propsResources?.type == SCPropsType.CHAT_BUBBLE.name) {
pr = value.propsResources;
}
});
return pr;
}
PropsResources? getFloatPicture() {
PropsResources? pr;
_useProps?.forEach((value) {
if (value.propsResources?.type == SCPropsType.FLOAT_PICTURE.name) {
pr = value.propsResources;
}
});
return pr;
}
PropsResources? getVipBadge() {
PropsResources? pr;
_useProps?.forEach((value) {
if (value.propsResources?.type == SCPropsType.BADGE.name) {
pr = value.propsResources;
}
});
return pr;
}
PropsResources? getMountains() {
PropsResources? pr;
_useProps?.forEach((value) {
if (value.propsResources?.type == SCPropsType.RIDE.name) {
pr = value.propsResources;
}
});
return pr;
}
PropsResources? getVIP() {
PropsResources? pr;
_useProps?.forEach((value) {
if (value.propsResources?.type == SCPropsType.NOBLE_VIP.name) {
pr = value.propsResources;
}
});
return pr;
}
PropsResources? getDataCard() {
PropsResources? pr;
_useProps?.forEach((value) {
if (value.propsResources?.type == SCPropsType.DATA_CARD.name) {
pr = value.propsResources;
}
});
return pr;
}
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['account'] = _account;
map['accountStatus'] = _accountStatus;
map['age'] = _age;
map['bornDay'] = _bornDay;
map['bornMonth'] = _bornMonth;
map['bornYear'] = _bornYear;
map['countryCode'] = _countryCode;
map['countryId'] = _countryId;
map['countryName'] = _countryName;
map['createTime'] = _createTime;
map['del'] = _del;
map['freezingTime'] = _freezingTime;
map['id'] = _id;
map['originSys'] = _originSys;
map['charmLevel'] = _charmLevel;
map['firstRechargeAmount'] = _firstRechargeAmount;
map['wealthLevel'] = _wealthLevel;
map['heartbeatVal'] = _heartbeatVal;
if (_ownSpecialId != null) {
map['ownSpecialId'] = _ownSpecialId?.toJson();
}
if (_vipLevel != null) {
map['vipLevel'] = _vipLevel;
}
map['sameRegion'] = _sameRegion;
map['isCpRelation'] = _isCpRelation;
map['firstRecharge'] = _firstRecharge;
map['firstRechargeEndTime'] = _firstRechargeEndTime;
map['sysOriginChild'] = _sysOriginChild;
if (_useProps != null) {
map['useProps'] = _useProps?.map((v) => v.toJson()).toList();
}
map['userAvatar'] = _userAvatar;
map['roles'] = _roles;
map['userNickname'] = _userNickname;
map['hobby'] = _hobby;
map['familyId'] = _familyId;
map['autograph'] = _autograph;
map['userSex'] = _userSex;
if (_wearBadge != null) {
map['wearBadge'] = _wearBadge?.map((v) => v.toJson()).toList();
}
if (_wearHonor != null) {
map['wearHonor'] = _wearHonor?.map((v) => v.toJson()).toList();
}
return map;
}
///获取Id有靓号显示靓号
String getID() {
String uid = account ?? "";
if (hasSpecialId()) {
uid = _ownSpecialId?.account ?? "";
}
return uid;
}
///是否有靓号
bool hasSpecialId() {
if (_ownSpecialId != null) {
if ((_ownSpecialId?.expiredTime ?? 0) >
DateTime.now().millisecondsSinceEpoch) {
return true;
}
}
return false;
}
int get vipLevelForColoredId {
final hasExplicitVipLevel = _vipLevel?.trim().isNotEmpty ?? false;
final explicitLevel = _parseVipLevelForColoredId(_vipLevel) ?? 0;
if (hasExplicitVipLevel && explicitLevel <= 0) {
return 0;
}
if (explicitLevel > 0) {
return explicitLevel;
}
final vipResource = getVIP();
final resourceLevel =
_parseVipLevelForColoredId(
vipResource?.name,
allowPlainNumber: false,
) ??
_parseVipLevelForColoredId(
vipResource?.code,
allowPlainNumber: false,
allowTrailingNumber: false,
);
if ((resourceLevel ?? 0) > 0) {
return resourceLevel!;
}
return vipResource == null ? 0 : 1;
}
int get vipVisualResourceLevelForColoredId {
for (final resource in [
getVipBadge(),
getHeaddress(),
getChatBox(),
getFloatPicture(),
getDataCard(),
getMountains(),
]) {
final level = _vipLevelFromVisualResource(resource);
if ((level ?? 0) > 0) {
return level!;
}
}
return 0;
}
/// ID 数字渐变字的 VIP 条件。
/// 新 VIP 接口优先读等级字段;旧数据继续兼容 useProps 里的 NOBLE_VIP。
bool hasVipPrivilegeForColoredId() {
return vipLevelForColoredId > 0;
}
bool hasVipVisualResourceForColoredId() {
return vipVisualResourceLevelForColoredId > 0;
}
bool shouldShowColoredSpecialIdText() {
return hasVipPrivilegeForColoredId() || hasVipVisualResourceForColoredId();
}
void setHeartbeatVal(num? heartbeatVal) {
_heartbeatVal = (_heartbeatVal ?? 0) + (heartbeatVal ?? 0);
}
}
String? socialChatVipLevelHintFromJson(dynamic json) {
return _firstNonBlankString(_vipLevelHintValues(json));
}
SocialChatUserProfile? socialChatProfileWithVipLevelHint(
SocialChatUserProfile? profile,
dynamic json,
) {
final vipLevel = socialChatVipLevelHintFromJson(json);
if (profile == null || vipLevel == null) {
return profile;
}
return profile.copyWith(vipLevel: vipLevel);
}
SocialChatUserProfile? socialChatUserProfileFromJsonWithVipHint(
dynamic json, {
String userProfileKey = 'userProfile',
}) {
if (json == null) {
return null;
}
if (json is Map && json[userProfileKey] != null) {
return socialChatProfileWithVipLevelHint(
SocialChatUserProfile.fromJson(
userProfileKey == 'userProfile'
? json
: <String, dynamic>{'userProfile': json[userProfileKey]},
),
json,
);
}
return SocialChatUserProfile.fromJson(json);
}
Iterable<dynamic> _vipLevelHintValues(dynamic json) sync* {
if (json is! Map) {
return;
}
yield json['vipLevel'];
yield json['svipLevel'];
yield json['sVipLevel'];
yield json['userSVipLevel'];
yield json['supperVip'];
yield json['superVip'];
yield json['nobleVipLevel'];
yield json['vipLevelCode'];
yield json['levelCode'];
yield _nestedVipLevel(json['vipStatus']);
yield _nestedVipLevel(json['vipState']);
yield _nestedVipLevel(json['vip']);
final nestedProfile = json['userProfile'];
if (nestedProfile is Map) {
yield* _vipLevelHintValues(nestedProfile);
}
}
String? _firstNonBlankString(Iterable<dynamic> values) {
for (final value in values) {
final text = value?.toString().trim();
if (text != null && text.isNotEmpty) {
return text;
}
}
return null;
}
dynamic _nestedVipLevel(dynamic value) {
if (value is Map) {
final active = value['active'];
if (active == false || active?.toString().trim().toLowerCase() == 'false') {
return '0';
}
return value['level'] ??
value['vipLevel'] ??
value['userSVipLevel'] ??
value['supperVip'] ??
value['levelCode'];
}
return null;
}
int? _vipLevelFromVisualResource(PropsResources? resource) {
if (resource == null) {
return null;
}
return _parseVipLevelForColoredId(resource.name, allowPlainNumber: false) ??
_parseVipLevelForColoredId(resource.code, allowPlainNumber: false) ??
_parseVipLevelForColoredId(resource.cover, allowPlainNumber: false) ??
_parseVipLevelForColoredId(resource.sourceUrl, allowPlainNumber: false) ??
_parseVipLevelForColoredId(
resource.roomOpenedUrl,
allowPlainNumber: false,
) ??
_parseVipLevelForColoredId(
resource.roomSendCoverUrl,
allowPlainNumber: false,
);
}
int? _parseVipLevelForColoredId(
dynamic value, {
bool allowPlainNumber = true,
bool allowTrailingNumber = true,
}) {
final text = value?.toString().trim();
if (text == null || text.isEmpty) {
return null;
}
if (allowPlainNumber) {
final plainLevel = int.tryParse(text);
if ((plainLevel ?? 0) > 0) {
return plainLevel;
}
}
final vipLevelMatch = RegExp(
r'(?:S?VIP|NOBLE[_\s-]*VIP)[^\d]*([1-9]\d*)',
caseSensitive: false,
).firstMatch(text);
if (vipLevelMatch != null) {
return int.tryParse(vipLevelMatch.group(1) ?? '');
}
if (allowTrailingNumber) {
final trailingLevelMatch = RegExp(r'([1-9]\d*)$').firstMatch(text);
if (trailingLevelMatch != null) {
return int.tryParse(trailingLevelMatch.group(1) ?? '');
}
}
return null;
}
/// animationUrl : ""
/// badgeKey : ""
/// badgeLevel : 0
/// badgeName : ""
/// expireTime : 0
/// id : 0
/// milestone : 0
/// notSelectUrl : ""
/// selectUrl : ""
/// type : ""
/// userId : 0
class WearBadge {
WearBadge({
String? animationUrl,
String? badgeKey,
num? badgeLevel,
String? badgeName,
int? expireTime,
String? id,
String? milestone,
String? notSelectUrl,
String? selectUrl,
String? sourceType,
String? type,
String? userId,
int? updateTime,
String? updatedAt,
bool? use,
}) {
_animationUrl = animationUrl;
_badgeKey = badgeKey;
_badgeLevel = badgeLevel;
_badgeName = badgeName;
_expireTime = expireTime;
_id = id;
_use = use;
_milestone = milestone;
_notSelectUrl = notSelectUrl;
_selectUrl = selectUrl;
_sourceType = sourceType;
_type = type;
_userId = userId;
_updateTime = updateTime;
_updatedAt = updatedAt;
}
WearBadge.fromJson(dynamic json) {
if (json is! Map) {
return;
}
_animationUrl = _stringValue(json['animationUrl']);
_badgeKey = _stringValue(json['badgeKey']);
_badgeLevel = _numValue(json['badgeLevel'] ?? json['level']);
_badgeName = _stringValue(
json['badgeName'] ?? json['name'] ?? json['displayName'],
);
_expireTime = _intValue(json['expireTime'] ?? json['expireAt']);
_id = _stringValue(json['id'] ?? json['badgeId']);
_use = _boolValue(json['use']);
_milestone = _stringValue(json['milestone']);
_notSelectUrl = _stringValue(json['notSelectUrl']);
_selectUrl = _stringValue(json['url'] ?? json['selectUrl']);
final rawType = _stringValue(json['type']);
_sourceType =
_stringValue(json['sourceType']) ?? _sourceTypeFromType(rawType);
_type = rawType;
_userId = _stringValue(json['userId']);
_updateTime = _intValue(
json['updateTime'] ?? json['updatedAt'] ?? json['createTime'],
);
_updatedAt = _stringValue(json['updatedAt']);
}
String? _animationUrl;
String? _badgeKey;
num? _badgeLevel;
String? _badgeName;
int? _expireTime;
String? _id;
bool? _use;
String? _milestone;
String? _notSelectUrl;
String? _selectUrl;
String? _sourceType;
String? _type;
String? _userId;
int? _updateTime;
String? _updatedAt;
WearBadge copyWith({
String? animationUrl,
String? badgeKey,
num? badgeLevel,
String? badgeName,
int? expireTime,
String? id,
bool? use,
String? milestone,
String? notSelectUrl,
String? selectUrl,
String? sourceType,
String? type,
String? userId,
int? updateTime,
String? updatedAt,
}) => WearBadge(
animationUrl: animationUrl ?? _animationUrl,
badgeKey: badgeKey ?? _badgeKey,
badgeLevel: badgeLevel ?? _badgeLevel,
badgeName: badgeName ?? _badgeName,
expireTime: expireTime ?? _expireTime,
id: id ?? _id,
use: use ?? _use,
milestone: milestone ?? _milestone,
notSelectUrl: notSelectUrl ?? _notSelectUrl,
selectUrl: selectUrl ?? _selectUrl,
sourceType: sourceType ?? _sourceType,
type: type ?? _type,
userId: userId ?? _userId,
updateTime: updateTime ?? _updateTime,
updatedAt: updatedAt ?? _updatedAt,
);
String? get animationUrl => _animationUrl;
String? get badgeKey => _badgeKey;
num? get badgeLevel => _badgeLevel;
bool? get use => _use;
String? get badgeName => _badgeName;
int? get expireTime => _expireTime;
String? get id => _id;
String? get milestone => _milestone;
String? get notSelectUrl => _notSelectUrl;
String? get selectUrl => _selectUrl;
String? get sourceType => _sourceType;
String? get type => _type;
String? get userId => _userId;
int? get updateTime => _updateTime;
String? get updatedAt => _updatedAt;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['animationUrl'] = _animationUrl;
map['badgeKey'] = _badgeKey;
map['badgeLevel'] = _badgeLevel;
map['badgeName'] = _badgeName;
map['expireTime'] = _expireTime;
map['id'] = _id;
map['use'] = _use;
map['milestone'] = _milestone;
map['notSelectUrl'] = _notSelectUrl;
map['selectUrl'] = _selectUrl;
map['sourceType'] = _sourceType;
map['type'] = _type;
map['userId'] = _userId;
map['updateTime'] = _updateTime;
map['updatedAt'] = _updatedAt;
return map;
}
static String? _stringValue(dynamic value) {
final text = value?.toString().trim();
return text == null || text.isEmpty ? null : text;
}
static String? _sourceTypeFromType(String? type) {
final normalized = type?.trim().toUpperCase();
if (normalized == "VIP" ||
normalized == "ACTIVITY" ||
normalized == "ACHIEVEMENT") {
return normalized;
}
return null;
}
static int? _intValue(dynamic value) {
if (value is int) {
return value;
}
if (value is num) {
return value.toInt();
}
return int.tryParse(value?.toString() ?? "");
}
static num? _numValue(dynamic value) {
if (value is num) {
return value;
}
return num.tryParse(value?.toString() ?? "");
}
static bool? _boolValue(dynamic value) {
if (value is bool) {
return value;
}
if (value is num) {
return value != 0;
}
final text = value?.toString().trim().toLowerCase();
if (text == "true" || text == "1") {
return true;
}
if (text == "false" || text == "0") {
return false;
}
return null;
}
}
class PersonPhoto {
PersonPhoto({String? url, num? status}) {
_url = url;
_status = status;
}
PersonPhoto.fromJson(dynamic json) {
_url = json['url'];
_status = json['status'];
}
String? _url;
num? _status;
PersonPhoto copyWith({String? url, num? status}) =>
PersonPhoto(url: url ?? _url, status: status ?? _status);
String? get url => _url;
num? get status => _status;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['url'] = _url;
map['status'] = _status;
return map;
}
}
class CPRes {
CPRes({
String? meUserId,
String? meAccount,
String? meUserAvatar,
String? meUserNickname,
String? cpUserId,
String? cpUserNickname,
String? cpAccount,
String? cpUserAvatar,
String? days,
String? firstDay,
double? cpValue,
String? relationType,
String? status,
String? levelText,
int? dismissEndTime,
int? dismissRemainSeconds,
int? dismissCost,
}) {
_meUserId = meUserId;
_meAccount = meAccount;
_meUserAvatar = meUserAvatar;
_meUserNickname = meUserNickname;
_cpUserId = cpUserId;
_cpUserNickname = cpUserNickname;
_cpAccount = cpAccount;
_cpUserAvatar = cpUserAvatar;
_days = days;
_firstDay = firstDay;
_cpValue = cpValue;
_relationType = relationType;
_status = status;
_levelText = levelText;
_dismissEndTime = dismissEndTime;
_dismissRemainSeconds = dismissRemainSeconds;
_dismissCost = dismissCost;
}
CPRes.fromJson(dynamic json) {
final source = json is Map ? json : const <String, dynamic>{};
final meProfileJson = source['meUserProfile'];
final cpProfileJson = source['cpUserProfile'];
final meProfile =
meProfileJson is Map
? SocialChatUserProfile.fromJson(meProfileJson)
: null;
final cpProfile =
cpProfileJson is Map
? SocialChatUserProfile.fromJson(cpProfileJson)
: null;
_meUserId = _asString(source['meUserId']) ?? meProfile?.id;
_meAccount = _asString(source['meAccount']) ?? meProfile?.account;
_meUserAvatar = _asString(source['meUserAvatar']) ?? meProfile?.userAvatar;
_meUserNickname =
_asString(source['meUserNickname']) ?? meProfile?.userNickname;
_cpUserId = _asString(source['cpUserId']) ?? cpProfile?.id;
_cpUserNickname =
_asString(source['cpUserNickname']) ?? cpProfile?.userNickname;
_cpAccount = _asString(source['cpAccount']) ?? cpProfile?.account;
_cpUserAvatar = _asString(source['cpUserAvatar']) ?? cpProfile?.userAvatar;
_days = _asString(source['days']);
_firstDay = _asString(source['firstDay']);
_cpValue = _asDouble(source['cpValue']);
_relationType = _asString(
_firstValue(source, const [
'relationType',
'relation_type',
'cpRelationType',
'cp_relation_type',
'relationshipType',
'relationship_type',
'relation',
'cpType',
'cp_type',
]),
);
_status = _asString(source['status']);
_levelText = _asString(
source['levelText'] ??
source['levelName'] ??
source['level'] ??
source['cpLevel'] ??
source['cabinLevel'] ??
source['lv'],
);
_dismissEndTime = _asInt(source['dismissEndTime']);
_dismissRemainSeconds = _asInt(source['dismissRemainSeconds']);
_dismissCost = _asInt(
_firstValue(source, const [
'dismissCost',
'dismissGold',
'dismissCoins',
'dismissCoin',
'cancelCost',
'cancelGold',
'removeCost',
'partWaysCost',
'consumeGold',
'goldCost',
'cost',
'coins',
'priceGold',
]),
);
}
static dynamic _firstValue(Map source, List<String> keys) {
for (final key in keys) {
if (source.containsKey(key) && source[key] != null) {
return source[key];
}
}
return null;
}
static String? _asString(dynamic value) {
final text = value?.toString().trim();
return text == null || text.isEmpty ? null : text;
}
static double? _asDouble(dynamic value) {
if (value is num) {
return value.toDouble();
}
return double.tryParse(value?.toString() ?? '');
}
static int? _asInt(dynamic value) {
if (value is int) {
return value;
}
if (value is num) {
return value.toInt();
}
return int.tryParse(value?.toString() ?? '');
}
String? _meUserId;
String? _meAccount;
String? _meUserAvatar;
String? _meUserNickname;
String? _cpUserId;
String? _cpUserNickname;
String? _cpAccount;
String? _cpUserAvatar;
String? _days;
String? _firstDay;
double? _cpValue;
String? _relationType;
String? _status;
String? _levelText;
int? _dismissEndTime;
int? _dismissRemainSeconds;
int? _dismissCost;
String? get meUserId => _meUserId;
String? get meAccount => _meAccount;
String? get meUserAvatar => _meUserAvatar;
String? get meUserNickname => _meUserNickname;
String? get cpUserId => _cpUserId;
String? get cpUserNickname => _cpUserNickname;
String? get cpAccount => _cpAccount;
String? get cpUserAvatar => _cpUserAvatar;
String? get days => _days;
String? get firstDay => _firstDay;
double? get cpValue => _cpValue;
String? get relationType => _relationType;
String? get status => _status;
String? get levelText => _levelText;
int? get dismissEndTime => _dismissEndTime;
int? get dismissRemainSeconds => _dismissRemainSeconds;
int? get dismissCost => _dismissCost;
CPRes copyWith({
String? relationType,
double? cpValue,
String? days,
String? levelText,
int? dismissCost,
}) {
return CPRes(
meUserId: _meUserId,
meAccount: _meAccount,
meUserAvatar: _meUserAvatar,
meUserNickname: _meUserNickname,
cpUserId: _cpUserId,
cpUserNickname: _cpUserNickname,
cpAccount: _cpAccount,
cpUserAvatar: _cpUserAvatar,
days: days ?? _days,
firstDay: _firstDay,
cpValue: cpValue ?? _cpValue,
relationType: relationType ?? _relationType,
status: _status,
levelText: levelText ?? _levelText,
dismissEndTime: _dismissEndTime,
dismissRemainSeconds: _dismissRemainSeconds,
dismissCost: dismissCost ?? _dismissCost,
);
}
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['meUserId'] = _meUserId;
map['meAccount'] = _meAccount;
map['meUserAvatar'] = _meUserAvatar;
map['meUserNickname'] = _meUserNickname;
map['cpUserId'] = _cpUserId;
map['cpUserNickname'] = _cpUserNickname;
map['cpAccount'] = _cpAccount;
map['cpUserAvatar'] = _cpUserAvatar;
map['days'] = _days;
map['firstDay'] = _firstDay;
map['cpValue'] = _cpValue;
map['relationType'] = _relationType;
map['status'] = _status;
map['levelText'] = _levelText;
map['dismissEndTime'] = _dismissEndTime;
map['dismissRemainSeconds'] = _dismissRemainSeconds;
map['dismissCost'] = _dismissCost;
return map;
}
}
class SCCpCabinRes {
SCCpCabinRes({
int? cpVal,
int? blessVal,
int? cpValLastMonth,
int? historyCpValMax,
CPRes? cpPairUserProfileCO,
List<dynamic>? cpCabinConfigCO,
dynamic currentCpCabinConfigCO,
dynamic userCpCabinSpecial,
bool? checkSelfCabin,
int? dismissCost,
}) {
_cpVal = cpVal;
_blessVal = blessVal;
_cpValLastMonth = cpValLastMonth;
_historyCpValMax = historyCpValMax;
_cpPairUserProfileCO = cpPairUserProfileCO;
_cpCabinConfigCO = cpCabinConfigCO;
_currentCpCabinConfigCO = currentCpCabinConfigCO;
_userCpCabinSpecial = userCpCabinSpecial;
_checkSelfCabin = checkSelfCabin;
_dismissCost = dismissCost;
}
SCCpCabinRes.fromJson(dynamic json) {
final source = json is Map ? json : const <String, dynamic>{};
_cpVal = CPRes._asInt(source['cpVal']);
_blessVal = CPRes._asInt(source['blessVal']);
_cpValLastMonth = CPRes._asInt(source['cpValLastMonth']);
_historyCpValMax = CPRes._asInt(source['historyCpValMax']);
final pair = source['cpPairUserProfileCO'];
_cpPairUserProfileCO = pair is Map ? CPRes.fromJson(pair) : null;
final configs = source['cpCabinConfigCO'];
_cpCabinConfigCO = configs is List ? List<dynamic>.from(configs) : null;
_currentCpCabinConfigCO = source['currentCpCabinConfigCO'];
_userCpCabinSpecial = source['userCpCabinSpecial'];
_checkSelfCabin =
source['checkSelfCabin'] is bool
? source['checkSelfCabin'] as bool
: null;
_dismissCost = CPRes._asInt(
CPRes._firstValue(source, const [
'dismissCost',
'dismissGold',
'dismissCoins',
'dismissCoin',
'cancelCost',
'cancelGold',
'removeCost',
'partWaysCost',
'consumeGold',
'goldCost',
'cost',
'coins',
'priceGold',
]),
);
}
int? _cpVal;
int? _blessVal;
int? _cpValLastMonth;
int? _historyCpValMax;
CPRes? _cpPairUserProfileCO;
List<dynamic>? _cpCabinConfigCO;
dynamic _currentCpCabinConfigCO;
dynamic _userCpCabinSpecial;
bool? _checkSelfCabin;
int? _dismissCost;
int? get cpVal => _cpVal;
int? get blessVal => _blessVal;
int? get cpValLastMonth => _cpValLastMonth;
int? get historyCpValMax => _historyCpValMax;
CPRes? get cpPairUserProfileCO => _cpPairUserProfileCO;
List<dynamic>? get cpCabinConfigCO => _cpCabinConfigCO;
dynamic get currentCpCabinConfigCO => _currentCpCabinConfigCO;
dynamic get userCpCabinSpecial => _userCpCabinSpecial;
bool? get checkSelfCabin => _checkSelfCabin;
int? get dismissCost => _dismissCost;
}
class SCCpCabinValueRes {
SCCpCabinValueRes({int? cpVal, int? blessVal}) {
_cpVal = cpVal;
_blessVal = blessVal;
}
SCCpCabinValueRes.fromJson(dynamic json) {
final source = json is Map ? json : const <String, dynamic>{};
_cpVal = CPRes._asInt(source['cpVal']);
_blessVal = CPRes._asInt(source['blessVal']);
}
int? _cpVal;
int? _blessVal;
int? get cpVal => _cpVal;
int? get blessVal => _blessVal;
}
/// expireTime : 0
/// propsResources : {"amount":0.0,"code":"","cover":"","expand":"","id":0,"name":"","sourceUrl":"","type":""}
/// userId : 0
class UseProps {
UseProps({
bool? allowGive,
String? expireTime,
PropsResources? propsResources,
String? userId,
}) {
_allowGive = allowGive;
_expireTime = expireTime;
_propsResources = propsResources;
_userId = userId;
}
UseProps.fromJson(dynamic json) {
_allowGive = json['allowGive'];
_expireTime = json['expireTime'];
_propsResources =
json['propsResources'] != null
? PropsResources.fromJson(json['propsResources'])
: null;
_userId = json['userId'];
}
bool? _allowGive;
String? _expireTime;
PropsResources? _propsResources;
String? _userId;
UseProps copyWith({
bool? allowGive,
String? expireTime,
PropsResources? propsResources,
String? userId,
}) => UseProps(
allowGive: allowGive ?? _allowGive,
expireTime: expireTime ?? _expireTime,
propsResources: propsResources ?? _propsResources,
userId: userId ?? _userId,
);
bool? get allowGive => _allowGive;
String? get expireTime => _expireTime;
PropsResources? get propsResources => _propsResources;
String? get userId => _userId;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['allowGive'] = _allowGive;
map['expireTime'] = _expireTime;
if (_propsResources != null) {
map['propsResources'] = _propsResources?.toJson();
}
map['userId'] = _userId;
return map;
}
void setPropsResources(PropsResources? pr) {
_propsResources = pr;
}
}
/// amount : 0.0
/// code : ""
/// cover : ""
/// expand : ""
/// id : 0
/// name : ""
/// sourceUrl : ""
/// type : ""
class PropsResources {
PropsResources({
num? amount,
String? code,
String? cover,
num? createTime,
bool? del,
String? expand,
String? id,
String? imNotOpenedUrl,
String? imOpenedUrl,
String? imOpenedUrlTwo,
String? imSendCoverUrl,
String? name,
String? roomNotOpenedUrl,
String? roomOpenedUrl,
String? roomSendCoverUrl,
String? sourceUrl,
String? sysOrigin,
String? type,
num? updateTime,
}) {
_amount = amount;
_code = code;
_cover = cover;
_createTime = createTime;
_del = del;
_expand = expand;
_id = id;
_imNotOpenedUrl = imNotOpenedUrl;
_imOpenedUrl = imOpenedUrl;
_imOpenedUrlTwo = imOpenedUrlTwo;
_imSendCoverUrl = imSendCoverUrl;
_name = name;
_roomNotOpenedUrl = roomNotOpenedUrl;
_roomOpenedUrl = roomOpenedUrl;
_roomSendCoverUrl = roomSendCoverUrl;
_sourceUrl = sourceUrl;
_sysOrigin = sysOrigin;
_type = type;
_updateTime = updateTime;
}
PropsResources.fromJson(dynamic json) {
if (json is! Map) {
return;
}
_amount = json['amount'];
_code = json['code'];
_cover = json['cover'] ?? json['coverUrl'];
_createTime = json['createTime'];
_del = json['del'];
_expand = json['expand'];
_id = json['id'] ?? json['resourceId'];
_imNotOpenedUrl = json['imNotOpenedUrl'];
_imOpenedUrl = json['imOpenedUrl'];
_imOpenedUrlTwo = json['imOpenedUrlTwo'];
_imSendCoverUrl = json['imSendCoverUrl'];
_name = json['name'];
_roomNotOpenedUrl = json['roomNotOpenedUrl'];
_roomOpenedUrl = json['roomOpenedUrl'];
_roomSendCoverUrl = json['roomSendCoverUrl'];
_sysOrigin = json['sysOrigin'];
_type = json['type'];
_sourceUrl =
_isAvatarFrameType(_type)
? json['sourceUrl']
: json['sourceUrl'] ?? json['resourceUrl'] ?? json['url'];
_updateTime = json['updateTime'];
}
num? _amount;
String? _code;
String? _cover;
num? _createTime;
bool? _del;
String? _expand;
String? _id;
String? _imNotOpenedUrl;
String? _imOpenedUrl;
String? _imOpenedUrlTwo;
String? _imSendCoverUrl;
String? _name;
String? _roomNotOpenedUrl;
String? _roomOpenedUrl;
String? _roomSendCoverUrl;
String? _sourceUrl;
String? _sysOrigin;
String? _type;
num? _updateTime;
PropsResources copyWith({
num? amount,
String? code,
String? cover,
num? createTime,
bool? del,
String? expand,
String? id,
String? imNotOpenedUrl,
String? imOpenedUrl,
String? imOpenedUrlTwo,
String? imSendCoverUrl,
String? name,
String? roomNotOpenedUrl,
String? roomOpenedUrl,
String? roomSendCoverUrl,
String? sourceUrl,
String? sysOrigin,
String? type,
num? updateTime,
}) => PropsResources(
amount: amount ?? _amount,
code: code ?? _code,
cover: cover ?? _cover,
createTime: createTime ?? _createTime,
del: del ?? _del,
expand: expand ?? _expand,
id: id ?? _id,
imNotOpenedUrl: imNotOpenedUrl ?? _imNotOpenedUrl,
imOpenedUrl: imOpenedUrl ?? _imOpenedUrl,
imOpenedUrlTwo: imOpenedUrlTwo ?? _imOpenedUrlTwo,
imSendCoverUrl: imSendCoverUrl ?? _imSendCoverUrl,
name: name ?? _name,
roomNotOpenedUrl: roomNotOpenedUrl ?? _roomNotOpenedUrl,
roomOpenedUrl: roomOpenedUrl ?? _roomOpenedUrl,
roomSendCoverUrl: roomSendCoverUrl ?? _roomSendCoverUrl,
sourceUrl: sourceUrl ?? _sourceUrl,
sysOrigin: sysOrigin ?? _sysOrigin,
type: type ?? _type,
updateTime: updateTime ?? _updateTime,
);
num? get amount => _amount;
String? get code => _code;
String? get cover => _cover;
num? get createTime => _createTime;
bool? get del => _del;
String? get expand => _expand;
String? get id => _id;
String? get imNotOpenedUrl => _imNotOpenedUrl;
String? get imOpenedUrl => _imOpenedUrl;
String? get imOpenedUrlTwo => _imOpenedUrlTwo;
String? get imSendCoverUrl => _imSendCoverUrl;
String? get name => _name;
String? get roomNotOpenedUrl => _roomNotOpenedUrl;
String? get roomOpenedUrl => _roomOpenedUrl;
String? get roomSendCoverUrl => _roomSendCoverUrl;
String? get sourceUrl => _sourceUrl;
String? get sysOrigin => _sysOrigin;
String? get type => _type;
num? get updateTime => _updateTime;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['amount'] = _amount;
map['code'] = _code;
map['cover'] = _cover;
map['createTime'] = _createTime;
map['del'] = _del;
map['expand'] = _expand;
map['id'] = _id;
map['imNotOpenedUrl'] = _imNotOpenedUrl;
map['imOpenedUrl'] = _imOpenedUrl;
map['imOpenedUrlTwo'] = _imOpenedUrlTwo;
map['imSendCoverUrl'] = _imSendCoverUrl;
map['name'] = _name;
map['roomNotOpenedUrl'] = _roomNotOpenedUrl;
map['roomOpenedUrl'] = _roomOpenedUrl;
map['roomSendCoverUrl'] = _roomSendCoverUrl;
map['sourceUrl'] = _sourceUrl;
map['sysOrigin'] = _sysOrigin;
map['type'] = _type;
map['updateTime'] = _updateTime;
return map;
}
}
bool socialChatIsAvatarFrameResource(PropsResources? resource) {
if (!_isAvatarFrameType(resource?.type)) {
return false;
}
final sourceUrl = resource?.sourceUrl?.trim() ?? "";
if (sourceUrl.isEmpty) {
return false;
}
return !_looksLikeEntryEffectResource(sourceUrl) &&
!_looksLikeEntryEffectResource(resource?.cover ?? "");
}
PropsResources? socialChatAvatarFrameProps({
String? id,
String? name,
String? sourceUrl,
String? cover,
String? code,
}) {
final resource = PropsResources(
id: id,
name: name,
code: code,
sourceUrl: sourceUrl,
cover: cover,
type: SCPropsType.AVATAR_FRAME.name,
);
return socialChatIsAvatarFrameResource(resource) ? resource : null;
}
SocialChatUserProfile socialChatProfileWithAvatarFrameResource(
SocialChatUserProfile profile,
PropsResources? avatarFrame, {
String? expireTime,
}) {
if (!socialChatIsAvatarFrameResource(avatarFrame)) {
return profile;
}
final currentHeaddress = profile.getHeaddress();
if (currentHeaddress != null) {
return profile;
}
final useProps = <UseProps>[
...?profile.useProps?.where(
(item) => !_isAvatarFrameType(item.propsResources?.type),
),
UseProps(
expireTime: expireTime ?? "4102444800000",
propsResources: avatarFrame,
userId: profile.id,
),
];
return profile.copyWith(useProps: useProps);
}
bool _isAvatarFrameType(String? type) {
return type?.trim().toUpperCase() == SCPropsType.AVATAR_FRAME.name;
}
bool _looksLikeEntryEffectResource(String value) {
if (value.trim().isEmpty) {
return false;
}
final text = _decodeResourceText(value).toLowerCase();
final entryResourcePattern = RegExp(
r'(^|[\/_\-.?=&])(?:entry|entrance|ride|mountain|mountains)([\/_\-.?=&]|$)',
);
return entryResourcePattern.hasMatch(text) ||
text.contains('entryeffect') ||
text.contains('进场') ||
text.contains('坐骑');
}
String _decodeResourceText(String value) {
try {
return Uri.decodeFull(value);
} catch (_) {
return value;
}
}
/// account : ""
/// expiredTime : 0
class OwnSpecialId {
OwnSpecialId({String? account, num? expiredTime}) {
_account = account;
_expiredTime = expiredTime;
}
OwnSpecialId.fromJson(dynamic json) {
_account = json['account'];
_expiredTime = json['expiredTime'];
}
String? _account;
num? _expiredTime;
OwnSpecialId copyWith({String? account, num? expiredTime}) => OwnSpecialId(
account: account ?? _account,
expiredTime: expiredTime ?? _expiredTime,
);
String? get account => _account;
num? get expiredTime => _expiredTime;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['account'] = _account;
map['expiredTime'] = _expiredTime;
return map;
}
}
/// expireTime : 0
/// releaseTime : 0
/// sign : ""
/// sysOrigin : ""
/// userId : 0
/// version : ""
class SocialChatUserCredential {
SocialChatUserCredential({
String? expireTime,
String? releaseTime,
String? sign,
String? sysOrigin,
String? userId,
String? version,
}) {
_expireTime = expireTime;
_releaseTime = releaseTime;
_sign = sign;
_sysOrigin = sysOrigin;
_userId = userId;
_version = version;
}
SocialChatUserCredential.fromJson(dynamic json) {
_expireTime = json['expireTime'];
_releaseTime = json['releaseTime'];
_sign = json['sign'];
_sysOrigin = json['sysOrigin'];
_userId = json['userId'];
_version = json['version'];
}
String? _expireTime;
String? _releaseTime;
String? _sign;
String? _sysOrigin;
String? _userId;
String? _version;
SocialChatUserCredential copyWith({
String? expireTime,
String? releaseTime,
String? sign,
String? sysOrigin,
String? userId,
String? version,
}) => SocialChatUserCredential(
expireTime: expireTime ?? _expireTime,
releaseTime: releaseTime ?? _releaseTime,
sign: sign ?? _sign,
sysOrigin: sysOrigin ?? _sysOrigin,
userId: userId ?? _userId,
version: version ?? _version,
);
String? get expireTime => _expireTime;
String? get releaseTime => _releaseTime;
String? get sign => _sign;
String? get sysOrigin => _sysOrigin;
String? get userId => _userId;
String? get version => _version;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['expireTime'] = _expireTime;
map['releaseTime'] = _releaseTime;
map['sign'] = _sign;
map['sysOrigin'] = _sysOrigin;
map['userId'] = _userId;
map['version'] = _version;
return map;
}
}