mirror of
https://github.com/xiaoyiweb/YiAi.git
synced 2025-09-17 16:56:38 +08:00
1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
'use strict';const _0x61ce16=_0x1709;(function(_0x5b476b,_0x29767b){const _0x3d9d1a=_0x1709,_0x3bd1d9=_0x5b476b();while(!![]){try{const _0x2d638e=parseInt(_0x3d9d1a(0x107))/0x1+parseInt(_0x3d9d1a(0x14a))/0x2+parseInt(_0x3d9d1a(0x13e))/0x3+-parseInt(_0x3d9d1a(0x100))/0x4*(-parseInt(_0x3d9d1a(0x12e))/0x5)+parseInt(_0x3d9d1a(0x12c))/0x6+-parseInt(_0x3d9d1a(0x117))/0x7+-parseInt(_0x3d9d1a(0x123))/0x8;if(_0x2d638e===_0x29767b)break;else _0x3bd1d9['push'](_0x3bd1d9['shift']());}catch(_0x1c70be){_0x3bd1d9['push'](_0x3bd1d9['shift']());}}}(_0x3372,0xa1ea3));function _0x3372(){const _0x5664f2=['where','msg','application/json','error:\x20','user','default','HttpStatus','save','code','metadata','post','axios','272236qVetIE','join','delete','Repository','formarTips','push','百度云检测','35958uMcrkH','violation','findAndCount','hideString','您提交的内容中包含','log','username','__metadata','@nestjs/typeorm','loadBadWords','BadwordsService','NineAi检测','map','word_list','敏感词不存在,请检查您的提交信息','getOwnPropertyDescriptor','7060396WMrTxK','design:paramtypes','删除敏感词失败','自定义','getSensitiveConfig','findOne','ASC','userInfo','您提交的信息中包含违规的内容、我们已对您的账户进行标记、请合规使用!','defineProperty','DESC','badWordsEntity','16541656Gtghbw','更新敏感词成功','globalConfigService','userEntity','UserEntity','onModuleInit','./violationLog.entity','violationLogEntity','baiduCheckBadWords','3869454srfPED','includes','60TKctLr','decorate','word','stringify','检测失败','InjectRepository','nineaiCheckBadWords','../globalConfig/globalConfig.service','queryBadWords','avatar','Like','recordUserBadWords','category','checkBadWords','createQueryBuilder','execute','3258177kfqzOe','status','customSensitiveWords','email','./badwords.entity','userId','length','data','application/x-www-form-urlencoded','@nestjs/common','id\x20=\x20:userId','BAD_REQUEST','2311808RPZQzi','ViolationLogEntity','typeOriginCn','match','checkBadWordsByConfig','的内容、我们已对您的账户进行标记、请合规使用!','typeorm','../user/user.entity','function','find','敏感词检测\x20|\x20','badWords','敏感词已经存在了、请勿重复添加','addBadWord','的信息、我们已对您账号进行标记、请合规使用!','__esModule','HttpException','object','keyword','自定义检测','您提交的信息中包含','update','../../common/utils','百度文本检测出现错误、请查看配置信息:\x20','nineai','敏感词已存在,请检查您的提交信息'];_0x3372=function(){return _0x5664f2;};return _0x3372();}var __decorate=this&&this['__decorate']||function(_0x3a93e9,_0x7a959,_0x210861,_0x23af4f){const _0x23f2ad=_0x1709;var _0x426d20=arguments['length'],_0x4a6f6d=_0x426d20<0x3?_0x7a959:_0x23af4f===null?_0x23af4f=Object[_0x23f2ad(0x116)](_0x7a959,_0x210861):_0x23af4f,_0x5a8633;if(typeof Reflect==='object'&&typeof Reflect[_0x23f2ad(0x12f)]===_0x23f2ad(0x152))_0x4a6f6d=Reflect[_0x23f2ad(0x12f)](_0x3a93e9,_0x7a959,_0x210861,_0x23af4f);else{for(var _0x423724=_0x3a93e9[_0x23f2ad(0x144)]-0x1;_0x423724>=0x0;_0x423724--)if(_0x5a8633=_0x3a93e9[_0x423724])_0x4a6f6d=(_0x426d20<0x3?_0x5a8633(_0x4a6f6d):_0x426d20>0x3?_0x5a8633(_0x7a959,_0x210861,_0x4a6f6d):_0x5a8633(_0x7a959,_0x210861))||_0x4a6f6d;}return _0x426d20>0x3&&_0x4a6f6d&&Object[_0x23f2ad(0x120)](_0x7a959,_0x210861,_0x4a6f6d),_0x4a6f6d;},__metadata=this&&this[_0x61ce16(0x10e)]||function(_0x2820ef,_0xab0788){const _0x5593d5=_0x61ce16;if(typeof Reflect===_0x5593d5(0x15b)&&typeof Reflect[_0x5593d5(0xfd)]===_0x5593d5(0x152))return Reflect['metadata'](_0x2820ef,_0xab0788);},__param=this&&this['__param']||function(_0x380124,_0x5801d8){return function(_0x3e0f18,_0x4e07a4){_0x5801d8(_0x3e0f18,_0x4e07a4,_0x380124);};};Object['defineProperty'](exports,_0x61ce16(0x159),{'value':!![]}),exports[_0x61ce16(0x111)]=void 0x0;const globalConfig_service_1=require(_0x61ce16(0x135)),common_1=require(_0x61ce16(0x147)),badwords_entity_1=require(_0x61ce16(0x142)),typeorm_1=require(_0x61ce16(0x150)),typeorm_2=require(_0x61ce16(0x10f)),axios_1=require(_0x61ce16(0xff)),violationLog_entity_1=require(_0x61ce16(0x129)),user_entity_1=require(_0x61ce16(0x151)),utils_1=require(_0x61ce16(0x160));function _0x1709(_0xe1cd1c,_0x495ca8){const _0x3372f0=_0x3372();return _0x1709=function(_0x1709f2,_0x1da869){_0x1709f2=_0x1709f2-0xfc;let _0x349eb5=_0x3372f0[_0x1709f2];return _0x349eb5;},_0x1709(_0xe1cd1c,_0x495ca8);}let BadwordsService=class BadwordsService{constructor(_0x2f989c,_0xa10bf9,_0x3877f9,_0x536062){const _0x9c7288=_0x61ce16;this['badWordsEntity']=_0x2f989c,this[_0x9c7288(0x12a)]=_0xa10bf9,this[_0x9c7288(0x126)]=_0x3877f9,this[_0x9c7288(0x125)]=_0x536062,this[_0x9c7288(0x155)]=[];}async[_0x61ce16(0x128)](){this['loadBadWords']();}async['customSensitiveWords'](_0x5c745b,_0x4359d0){const _0x566408=_0x61ce16,_0xdb5749=[];for(let _0x4d6c87=0x0;_0x4d6c87<this['badWords'][_0x566408(0x144)];_0x4d6c87++){const _0x4f271c=this[_0x566408(0x155)][_0x4d6c87];_0x5c745b[_0x566408(0x12d)](_0x4f271c)&&_0xdb5749[_0x566408(0x105)](_0x4f271c);}if(_0xdb5749[_0x566408(0x144)]){await this[_0x566408(0x139)](_0x4359d0,_0x5c745b,_0xdb5749,[_0x566408(0x11a)],_0x566408(0x15d));const _0x5c68bd=_0x566408(0x11f);throw new common_1[(_0x566408(0x15a))](_0x5c68bd,common_1[_0x566408(0x16a)][_0x566408(0x149)]);}}async[_0x61ce16(0x13b)](_0x3e68ef,_0x5cdf00){const _0x15a76b=_0x61ce16,_0x3f593f=await this[_0x15a76b(0x125)][_0x15a76b(0x11b)]();_0x3f593f&&await this[_0x15a76b(0x14e)](_0x3e68ef,_0x3f593f,_0x5cdf00),await this[_0x15a76b(0x140)](_0x3e68ef,_0x5cdf00);}async[_0x61ce16(0x14e)](_0x43513f,_0x4f4afb,_0x46a475){const _0x63e695=_0x61ce16,{useType:_0x1717ba}=_0x4f4afb;_0x1717ba==='baidu'&&await this[_0x63e695(0x12b)](_0x43513f,_0x4f4afb['baiduTextAccessToken'],_0x46a475),_0x1717ba===_0x63e695(0x162)&&await this[_0x63e695(0x134)](_0x43513f,_0x4f4afb,_0x46a475);}['extractContent'](_0x41d805){const _0x4cc161=_0x61ce16,_0x52dde8=/存在(.*?)不合规/,_0x11421e=_0x41d805[_0x4cc161(0x14d)](_0x52dde8);return _0x11421e?_0x11421e[0x1]:'';}async['baiduCheckBadWords'](_0x358065,_0x224a84,_0x32a651){const _0x270157=_0x61ce16;if(!_0x224a84)return;const _0x9b54a1='https://aip.baidubce.com/rest/2.0/solution/v1/text_censor/v2/user_defined?access_token='+_0x224a84+'}',_0x54c6c4={'Content-Type':_0x270157(0x146),'Accept':'application/json'},_0x4b5dd1=await axios_1[_0x270157(0x169)]['post'](_0x9b54a1,{'text':_0x358065},{'headers':_0x54c6c4}),{conclusion:_0x363192,error_code:_0xabe123,error_msg:_0x3a0209,conclusionType:_0x11f5d9,data:_0x1d951f}=_0x4b5dd1[_0x270157(0x145)];_0xabe123&&console[_0x270157(0x10c)](_0x270157(0x161),_0x3a0209);if(_0x11f5d9!==0x1){const _0x301900=[...new Set(_0x1d951f['map'](_0x1ebbe5=>this['extractContent'](_0x1ebbe5[_0x270157(0x165)])))];await this[_0x270157(0x139)](_0x32a651,_0x358065,['***'],_0x301900,_0x270157(0x106));const _0x3eac1d=_0x270157(0x15e)+_0x301900[_0x270157(0x101)](',')+_0x270157(0x14f);throw new common_1[(_0x270157(0x15a))](_0x3eac1d,common_1[_0x270157(0x16a)][_0x270157(0x149)]);}}async[_0x61ce16(0x134)](_0x13286e,_0x3eb616,_0x479d62){const _0x4730cf=_0x61ce16;var _0xe6843b;const {nineaiBuiltInSensitiveApiBase:_0xa243e,nineaiBuiltInSensitiveAuthKey:_0x532de0}=_0x3eb616;if(!_0xa243e||!_0x532de0)return;const _0x2509c7=await axios_1[_0x4730cf(0x169)][_0x4730cf(0xfe)](_0xa243e,{'content':_0x13286e},{'headers':{'Content-Type':_0x4730cf(0x166),'Authorization':_0x532de0}});if(!_0x2509c7[_0x4730cf(0x145)])return;if(_0x2509c7['data'][_0x4730cf(0xfc)]!=='0'){const {msg:msg=_0x4730cf(0x132)}=_0x2509c7[_0x4730cf(0x145)];throw new common_1[(_0x4730cf(0x15a))](_0x4730cf(0x154)+msg,common_1[_0x4730cf(0x16a)][_0x4730cf(0x149)]);}if(_0x2509c7[_0x4730cf(0x145)][_0x4730cf(0x114)]&&((_0xe6843b=_0x2509c7['data']['word_list'])===null||_0xe6843b===void 0x0?void 0x0:_0xe6843b[_0x4730cf(0x144)])){const _0x284654=[...new Set(_0x2509c7['data'][_0x4730cf(0x114)]['map'](_0x1dc9a7=>_0x1dc9a7[_0x4730cf(0x15c)]))],_0x29b5e7=[...new Set(_0x2509c7['data'][_0x4730cf(0x114)]['map'](_0x233a52=>_0x233a52[_0x4730cf(0x13a)]))];await this['recordUserBadWords'](_0x479d62,_0x13286e,_0x284654,_0x29b5e7,_0x4730cf(0x112));const _0x35dad3=this[_0x4730cf(0x104)](_0x2509c7[_0x4730cf(0x145)][_0x4730cf(0x114)]);throw new common_1['HttpException'](_0x35dad3,common_1[_0x4730cf(0x16a)][_0x4730cf(0x149)]);}}[_0x61ce16(0x104)](_0xc5b22f){const _0x2fdc62=_0x61ce16,_0x153c54=_0xc5b22f[_0x2fdc62(0x113)](_0x4debd2=>_0x4debd2[_0x2fdc62(0x13a)]),_0x549a23=[...new Set(_0x153c54)];return _0x2fdc62(0x10b)+_0x549a23['join'](',')+_0x2fdc62(0x158);}async[_0x61ce16(0x110)](){const _0x265ece=_0x61ce16,_0x5849ed=await this[_0x265ece(0x122)][_0x265ece(0x153)]({'where':{'status':0x1},'select':[_0x265ece(0x130)]});this['badWords']=_0x5849ed[_0x265ece(0x113)](_0x4add41=>_0x4add41[_0x265ece(0x130)]);}async[_0x61ce16(0x136)](_0x1f17f4){const _0x3e4b67=_0x61ce16,{page:page=0x1,size:size=0x1f4,word:_0x1aa91d,status:_0x413825}=_0x1f17f4,_0x249d39={};[0x0,0x1,'0','1'][_0x3e4b67(0x12d)](_0x413825)&&(_0x249d39[_0x3e4b67(0x13f)]=_0x413825),_0x1aa91d&&(_0x249d39[_0x3e4b67(0x130)]=(0x0,typeorm_1[_0x3e4b67(0x138)])('%'+_0x1aa91d+'%'));const [_0x23ee70,_0xf40ba2]=await this[_0x3e4b67(0x122)][_0x3e4b67(0x109)]({'where':_0x249d39,'skip':(page-0x1)*size,'take':size,'order':{'id':_0x3e4b67(0x11d)}});return{'rows':_0x23ee70,'count':_0xf40ba2};}async['delBadWords'](_0xd9f255){const _0x3c20c0=_0x61ce16,_0x11c26a=await this[_0x3c20c0(0x122)]['findOne']({'where':{'id':_0xd9f255['id']}});if(!_0x11c26a)throw new common_1[(_0x3c20c0(0x15a))](_0x3c20c0(0x115),common_1['HttpStatus'][_0x3c20c0(0x149)]);const _0x389c90=await this[_0x3c20c0(0x122)][_0x3c20c0(0x102)]({'id':_0xd9f255['id']});if(_0x389c90['affected']>0x0)return await this[_0x3c20c0(0x110)](),'删除敏感词成功';else throw new common_1[(_0x3c20c0(0x15a))](_0x3c20c0(0x119),common_1['HttpStatus'][_0x3c20c0(0x149)]);}async['updateBadWords'](_0x33efe7){const _0x2ee6c4=_0x61ce16,{id:_0xfd45ab,word:_0xb107e8,status:_0x522d25}=_0x33efe7,_0x5fcc07=await this[_0x2ee6c4(0x122)]['findOne']({'where':{'word':_0xb107e8}});if(_0x5fcc07)throw new common_1[(_0x2ee6c4(0x15a))](_0x2ee6c4(0x156),common_1[_0x2ee6c4(0x16a)]['BAD_REQUEST']);const _0x3f72b1=await this[_0x2ee6c4(0x122)][_0x2ee6c4(0x15f)]({'id':_0xfd45ab},{'word':_0xb107e8,'status':_0x522d25});if(_0x3f72b1['affected']>0x0)return await this['loadBadWords'](),_0x2ee6c4(0x124);else throw new common_1[(_0x2ee6c4(0x15a))]('更新敏感词失败',common_1[_0x2ee6c4(0x16a)][_0x2ee6c4(0x149)]);}async[_0x61ce16(0x157)](_0x432c0d){const _0x3a0638=_0x61ce16,{word:_0x47dc2a}=_0x432c0d,_0x963a6c=await this['badWordsEntity'][_0x3a0638(0x11c)]({'where':{'word':_0x47dc2a}});if(_0x963a6c)throw new common_1[(_0x3a0638(0x15a))](_0x3a0638(0x163),common_1[_0x3a0638(0x16a)][_0x3a0638(0x149)]);return await this[_0x3a0638(0x122)][_0x3a0638(0x16b)]({'word':_0x47dc2a}),await this['loadBadWords'](),'添加敏感词成功';}async['recordUserBadWords'](_0x54458d,_0x4cb778,_0x28725c,_0x1e8ff2,_0x151ce0){const _0x35ad54=_0x61ce16,_0x54a195={'userId':_0x54458d,'content':_0x4cb778,'words':JSON[_0x35ad54(0x131)](_0x28725c),'typeCn':JSON[_0x35ad54(0x131)](_0x1e8ff2),'typeOriginCn':_0x151ce0};try{await this[_0x35ad54(0x126)][_0x35ad54(0x13c)]()[_0x35ad54(0x15f)](user_entity_1[_0x35ad54(0x127)])['set']({'violationCount':()=>'violationCount\x20+\x201'})[_0x35ad54(0x164)](_0x35ad54(0x148),{'userId':_0x54458d})[_0x35ad54(0x13d)](),await this['violationLogEntity'][_0x35ad54(0x16b)](_0x54a195);}catch(_0x491200){console[_0x35ad54(0x10c)](_0x35ad54(0x167),_0x491200);}}async[_0x61ce16(0x108)](_0x4c0055,_0x3301e3){const _0x361e00=_0x61ce16,{role:_0x49b2de}=_0x4c0055[_0x361e00(0x168)],{page:page=0x1,size:size=0xa,userId:_0x5435d3,typeOriginCn:_0x54fbaf}=_0x3301e3,_0x461ea5={};_0x5435d3&&(_0x461ea5[_0x361e00(0x143)]=_0x5435d3),_0x54fbaf&&(_0x461ea5[_0x361e00(0x14c)]=_0x54fbaf);const [_0xf197e0,_0x5d6717]=await this[_0x361e00(0x12a)][_0x361e00(0x109)]({'where':_0x461ea5,'skip':(page-0x1)*size,'take':size,'order':{'id':_0x361e00(0x121)}}),_0x2bbd6a=[...new Set(_0xf197e0[_0x361e00(0x113)](_0x3058b7=>_0x3058b7[_0x361e00(0x143)]))],_0x11767a=await this[_0x361e00(0x126)][_0x361e00(0x153)]({'where':{'id':(0x0,typeorm_1['In'])(_0x2bbd6a)},'select':['id',_0x361e00(0x137),_0x361e00(0x10d),_0x361e00(0x141),'violationCount',_0x361e00(0x13f)]});return _0xf197e0['forEach'](_0x1a076a=>{const _0x289c84=_0x361e00,_0x47b8e4=_0x11767a[_0x289c84(0x153)](_0x224f9d=>_0x224f9d['id']===_0x1a076a[_0x289c84(0x143)]);_0x49b2de!=='super'&&(_0x47b8e4[_0x289c84(0x141)]=(0x0,utils_1[_0x289c84(0x10a)])(_0x47b8e4[_0x289c84(0x141)])),_0x1a076a[_0x289c84(0x11e)]=_0x47b8e4;}),{'rows':_0xf197e0,'count':_0x5d6717};}};BadwordsService=__decorate([(0x0,common_1['Injectable'])(),__param(0x0,(0x0,typeorm_2['InjectRepository'])(badwords_entity_1['BadWordsEntity'])),__param(0x1,(0x0,typeorm_2[_0x61ce16(0x133)])(violationLog_entity_1[_0x61ce16(0x14b)])),__param(0x2,(0x0,typeorm_2[_0x61ce16(0x133)])(user_entity_1['UserEntity'])),__metadata(_0x61ce16(0x118),[typeorm_1[_0x61ce16(0x103)],typeorm_1[_0x61ce16(0x103)],typeorm_1['Repository'],globalConfig_service_1['GlobalConfigService']])],BadwordsService),exports[_0x61ce16(0x111)]=BadwordsService; |