mirror of
https://github.com/xiaoyiweb/YiAi.git
synced 2025-09-26 05:06:39 +08:00
1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
'use strict';const _0x329081=_0x24c6;(function(_0x3106d0,_0x5a2b82){const _0x1ca6c4=_0x24c6,_0x1eb0bb=_0x3106d0();while(!![]){try{const _0x456766=parseInt(_0x1ca6c4(0x168))/0x1*(-parseInt(_0x1ca6c4(0x144))/0x2)+parseInt(_0x1ca6c4(0x16c))/0x3+parseInt(_0x1ca6c4(0x19c))/0x4*(parseInt(_0x1ca6c4(0x15e))/0x5)+parseInt(_0x1ca6c4(0x195))/0x6+parseInt(_0x1ca6c4(0x152))/0x7*(-parseInt(_0x1ca6c4(0x17d))/0x8)+-parseInt(_0x1ca6c4(0x18f))/0x9*(-parseInt(_0x1ca6c4(0x1a6))/0xa)+parseInt(_0x1ca6c4(0x194))/0xb;if(_0x456766===_0x5a2b82)break;else _0x1eb0bb['push'](_0x1eb0bb['shift']());}catch(_0xe5f0da){_0x1eb0bb['push'](_0x1eb0bb['shift']());}}}(_0x35f1,0x3ad2e));var __decorate=this&&this[_0x329081(0x147)]||function(_0x3dfa16,_0xe3212d,_0x52223c,_0x47948f){const _0x4830e5=_0x329081;var _0x393d8e=arguments['length'],_0x259b99=_0x393d8e<0x3?_0xe3212d:_0x47948f===null?_0x47948f=Object['getOwnPropertyDescriptor'](_0xe3212d,_0x52223c):_0x47948f,_0x1210cf;if(typeof Reflect==='object'&&typeof Reflect[_0x4830e5(0x192)]===_0x4830e5(0x190))_0x259b99=Reflect[_0x4830e5(0x192)](_0x3dfa16,_0xe3212d,_0x52223c,_0x47948f);else{for(var _0x2323d2=_0x3dfa16[_0x4830e5(0x171)]-0x1;_0x2323d2>=0x0;_0x2323d2--)if(_0x1210cf=_0x3dfa16[_0x2323d2])_0x259b99=(_0x393d8e<0x3?_0x1210cf(_0x259b99):_0x393d8e>0x3?_0x1210cf(_0xe3212d,_0x52223c,_0x259b99):_0x1210cf(_0xe3212d,_0x52223c))||_0x259b99;}return _0x393d8e>0x3&&_0x259b99&&Object['defineProperty'](_0xe3212d,_0x52223c,_0x259b99),_0x259b99;},__metadata=this&&this[_0x329081(0x18e)]||function(_0x153d89,_0x1a5b85){const _0x52f663=_0x329081;if(typeof Reflect==='object'&&typeof Reflect[_0x52f663(0x146)]===_0x52f663(0x190))return Reflect[_0x52f663(0x146)](_0x153d89,_0x1a5b85);},__param=this&&this[_0x329081(0x13e)]||function(_0x34435e,_0x25184e){return function(_0xbdb125,_0x5be5c9){_0x25184e(_0xbdb125,_0x5be5c9,_0x34435e);};};function _0x24c6(_0x36c73b,_0x12df6a){const _0x35f191=_0x35f1();return _0x24c6=function(_0x24c6fd,_0x4830a3){_0x24c6fd=_0x24c6fd-0x139;let _0x37e41a=_0x35f191[_0x24c6fd];return _0x37e41a;},_0x24c6(_0x36c73b,_0x12df6a);}Object[_0x329081(0x187)](exports,'__esModule',{'value':!![]}),exports['BadwordsService']=void 0x0;function _0x35f1(){const _0x534632=['extractContent','msg','的信息、我们已对您账号进行标记、请合规使用!','delBadWords','userEntity','ASC','敏感词不存在,请检查您的提交信息','application/x-www-form-urlencoded','190bGUoSM','您提交的信息中包含违规的内容、我们已对您的账户进行标记、请合规使用!','添加敏感词成功','../globalConfig/globalConfig.service','../user/user.entity','InjectRepository','status','recordUserBadWords','__param','检测失败','user','execute','ViolationLogEntity','敏感词已存在,请检查您的提交信息','702Khusxn','queryBadWords','metadata','__decorate','log','affected','nineaiCheckBadWords','baiduTextAccessToken','百度云检测','更新敏感词失败','createQueryBuilder','category','includes','badWordsEntity','1358NAMezY','HttpException','violationCount','getSensitiveConfig','super','delete','avatar','onModuleInit','nineai','findOne','删除敏感词成功','百度文本检测出现错误、请查看配置信息:\x20','10RptfYf','typeOriginCn','删除敏感词失败','word_list','violationLogEntity','globalConfigService','HttpStatus','@nestjs/common','post','BadwordsService','192OpnuNF','data','baiduCheckBadWords','checkBadWords','286455IspchK','userId','findAndCount','where','code','length','UserEntity','BadWordsEntity','loadBadWords','自定义','push','NineAi检测','checkBadWordsByConfig','save','https://aip.baidubce.com/rest/2.0/solution/v1/text_censor/v2/user_defined?access_token=','username','敏感词已经存在了、请勿重复添加','6128aHgGrw','join','更新敏感词成功','您提交的信息中包含','violationCount\x20+\x201','typeorm','Like','BAD_REQUEST','hideString','map','defineProperty','badWords','***','的内容、我们已对您的账户进行标记、请合规使用!','Repository','update','敏感词检测\x20|\x20','__metadata','90378wpemAm','function','formarTips','decorate','forEach','158851xLbYnX','336888oIwefJ','customSensitiveWords','find','stringify','default','baidu','word','200132qAYSXc','set'];_0x35f1=function(){return _0x534632;};return _0x35f1();}const globalConfig_service_1=require(_0x329081(0x139)),common_1=require(_0x329081(0x165)),badwords_entity_1=require('./badwords.entity'),typeorm_1=require(_0x329081(0x182)),typeorm_2=require('@nestjs/typeorm'),axios_1=require('axios'),violationLog_entity_1=require('./violationLog.entity'),user_entity_1=require(_0x329081(0x13a)),utils_1=require('../../common/utils');let BadwordsService=class BadwordsService{constructor(_0x6356a3,_0x2dc976,_0x8d264d,_0x1c4f76){const _0x1eaeae=_0x329081;this['badWordsEntity']=_0x6356a3,this[_0x1eaeae(0x162)]=_0x2dc976,this['userEntity']=_0x8d264d,this[_0x1eaeae(0x163)]=_0x1c4f76,this[_0x1eaeae(0x188)]=[];}async[_0x329081(0x159)](){const _0x59e360=_0x329081;this[_0x59e360(0x174)]();}async[_0x329081(0x196)](_0x4661ff,_0x566435){const _0x30ef7a=_0x329081,_0x2060e0=[];for(let _0x32f380=0x0;_0x32f380<this[_0x30ef7a(0x188)][_0x30ef7a(0x171)];_0x32f380++){const _0x2629b2=this[_0x30ef7a(0x188)][_0x32f380];_0x4661ff[_0x30ef7a(0x150)](_0x2629b2)&&_0x2060e0[_0x30ef7a(0x176)](_0x2629b2);}if(_0x2060e0[_0x30ef7a(0x171)]){await this[_0x30ef7a(0x13d)](_0x566435,_0x4661ff,_0x2060e0,[_0x30ef7a(0x175)],'自定义检测');const _0x23b5bb=_0x30ef7a(0x1a7);throw new common_1['HttpException'](_0x23b5bb,common_1[_0x30ef7a(0x164)][_0x30ef7a(0x184)]);}}async[_0x329081(0x16b)](_0x40f458,_0x15a61d){const _0xedb0d4=_0x329081,_0xdc5caa=await this['globalConfigService'][_0xedb0d4(0x155)]();_0xdc5caa&&await this[_0xedb0d4(0x178)](_0x40f458,_0xdc5caa,_0x15a61d),await this['customSensitiveWords'](_0x40f458,_0x15a61d);}async[_0x329081(0x178)](_0xc69683,_0x274864,_0x10fee9){const _0x52d560=_0x329081,{useType:_0xb9e75a}=_0x274864;_0xb9e75a===_0x52d560(0x19a)&&await this[_0x52d560(0x16a)](_0xc69683,_0x274864[_0x52d560(0x14b)],_0x10fee9),_0xb9e75a===_0x52d560(0x15a)&&await this[_0x52d560(0x14a)](_0xc69683,_0x274864,_0x10fee9);}['extractContent'](_0x5e365e){const _0x51fd90=/存在(.*?)不合规/,_0x467891=_0x5e365e['match'](_0x51fd90);return _0x467891?_0x467891[0x1]:'';}async[_0x329081(0x16a)](_0x1bf7fc,_0xfc1ae,_0x4c5afb){const _0x4c1a88=_0x329081;if(!_0xfc1ae)return;const _0x6a0ea7=_0x4c1a88(0x17a)+_0xfc1ae+'}',_0x48db25={'Content-Type':_0x4c1a88(0x1a5),'Accept':'application/json'},_0x1a77ab=await axios_1[_0x4c1a88(0x199)][_0x4c1a88(0x166)](_0x6a0ea7,{'text':_0x1bf7fc},{'headers':_0x48db25}),{conclusion:_0x57379d,error_code:_0x7ad0c5,error_msg:_0x543885,conclusionType:_0x3acce0,data:_0x2e689a}=_0x1a77ab[_0x4c1a88(0x169)];_0x7ad0c5&&console[_0x4c1a88(0x148)](_0x4c1a88(0x15d),_0x543885);if(_0x3acce0!==0x1){const _0x5b6a36=[...new Set(_0x2e689a[_0x4c1a88(0x186)](_0x22bbdd=>this[_0x4c1a88(0x19e)](_0x22bbdd[_0x4c1a88(0x19f)])))];await this['recordUserBadWords'](_0x4c5afb,_0x1bf7fc,[_0x4c1a88(0x189)],_0x5b6a36,_0x4c1a88(0x14c));const _0x4a3852=_0x4c1a88(0x180)+_0x5b6a36[_0x4c1a88(0x17e)](',')+_0x4c1a88(0x18a);throw new common_1[(_0x4c1a88(0x153))](_0x4a3852,common_1[_0x4c1a88(0x164)]['BAD_REQUEST']);}}async[_0x329081(0x14a)](_0xe3431d,_0x4a594b,_0x4c8006){const _0x4738cc=_0x329081;var _0x1f8bd4;const {nineaiBuiltInSensitiveApiBase:_0x1e100d,nineaiBuiltInSensitiveAuthKey:_0x5bfdd2}=_0x4a594b;if(!_0x1e100d||!_0x5bfdd2)return;const _0x2682c9=await axios_1['default'][_0x4738cc(0x166)](_0x1e100d,{'content':_0xe3431d},{'headers':{'Content-Type':'application/json','Authorization':_0x5bfdd2}});if(!_0x2682c9[_0x4738cc(0x169)])return;if(_0x2682c9[_0x4738cc(0x169)][_0x4738cc(0x170)]!=='0'){const {msg:msg=_0x4738cc(0x13f)}=_0x2682c9[_0x4738cc(0x169)];throw new common_1[(_0x4738cc(0x153))](_0x4738cc(0x18d)+msg,common_1[_0x4738cc(0x164)][_0x4738cc(0x184)]);}if(_0x2682c9[_0x4738cc(0x169)][_0x4738cc(0x161)]&&((_0x1f8bd4=_0x2682c9[_0x4738cc(0x169)][_0x4738cc(0x161)])===null||_0x1f8bd4===void 0x0?void 0x0:_0x1f8bd4[_0x4738cc(0x171)])){const _0x8c267e=[...new Set(_0x2682c9[_0x4738cc(0x169)][_0x4738cc(0x161)][_0x4738cc(0x186)](_0x48a1fa=>_0x48a1fa['keyword']))],_0x37d0fc=[...new Set(_0x2682c9[_0x4738cc(0x169)][_0x4738cc(0x161)]['map'](_0x25a25c=>_0x25a25c[_0x4738cc(0x14f)]))];await this[_0x4738cc(0x13d)](_0x4c8006,_0xe3431d,_0x8c267e,_0x37d0fc,_0x4738cc(0x177));const _0x3d2bf9=this[_0x4738cc(0x191)](_0x2682c9['data'][_0x4738cc(0x161)]);throw new common_1[(_0x4738cc(0x153))](_0x3d2bf9,common_1['HttpStatus']['BAD_REQUEST']);}}[_0x329081(0x191)](_0x168864){const _0x158218=_0x329081,_0x35eccf=_0x168864[_0x158218(0x186)](_0xe3c060=>_0xe3c060[_0x158218(0x14f)]),_0x34e030=[...new Set(_0x35eccf)];return'您提交的内容中包含'+_0x34e030[_0x158218(0x17e)](',')+_0x158218(0x1a0);}async[_0x329081(0x174)](){const _0x529117=_0x329081,_0x1ce451=await this[_0x529117(0x151)][_0x529117(0x197)]({'where':{'status':0x1},'select':['word']});this[_0x529117(0x188)]=_0x1ce451[_0x529117(0x186)](_0x4e60b3=>_0x4e60b3[_0x529117(0x19b)]);}async[_0x329081(0x145)](_0x18d69d){const _0x11df22=_0x329081,{page:page=0x1,size:size=0x1f4,word:_0x407292,status:_0x42f3c8}=_0x18d69d,_0x3bf96f={};[0x0,0x1,'0','1'][_0x11df22(0x150)](_0x42f3c8)&&(_0x3bf96f[_0x11df22(0x13c)]=_0x42f3c8),_0x407292&&(_0x3bf96f[_0x11df22(0x19b)]=(0x0,typeorm_1[_0x11df22(0x183)])('%'+_0x407292+'%'));const [_0x5a8256,_0x48fcfe]=await this[_0x11df22(0x151)][_0x11df22(0x16e)]({'where':_0x3bf96f,'skip':(page-0x1)*size,'take':size,'order':{'id':_0x11df22(0x1a3)}});return{'rows':_0x5a8256,'count':_0x48fcfe};}async[_0x329081(0x1a1)](_0xf0f8da){const _0x30505f=_0x329081,_0x57d1fb=await this[_0x30505f(0x151)][_0x30505f(0x15b)]({'where':{'id':_0xf0f8da['id']}});if(!_0x57d1fb)throw new common_1[(_0x30505f(0x153))](_0x30505f(0x1a4),common_1['HttpStatus'][_0x30505f(0x184)]);const _0x3f713a=await this[_0x30505f(0x151)][_0x30505f(0x157)]({'id':_0xf0f8da['id']});if(_0x3f713a['affected']>0x0)return await this['loadBadWords'](),_0x30505f(0x15c);else throw new common_1[(_0x30505f(0x153))](_0x30505f(0x160),common_1['HttpStatus'][_0x30505f(0x184)]);}async['updateBadWords'](_0x5869ee){const _0x4f313d=_0x329081,{id:_0x3bc053,word:_0xcf40db,status:_0x1ebc6e}=_0x5869ee,_0x45c44f=await this[_0x4f313d(0x151)]['findOne']({'where':{'word':_0xcf40db}});if(_0x45c44f)throw new common_1[(_0x4f313d(0x153))](_0x4f313d(0x17c),common_1['HttpStatus']['BAD_REQUEST']);const _0x1190dd=await this[_0x4f313d(0x151)]['update']({'id':_0x3bc053},{'word':_0xcf40db,'status':_0x1ebc6e});if(_0x1190dd[_0x4f313d(0x149)]>0x0)return await this['loadBadWords'](),_0x4f313d(0x17f);else throw new common_1[(_0x4f313d(0x153))](_0x4f313d(0x14d),common_1[_0x4f313d(0x164)]['BAD_REQUEST']);}async['addBadWord'](_0x3213cd){const _0x38de03=_0x329081,{word:_0x46db45}=_0x3213cd,_0x393885=await this[_0x38de03(0x151)][_0x38de03(0x15b)]({'where':{'word':_0x46db45}});if(_0x393885)throw new common_1[(_0x38de03(0x153))](_0x38de03(0x143),common_1['HttpStatus'][_0x38de03(0x184)]);return await this[_0x38de03(0x151)][_0x38de03(0x179)]({'word':_0x46db45}),await this[_0x38de03(0x174)](),_0x38de03(0x1a8);}async[_0x329081(0x13d)](_0x329f88,_0x12db6b,_0x54edb4,_0x5f4700,_0x125312){const _0x25c39d=_0x329081,_0x4e7db7={'userId':_0x329f88,'content':_0x12db6b,'words':JSON[_0x25c39d(0x198)](_0x54edb4),'typeCn':JSON['stringify'](_0x5f4700),'typeOriginCn':_0x125312};try{await this[_0x25c39d(0x1a2)][_0x25c39d(0x14e)]()[_0x25c39d(0x18c)](user_entity_1[_0x25c39d(0x172)])[_0x25c39d(0x19d)]({'violationCount':()=>_0x25c39d(0x181)})[_0x25c39d(0x16f)]('id\x20=\x20:userId',{'userId':_0x329f88})[_0x25c39d(0x141)](),await this['violationLogEntity'][_0x25c39d(0x179)](_0x4e7db7);}catch(_0x39eab3){console[_0x25c39d(0x148)]('error:\x20',_0x39eab3);}}async['violation'](_0x19e295,_0x59ac9e){const _0x464ea6=_0x329081,{role:_0x4e3021}=_0x19e295[_0x464ea6(0x140)],{page:page=0x1,size:size=0xa,userId:_0x37e030,typeOriginCn:_0x3031fc}=_0x59ac9e,_0x59c367={};_0x37e030&&(_0x59c367[_0x464ea6(0x16d)]=_0x37e030),_0x3031fc&&(_0x59c367[_0x464ea6(0x15f)]=_0x3031fc);const [_0x525835,_0x4e1e35]=await this[_0x464ea6(0x162)][_0x464ea6(0x16e)]({'where':_0x59c367,'skip':(page-0x1)*size,'take':size,'order':{'id':'DESC'}}),_0x1f07ed=[...new Set(_0x525835[_0x464ea6(0x186)](_0x504d8b=>_0x504d8b[_0x464ea6(0x16d)]))],_0x24b6e2=await this[_0x464ea6(0x1a2)][_0x464ea6(0x197)]({'where':{'id':(0x0,typeorm_1['In'])(_0x1f07ed)},'select':['id',_0x464ea6(0x158),_0x464ea6(0x17b),'email',_0x464ea6(0x154),'status']});return _0x525835[_0x464ea6(0x193)](_0x4037f4=>{const _0x5d62b9=_0x464ea6,_0x366823=_0x24b6e2[_0x5d62b9(0x197)](_0x487d47=>_0x487d47['id']===_0x4037f4[_0x5d62b9(0x16d)]);_0x4e3021!==_0x5d62b9(0x156)&&(_0x366823['email']=(0x0,utils_1[_0x5d62b9(0x185)])(_0x366823['email'])),_0x4037f4['userInfo']=_0x366823;}),{'rows':_0x525835,'count':_0x4e1e35};}};BadwordsService=__decorate([(0x0,common_1['Injectable'])(),__param(0x0,(0x0,typeorm_2[_0x329081(0x13b)])(badwords_entity_1[_0x329081(0x173)])),__param(0x1,(0x0,typeorm_2['InjectRepository'])(violationLog_entity_1[_0x329081(0x142)])),__param(0x2,(0x0,typeorm_2[_0x329081(0x13b)])(user_entity_1['UserEntity'])),__metadata('design:paramtypes',[typeorm_1[_0x329081(0x18b)],typeorm_1['Repository'],typeorm_1[_0x329081(0x18b)],globalConfig_service_1['GlobalConfigService']])],BadwordsService),exports[_0x329081(0x167)]=BadwordsService; |