| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168 |
- module.exports = function () {
- var __MODS__ = {};
- var __DEFINE__ = function (modId, func, req) {
- var m = {
- exports: {},
- _tempexports: {}
- };
- __MODS__[modId] = {
- status: 0,
- func: func,
- req: req,
- m: m
- };
- };
- var __REQUIRE__ = function (modId, source) {
- if (!__MODS__[modId]) return require(source);
- if (!__MODS__[modId].status) {
- var m = __MODS__[modId].m;
- m._exports = m._tempexports;
- var desp = Object.getOwnPropertyDescriptor(m, "exports");
- if (desp && desp.configurable) Object.defineProperty(m, "exports", {
- set: function (val) {
- if (typeof val === "object" && val !== m._exports) {
- m._exports.__proto__ = val.__proto__;
- Object.keys(val).forEach(function (k) {
- m._exports[k] = val[k];
- });
- }
- m._tempexports = val;
- },
- get: function () {
- return m._tempexports;
- }
- });
- __MODS__[modId].status = 1;
- __MODS__[modId].func(__MODS__[modId].req, m, m.exports);
- }
- return __MODS__[modId].m.exports;
- };
- var __REQUIRE_WILDCARD__ = function (obj) {
- if (obj && obj.__esModule) {
- return obj;
- } else {
- var newObj = {};
- if (obj != null) {
- for (var k in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k];
- }
- }
- newObj.default = obj;
- return newObj;
- }
- };
- var __REQUIRE_DEFAULT__ = function (obj) {
- return obj && obj.__esModule ? obj.default : obj;
- };
- __DEFINE__(1611536305607, function (require, module, exports) {
- !function (e, t) {
- "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = e || self).TIM = t();
- }(this, function () {
- var e = {
- SDK_READY: "sdkStateReady",
- SDK_NOT_READY: "sdkStateNotReady",
- SDK_DESTROY: "sdkDestroy",
- MESSAGE_RECEIVED: "onMessageReceived",
- MESSAGE_REVOKED: "onMessageRevoked",
- MESSAGE_READ_BY_PEER: "onMessageReadByPeer",
- CONVERSATION_LIST_UPDATED: "onConversationListUpdated",
- GROUP_LIST_UPDATED: "onGroupListUpdated",
- GROUP_SYSTEM_NOTICE_RECEIVED: "receiveGroupSystemNotice",
- PROFILE_UPDATED: "onProfileUpdated",
- BLACKLIST_UPDATED: "blacklistUpdated",
- KICKED_OUT: "kickedOut",
- ERROR: "error",
- NET_STATE_CHANGE: "netStateChange",
- SDK_RELOAD: "sdkReload"
- },
- t = {
- MSG_TEXT: "TIMTextElem",
- MSG_IMAGE: "TIMImageElem",
- MSG_SOUND: "TIMSoundElem",
- MSG_AUDIO: "TIMSoundElem",
- MSG_FILE: "TIMFileElem",
- MSG_FACE: "TIMFaceElem",
- MSG_VIDEO: "TIMVideoFileElem",
- MSG_GEO: "TIMLocationElem",
- MSG_GRP_TIP: "TIMGroupTipElem",
- MSG_GRP_SYS_NOTICE: "TIMGroupSystemNoticeElem",
- MSG_CUSTOM: "TIMCustomElem",
- MSG_PRIORITY_HIGH: "High",
- MSG_PRIORITY_NORMAL: "Normal",
- MSG_PRIORITY_LOW: "Low",
- MSG_PRIORITY_LOWEST: "Lowest",
- CONV_C2C: "C2C",
- CONV_GROUP: "GROUP",
- CONV_SYSTEM: "@TIM#SYSTEM",
- CONV_AT_ME: 1,
- CONV_AT_ALL: 2,
- CONV_AT_ALL_AT_ME: 3,
- GRP_PRIVATE: "Private",
- GRP_WORK: "Private",
- GRP_PUBLIC: "Public",
- GRP_CHATROOM: "ChatRoom",
- GRP_MEETING: "ChatRoom",
- GRP_AVCHATROOM: "AVChatRoom",
- GRP_MBR_ROLE_OWNER: "Owner",
- GRP_MBR_ROLE_ADMIN: "Admin",
- GRP_MBR_ROLE_MEMBER: "Member",
- GRP_TIP_MBR_JOIN: 1,
- GRP_TIP_MBR_QUIT: 2,
- GRP_TIP_MBR_KICKED_OUT: 3,
- GRP_TIP_MBR_SET_ADMIN: 4,
- GRP_TIP_MBR_CANCELED_ADMIN: 5,
- GRP_TIP_GRP_PROFILE_UPDATED: 6,
- GRP_TIP_MBR_PROFILE_UPDATED: 7,
- MSG_REMIND_ACPT_AND_NOTE: "AcceptAndNotify",
- MSG_REMIND_ACPT_NOT_NOTE: "AcceptNotNotify",
- MSG_REMIND_DISCARD: "Discard",
- GENDER_UNKNOWN: "Gender_Type_Unknown",
- GENDER_FEMALE: "Gender_Type_Female",
- GENDER_MALE: "Gender_Type_Male",
- KICKED_OUT_MULT_ACCOUNT: "multipleAccount",
- KICKED_OUT_MULT_DEVICE: "multipleDevice",
- KICKED_OUT_USERSIG_EXPIRED: "userSigExpired",
- ALLOW_TYPE_ALLOW_ANY: "AllowType_Type_AllowAny",
- ALLOW_TYPE_NEED_CONFIRM: "AllowType_Type_NeedConfirm",
- ALLOW_TYPE_DENY_ANY: "AllowType_Type_DenyAny",
- FORBID_TYPE_NONE: "AdminForbid_Type_None",
- FORBID_TYPE_SEND_OUT: "AdminForbid_Type_SendOut",
- JOIN_OPTIONS_FREE_ACCESS: "FreeAccess",
- JOIN_OPTIONS_NEED_PERMISSION: "NeedPermission",
- JOIN_OPTIONS_DISABLE_APPLY: "DisableApply",
- JOIN_STATUS_SUCCESS: "JoinedSuccess",
- JOIN_STATUS_ALREADY_IN_GROUP: "AlreadyInGroup",
- JOIN_STATUS_WAIT_APPROVAL: "WaitAdminApproval",
- GRP_PROFILE_OWNER_ID: "ownerID",
- GRP_PROFILE_CREATE_TIME: "createTime",
- GRP_PROFILE_LAST_INFO_TIME: "lastInfoTime",
- GRP_PROFILE_MEMBER_NUM: "memberNum",
- GRP_PROFILE_MAX_MEMBER_NUM: "maxMemberNum",
- GRP_PROFILE_JOIN_OPTION: "joinOption",
- GRP_PROFILE_INTRODUCTION: "introduction",
- GRP_PROFILE_NOTIFICATION: "notification",
- GRP_PROFILE_MUTE_ALL_MBRS: "muteAllMembers",
- NET_STATE_CONNECTED: "connected",
- NET_STATE_CONNECTING: "connecting",
- NET_STATE_DISCONNECTED: "disconnected",
- MSG_AT_ALL: "__kImSDK_MesssageAtALL__"
- };
- function n(e) {
- return (n = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) {
- return typeof e;
- } : function (e) {
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
- })(e);
- }
- function o(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
- }
- function r(e, t) {
- for (var n = 0; n < t.length; n++) {
- var o = t[n];
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, o.key, o);
- }
- }
- function i(e, t, n) {
- return t && r(e.prototype, t), n && r(e, n), e;
- }
- function s(e, t, n) {
- return t in e ? Object.defineProperty(e, t, {
- value: n,
- enumerable: !0,
- configurable: !0,
- writable: !0
- }) : e[t] = n, e;
- }
- function a(e, t) {
- var n = Object.keys(e);
- if (Object.getOwnPropertySymbols) {
- var o = Object.getOwnPropertySymbols(e);
- t && (o = o.filter(function (t) {
- return Object.getOwnPropertyDescriptor(e, t).enumerable;
- })), n.push.apply(n, o);
- }
- return n;
- }
- function u(e) {
- for (var t = 1; t < arguments.length; t++) {
- var n = null != arguments[t] ? arguments[t] : {};
- t % 2 ? a(Object(n), !0).forEach(function (t) {
- s(e, t, n[t]);
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : a(Object(n)).forEach(function (t) {
- Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
- });
- }
- return e;
- }
- function c(e, t) {
- if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
- e.prototype = Object.create(t && t.prototype, {
- constructor: {
- value: e,
- writable: !0,
- configurable: !0
- }
- }), t && p(e, t);
- }
- function l(e) {
- return (l = Object.setPrototypeOf ? Object.getPrototypeOf : function (e) {
- return e.__proto__ || Object.getPrototypeOf(e);
- })(e);
- }
- function p(e, t) {
- return (p = Object.setPrototypeOf || function (e, t) {
- return e.__proto__ = t, e;
- })(e, t);
- }
- function g() {
- if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
- if (Reflect.construct.sham) return !1;
- if ("function" == typeof Proxy) return !0;
- try {
- return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})), !0;
- } catch (e) {
- return !1;
- }
- }
- function h(e, t, n) {
- return (h = g() ? Reflect.construct : function (e, t, n) {
- var o = [null];
- o.push.apply(o, t);
- var r = new (Function.bind.apply(e, o))();
- return n && p(r, n.prototype), r;
- }).apply(null, arguments);
- }
- function d(e) {
- var t = "function" == typeof Map ? new Map() : void 0;
- return (d = function (e) {
- if (null === e || (n = e, -1 === Function.toString.call(n).indexOf("[native code]"))) return e;
- var n;
- if ("function" != typeof e) throw new TypeError("Super expression must either be null or a function");
- if (void 0 !== t) {
- if (t.has(e)) return t.get(e);
- t.set(e, o);
- }
- function o() {
- return h(e, arguments, l(this).constructor);
- }
- return o.prototype = Object.create(e.prototype, {
- constructor: {
- value: o,
- enumerable: !1,
- writable: !0,
- configurable: !0
- }
- }), p(o, e);
- })(e);
- }
- function m(e, t) {
- if (null == e) return {};
- var n,
- o,
- r = function (e, t) {
- if (null == e) return {};
- var n,
- o,
- r = {},
- i = Object.keys(e);
- for (o = 0; o < i.length; o++) n = i[o], t.indexOf(n) >= 0 || (r[n] = e[n]);
- return r;
- }(e, t);
- if (Object.getOwnPropertySymbols) {
- var i = Object.getOwnPropertySymbols(e);
- for (o = 0; o < i.length; o++) n = i[o], t.indexOf(n) >= 0 || Object.prototype.propertyIsEnumerable.call(e, n) && (r[n] = e[n]);
- }
- return r;
- }
- function f(e) {
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- return e;
- }
- function _(e, t) {
- return !t || "object" != typeof t && "function" != typeof t ? f(e) : t;
- }
- function v(e) {
- var t = g();
- return function () {
- var n,
- o = l(e);
- if (t) {
- var r = l(this).constructor;
- n = Reflect.construct(o, arguments, r);
- } else n = o.apply(this, arguments);
- return _(this, n);
- };
- }
- function y(e, t) {
- return M(e) || function (e, t) {
- if ("undefined" == typeof Symbol || !(Symbol.iterator in Object(e))) return;
- var n = [],
- o = !0,
- r = !1,
- i = void 0;
- try {
- for (var s, a = e[Symbol.iterator](); !(o = (s = a.next()).done) && (n.push(s.value), !t || n.length !== t); o = !0);
- } catch (u) {
- r = !0, i = u;
- } finally {
- try {
- o || null == a.return || a.return();
- } finally {
- if (r) throw i;
- }
- }
- return n;
- }(e, t) || E(e, t) || D();
- }
- function I(e) {
- return function (e) {
- if (Array.isArray(e)) return T(e);
- }(e) || C(e) || E(e) || function () {
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }();
- }
- function M(e) {
- if (Array.isArray(e)) return e;
- }
- function C(e) {
- if ("undefined" != typeof Symbol && Symbol.iterator in Object(e)) return Array.from(e);
- }
- function E(e, t) {
- if (e) {
- if ("string" == typeof e) return T(e, t);
- var n = Object.prototype.toString.call(e).slice(8, -1);
- return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? T(e, t) : void 0;
- }
- }
- function T(e, t) {
- (null == t || t > e.length) && (t = e.length);
- for (var n = 0, o = new Array(t); n < t; n++) o[n] = e[n];
- return o;
- }
- function D() {
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- function S(e, t) {
- var n;
- if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) {
- if (Array.isArray(e) || (n = E(e)) || t && e && "number" == typeof e.length) {
- n && (e = n);
- var o = 0,
- r = function () {};
- return {
- s: r,
- n: function () {
- return o >= e.length ? {
- done: !0
- } : {
- done: !1,
- value: e[o++]
- };
- },
- e: function (e) {
- throw e;
- },
- f: r
- };
- }
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- var i,
- s = !0,
- a = !1;
- return {
- s: function () {
- n = e[Symbol.iterator]();
- },
- n: function () {
- var e = n.next();
- return s = e.done, e;
- },
- e: function (e) {
- a = !0, i = e;
- },
- f: function () {
- try {
- s || null == n.return || n.return();
- } finally {
- if (a) throw i;
- }
- }
- };
- }
- var k = function () {
- function e() {
- o(this, e), this.cache = [], this.options = null;
- }
- return i(e, [{
- key: "use",
- value: function (e) {
- if ("function" != typeof e) throw "middleware must be a function";
- return this.cache.push(e), this;
- }
- }, {
- key: "next",
- value: function (e) {
- if (this.middlewares && this.middlewares.length > 0) return this.middlewares.shift().call(this, this.options, this.next.bind(this));
- }
- }, {
- key: "run",
- value: function (e) {
- return this.middlewares = this.cache.map(function (e) {
- return e;
- }), this.options = e, this.next();
- }
- }]), e;
- }(),
- A = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};
- function O(e, t) {
- return e(t = {
- exports: {}
- }, t.exports), t.exports;
- }
- var R,
- N,
- L,
- w,
- P = O(function (e, t) {
- var n, o, r, i, s, a, u, c, l, p, g, h, d, m, f, _, v, y;
- e.exports = (n = "function" == typeof Promise, o = "object" == typeof self ? self : A, r = "undefined" != typeof Symbol, i = "undefined" != typeof Map, s = "undefined" != typeof Set, a = "undefined" != typeof WeakMap, u = "undefined" != typeof WeakSet, c = "undefined" != typeof DataView, l = r && void 0 !== Symbol.iterator, p = r && void 0 !== Symbol.toStringTag, g = s && "function" == typeof Set.prototype.entries, h = i && "function" == typeof Map.prototype.entries, d = g && Object.getPrototypeOf(new Set().entries()), m = h && Object.getPrototypeOf(new Map().entries()), f = l && "function" == typeof Array.prototype[Symbol.iterator], _ = f && Object.getPrototypeOf([][Symbol.iterator]()), v = l && "function" == typeof String.prototype[Symbol.iterator], y = v && Object.getPrototypeOf(""[Symbol.iterator]()), function (e) {
- var t = typeof e;
- if ("object" !== t) return t;
- if (null === e) return "null";
- if (e === o) return "global";
- if (Array.isArray(e) && (!1 === p || !(Symbol.toStringTag in e))) return "Array";
- if ("object" == typeof window && null !== window) {
- if ("object" == typeof window.location && e === window.location) return "Location";
- if ("object" == typeof window.document && e === window.document) return "Document";
- if ("object" == typeof window.navigator) {
- if ("object" == typeof window.navigator.mimeTypes && e === window.navigator.mimeTypes) return "MimeTypeArray";
- if ("object" == typeof window.navigator.plugins && e === window.navigator.plugins) return "PluginArray";
- }
- if (("function" == typeof window.HTMLElement || "object" == typeof window.HTMLElement) && e instanceof window.HTMLElement) {
- if ("BLOCKQUOTE" === e.tagName) return "HTMLQuoteElement";
- if ("TD" === e.tagName) return "HTMLTableDataCellElement";
- if ("TH" === e.tagName) return "HTMLTableHeaderCellElement";
- }
- }
- var r = p && e[Symbol.toStringTag];
- if ("string" == typeof r) return r;
- var l = Object.getPrototypeOf(e);
- return l === RegExp.prototype ? "RegExp" : l === Date.prototype ? "Date" : n && l === Promise.prototype ? "Promise" : s && l === Set.prototype ? "Set" : i && l === Map.prototype ? "Map" : u && l === WeakSet.prototype ? "WeakSet" : a && l === WeakMap.prototype ? "WeakMap" : c && l === DataView.prototype ? "DataView" : i && l === m ? "Map Iterator" : s && l === d ? "Set Iterator" : f && l === _ ? "Array Iterator" : v && l === y ? "String Iterator" : null === l ? "Object" : Object.prototype.toString.call(e).slice(8, -1);
- });
- }),
- G = "undefined" != typeof window,
- b = "undefined" != typeof uni && "function" == typeof uni.getSystemInfoSync,
- U = "undefined" != typeof qq && "function" == typeof qq.getSystemInfoSync,
- q = "undefined" != typeof tt && "function" == typeof tt.getSystemInfoSync,
- F = "undefined" != typeof swan && "function" == typeof swan.getSystemInfoSync,
- x = "undefined" != typeof my && "function" == typeof my.getSystemInfoSync,
- V = b || U || q || F || x,
- K = U ? qq : q ? tt : F ? swan : x ? my : b ? uni : {},
- H = (R = "web", oe ? R = "wechat" : U ? R = "qqmp" : q ? R = "ttmp" : F ? R = "baidump" : x ? R = "alipaymp" : b && (R = "wxmp"), R),
- B = G && window.navigator && window.navigator.userAgent || "",
- j = /AppleWebKit\/([\d.]+)/i.exec(B),
- $ = (j && parseFloat(j.pop()), /iPad/i.test(B)),
- Y = /iPhone/i.test(B) && !$,
- z = /iPod/i.test(B),
- W = Y || $ || z,
- J = ((N = B.match(/OS (\d+)_/i)) && N[1] && N[1], /Android/i.test(B)),
- X = function () {
- var e = B.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);
- if (!e) return null;
- var t = e[1] && parseFloat(e[1]),
- n = e[2] && parseFloat(e[2]);
- return t && n ? parseFloat(e[1] + "." + e[2]) : t || null;
- }(),
- Q = (J && /webkit/i.test(B), /Firefox/i.test(B), /Edge/i.test(B)),
- Z = !Q && /Chrome/i.test(B),
- ee = (function () {
- var e = B.match(/Chrome\/(\d+)/);
- e && e[1] && parseFloat(e[1]);
- }(), /MSIE/.test(B)),
- te = (/MSIE\s8\.0/.test(B), function () {
- var e = /MSIE\s(\d+)\.\d/.exec(B),
- t = e && parseFloat(e[1]);
- return !t && /Trident\/7.0/i.test(B) && /rv:11.0/.test(B) && (t = 11), t;
- }()),
- ne = (/Safari/i.test(B), /TBS\/\d+/i.test(B)),
- oe = (function () {
- var e = B.match(/TBS\/(\d+)/i);
- if (e && e[1]) e[1];
- }(), !ne && /MQQBrowser\/\d+/i.test(B), !ne && / QQBrowser\/\d+/i.test(B), /(micromessenger|webbrowser)/i.test(B)),
- re = /Windows/i.test(B),
- ie = /MAC OS X/i.test(B),
- se = (/MicroMessenger/i.test(B), "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {});
- L = "undefined" != typeof console ? console : void 0 !== se && se.console ? se.console : "undefined" != typeof window && window.console ? window.console : {};
- for (var ae = function () {}, ue = ["assert", "clear", "count", "debug", "dir", "dirxml", "error", "exception", "group", "groupCollapsed", "groupEnd", "info", "log", "markTimeline", "profile", "profileEnd", "table", "time", "timeEnd", "timeStamp", "trace", "warn"], ce = ue.length; ce--;) w = ue[ce], console[w] || (L[w] = ae);
- L.methods = ue;
- var le = L,
- pe = 0,
- ge = new Map();
- function he() {
- var e = new Date();
- return "TIM " + e.toLocaleTimeString("en-US", {
- hour12: !1
- }) + "." + function (e) {
- var t;
- switch (e.toString().length) {
- case 1:
- t = "00" + e;
- break;
- case 2:
- t = "0" + e;
- break;
- default:
- t = e;
- }
- return t;
- }(e.getMilliseconds()) + ":";
- }
- var de = {
- arguments2String: function (e) {
- var t;
- if (1 === e.length) t = he() + e[0];else {
- t = he();
- for (var n = 0, o = e.length; n < o; n++) Ce(e[n]) ? Te(e[n]) ? t += Re(e[n]) : t += JSON.stringify(e[n]) : t += e[n], t += " ";
- }
- return t;
- },
- debug: function () {
- if (pe <= -1) {
- var e = this.arguments2String(arguments);
- le.debug(e);
- }
- },
- log: function () {
- if (pe <= 0) {
- var e = this.arguments2String(arguments);
- le.log(e);
- }
- },
- info: function () {
- if (pe <= 1) {
- var e = this.arguments2String(arguments);
- le.info(e);
- }
- },
- warn: function () {
- if (pe <= 2) {
- var e = this.arguments2String(arguments);
- le.warn(e);
- }
- },
- error: function () {
- if (pe <= 3) {
- var e = this.arguments2String(arguments);
- le.error(e);
- }
- },
- time: function (e) {
- ge.set(e, Ae.now());
- },
- timeEnd: function (e) {
- if (ge.has(e)) {
- var t = Ae.now() - ge.get(e);
- return ge.delete(e), t;
- }
- return le.warn("未找到对应label: ".concat(e, ", 请在调用 logger.timeEnd 前,调用 logger.time")), 0;
- },
- setLevel: function (e) {
- e < 4 && le.log(he() + "set level from " + pe + " to " + e), pe = e;
- }
- },
- me = function (e) {
- return "file" === De(e);
- },
- fe = function (e) {
- return null !== e && ("number" == typeof e && !isNaN(e - 0) || "object" === n(e) && e.constructor === Number);
- },
- _e = function (e) {
- return "string" == typeof e;
- },
- ve = function (e) {
- return null !== e && "object" === n(e);
- },
- ye = function (e) {
- if ("object" !== n(e) || null === e) return !1;
- var t = Object.getPrototypeOf(e);
- if (null === t) return !0;
- for (var o = t; null !== Object.getPrototypeOf(o);) o = Object.getPrototypeOf(o);
- return t === o;
- },
- Ie = function (e) {
- return "function" == typeof Array.isArray ? Array.isArray(e) : "array" === De(e);
- },
- Me = function (e) {
- return void 0 === e;
- },
- Ce = function (e) {
- return Ie(e) || ve(e);
- },
- Ee = function (e) {
- return "function" == typeof e;
- },
- Te = function (e) {
- return e instanceof Error;
- },
- De = function (e) {
- return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase();
- },
- Se = function (e) {
- if ("string" != typeof e) return !1;
- var t = e[0];
- return !/[^a-zA-Z0-9]/.test(t);
- },
- ke = 0;
- Date.now || (Date.now = function () {
- return new Date().getTime();
- });
- var Ae = {
- now: function () {
- 0 === ke && (ke = Date.now() - 1);
- var e = Date.now() - ke;
- return e > 4294967295 ? (ke += 4294967295, Date.now() - ke) : e;
- },
- utc: function () {
- return Math.round(Date.now() / 1e3);
- }
- },
- Oe = function e(t, n, o, r) {
- if (!Ce(t) || !Ce(n)) return 0;
- for (var i, s = 0, a = Object.keys(n), u = 0, c = a.length; u < c; u++) if (i = a[u], !(Me(n[i]) || o && o.includes(i))) if (Ce(t[i]) && Ce(n[i])) s += e(t[i], n[i], o, r);else {
- if (r && r.includes(n[i])) continue;
- t[i] !== n[i] && (t[i] = n[i], s += 1);
- }
- return s;
- },
- Re = function (e) {
- return JSON.stringify(e, ["message", "code"]);
- },
- Ne = function () {
- var e = new Date(),
- t = e.toISOString(),
- n = e.getTimezoneOffset() / 60,
- o = "";
- return o = n < 0 ? n > -10 ? "+0" + Math.abs(100 * n) : "+" + Math.abs(100 * n) : n >= 10 ? "-" + 100 * n : "-0" + 100 * n, t.replace("Z", o);
- },
- Le = function (e) {
- if (0 === e.length) return 0;
- for (var t = 0, n = 0, o = "undefined" != typeof document && void 0 !== document.characterSet ? document.characterSet : "UTF-8"; void 0 !== e[t];) n += e[t++].charCodeAt[t] <= 255 ? 1 : !1 === o ? 3 : 2;
- return n;
- },
- we = function (e) {
- var t = e || 99999999;
- return Math.round(Math.random() * t);
- },
- Pe = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
- Ge = Pe.length,
- be = function (e, t) {
- for (var n in e) if (e[n] === t) return !0;
- return !1;
- },
- Ue = {},
- qe = function () {
- if (V) return "https:";
- var e = window.location.protocol;
- return ["http:", "https:"].indexOf(e) < 0 && (e = "http:"), e;
- },
- Fe = function (e) {
- return -1 === e.indexOf("http://") || -1 === e.indexOf("https://") ? "https://" + e : e.replace(/https|http/, "https");
- };
- function xe(e, t) {
- Ie(e) && Ie(t) ? t.forEach(function (t) {
- var n = t.key,
- o = t.value,
- r = e.find(function (e) {
- return e.key === n;
- });
- r ? r.value = o : e.push({
- key: n,
- value: o
- });
- }) : de.warn("updateCustomField target 或 source 不是数组,忽略此次更新。");
- }
- var Ve = function (e) {
- return e === t.GRP_WORK;
- },
- Ke = function (e) {
- return e === t.GRP_PUBLIC;
- },
- He = function (e) {
- return e === t.GRP_MEETING;
- },
- Be = function (e) {
- return e === t.GRP_AVCHATROOM;
- },
- je = function (e) {
- return _e(e) && e === t.CONV_SYSTEM;
- };
- function $e(e, t) {
- var n = {};
- return Object.keys(e).forEach(function (o) {
- n[o] = t(e[o], o);
- }), n;
- }
- function Ye() {
- function e() {
- return (65536 * (1 + Math.random()) | 0).toString(16).substring(1);
- }
- return "".concat(e() + e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e());
- }
- function ze(e) {
- var t = e.originUrl,
- n = void 0 === t ? void 0 : t,
- o = e.originWidth,
- r = e.originHeight,
- i = e.min,
- s = void 0 === i ? 198 : i,
- a = parseInt(o),
- u = parseInt(r),
- c = {
- url: void 0,
- width: 0,
- height: 0
- };
- return (a <= u ? a : u) <= s ? (c.url = n, c.width = a, c.height = u) : (u <= a ? (c.width = Math.ceil(a * s / u), c.height = s) : (c.width = s, c.height = Math.ceil(u * s / a)), c.url = "".concat(n, 198 === s ? "?imageView2/3/w/198/h/198" : "?imageView2/3/w/720/h/720")), Me(n) ? m(c, ["url"]) : c;
- }
- function We(e) {
- var t = e[2];
- e[2] = e[1], e[1] = t;
- for (var n = 0; n < e.length; n++) e[n].setSizeType(n + 1), e[n].setType(n);
- }
- var Je = Object.prototype.hasOwnProperty;
- function Xe(e) {
- if (null == e) return !0;
- if ("boolean" == typeof e) return !1;
- if ("number" == typeof e) return 0 === e;
- if ("string" == typeof e) return 0 === e.length;
- if ("function" == typeof e) return 0 === e.length;
- if (Array.isArray(e)) return 0 === e.length;
- if (e instanceof Error) return "" === e.message;
- if (ye(e)) {
- for (var t in e) if (Je.call(e, t)) return !1;
- return !0;
- }
- return !("map" !== De(e) && !function (e) {
- return "set" === De(e);
- }(e) && !me(e)) && 0 === e.size;
- }
- function Qe(e, t, n) {
- if (void 0 === t) return !0;
- var o = !0;
- if ("object" === P(t).toLowerCase()) Object.keys(t).forEach(function (r) {
- var i = 1 === e.length ? e[0][r] : void 0;
- o = !!Ze(i, t[r], n, r) && o;
- });else if ("array" === P(t).toLowerCase()) for (var r = 0; r < t.length; r++) o = !!Ze(e[r], t[r], n, t[r].name) && o;
- if (o) return o;
- throw new Error("Params validate failed.");
- }
- function Ze(e, t, n, o) {
- if (void 0 === t) return !0;
- var r = !0;
- return t.required && Xe(e) && (le.error("TIM [".concat(n, '] Missing required params: "').concat(o, '".')), r = !1), Xe(e) || P(e).toLowerCase() === t.type.toLowerCase() || (le.error("TIM [".concat(n, '] Invalid params: type check failed for "').concat(o, '".Expected ').concat(t.type, ".")), r = !1), t.validator && !t.validator(e) && (le.error("TIM [".concat(n, "] Invalid params: custom validator check failed for params.")), r = !1), r;
- }
- var et = {
- SUCCESS: "JoinedSuccess",
- WAIT_APPROVAL: "WaitAdminApproval"
- },
- nt = {
- SUCCESS: 0
- },
- ot = {
- IS_LOGIN: 1,
- IS_NOT_LOGIN: 0
- },
- rt = {
- UNSEND: "unSend",
- SUCCESS: "success",
- FAIL: "fail"
- },
- it = {
- NOT_START: "notStart",
- PENDING: "pengding",
- RESOLVED: "resolved",
- REJECTED: "rejected"
- },
- st = function () {
- function e(n) {
- o(this, e), this.type = t.MSG_TEXT, this.content = {
- text: n.text || ""
- };
- }
- return i(e, [{
- key: "setText",
- value: function (e) {
- this.content.text = e;
- }
- }, {
- key: "sendable",
- value: function () {
- return 0 !== this.content.text.length;
- }
- }]), e;
- }(),
- at = {
- JSON: {
- TYPE: {
- C2C: {
- NOTICE: 1,
- COMMON: 9,
- EVENT: 10
- },
- GROUP: {
- COMMON: 3,
- TIP: 4,
- SYSTEM: 5,
- TIP2: 6
- },
- FRIEND: {
- NOTICE: 7
- },
- PROFILE: {
- NOTICE: 8
- }
- },
- SUBTYPE: {
- C2C: {
- COMMON: 0,
- READED: 92,
- KICKEDOUT: 96
- },
- GROUP: {
- COMMON: 0,
- LOVEMESSAGE: 1,
- TIP: 2,
- REDPACKET: 3
- }
- },
- OPTIONS: {
- GROUP: {
- JOIN: 1,
- QUIT: 2,
- KICK: 3,
- SET_ADMIN: 4,
- CANCEL_ADMIN: 5,
- MODIFY_GROUP_INFO: 6,
- MODIFY_MEMBER_INFO: 7
- }
- }
- },
- PROTOBUF: {},
- IMAGE_TYPES: {
- ORIGIN: 1,
- LARGE: 2,
- SMALL: 3
- },
- IMAGE_FORMAT: {
- JPG: 1,
- JPEG: 1,
- GIF: 2,
- PNG: 3,
- BMP: 4,
- UNKNOWN: 255
- }
- },
- ut = 1,
- ct = 2,
- lt = 3,
- pt = 4,
- gt = 5,
- ht = 7,
- dt = 8,
- mt = 9,
- ft = 10,
- _t = 15,
- vt = 255,
- yt = 2,
- It = 0,
- Mt = 1,
- Ct = {
- NICK: "Tag_Profile_IM_Nick",
- GENDER: "Tag_Profile_IM_Gender",
- BIRTHDAY: "Tag_Profile_IM_BirthDay",
- LOCATION: "Tag_Profile_IM_Location",
- SELFSIGNATURE: "Tag_Profile_IM_SelfSignature",
- ALLOWTYPE: "Tag_Profile_IM_AllowType",
- LANGUAGE: "Tag_Profile_IM_Language",
- AVATAR: "Tag_Profile_IM_Image",
- MESSAGESETTINGS: "Tag_Profile_IM_MsgSettings",
- ADMINFORBIDTYPE: "Tag_Profile_IM_AdminForbidType",
- LEVEL: "Tag_Profile_IM_Level",
- ROLE: "Tag_Profile_IM_Role"
- },
- Et = {
- UNKNOWN: "Gender_Type_Unknown",
- FEMALE: "Gender_Type_Female",
- MALE: "Gender_Type_Male"
- },
- Tt = {
- NONE: "AdminForbid_Type_None",
- SEND_OUT: "AdminForbid_Type_SendOut"
- },
- Dt = {
- NEED_CONFIRM: "AllowType_Type_NeedConfirm",
- ALLOW_ANY: "AllowType_Type_AllowAny",
- DENY_ANY: "AllowType_Type_DenyAny"
- },
- St = function () {
- function e(n) {
- o(this, e), this._imageMemoryURL = "", this._file = n.file, V ? this.createImageDataASURLInWXMiniApp(n.file) : this.createImageDataASURLInWeb(n.file), this._initImageInfoModel(), this.type = t.MSG_IMAGE, this._percent = 0, this.content = {
- imageFormat: n.imageFormat || at.IMAGE_FORMAT.UNKNOWN,
- uuid: n.uuid,
- imageInfoArray: []
- }, this.initImageInfoArray(n.imageInfoArray), this._defaultImage = "http://imgcache.qq.com/open/qcloud/video/act/webim-images/default.jpg", this._autoFixUrl();
- }
- return i(e, [{
- key: "_initImageInfoModel",
- value: function () {
- var e = this;
- this._ImageInfoModel = function (t) {
- this.instanceID = we(9999999), this.sizeType = t.type || 0, this.type = 0, this.size = t.size || 0, this.width = t.width || 0, this.height = t.height || 0, this.imageUrl = t.url || "", this.url = t.url || e._imageMemoryURL || e._defaultImage;
- }, this._ImageInfoModel.prototype = {
- setSizeType: function (e) {
- this.sizeType = e;
- },
- setType: function (e) {
- this.type = e;
- },
- setImageUrl: function (e) {
- e && (this.imageUrl = e);
- },
- getImageUrl: function () {
- return this.imageUrl;
- }
- };
- }
- }, {
- key: "initImageInfoArray",
- value: function (e) {
- for (var t = 0, n = null, o = null; t <= 2;) o = Me(e) || Me(e[t]) ? {
- type: 0,
- size: 0,
- width: 0,
- height: 0,
- url: ""
- } : e[t], (n = new this._ImageInfoModel(o)).setSizeType(t + 1), n.setType(t), this.addImageInfo(n), t++;
- this.updateAccessSideImageInfoArray();
- }
- }, {
- key: "updateImageInfoArray",
- value: function (e) {
- for (var t, n = this.content.imageInfoArray.length, o = 0; o < n; o++) t = this.content.imageInfoArray[o], e[o].size && (t.size = e[o].size), e[o].url && t.setImageUrl(e[o].url), e[o].width && (t.width = e[o].width), e[o].height && (t.height = e[o].height);
- }
- }, {
- key: "_autoFixUrl",
- value: function () {
- for (var e = this.content.imageInfoArray.length, t = "", n = "", o = ["http", "https"], r = null, i = 0; i < e; i++) this.content.imageInfoArray[i].url && "" !== (r = this.content.imageInfoArray[i]).imageUrl && (n = r.imageUrl.slice(0, r.imageUrl.indexOf("://") + 1), t = r.imageUrl.slice(r.imageUrl.indexOf("://") + 1), o.indexOf(n) < 0 && (n = "https:"), this.content.imageInfoArray[i].setImageUrl([n, t].join("")));
- }
- }, {
- key: "updatePercent",
- value: function (e) {
- this._percent = e, this._percent > 1 && (this._percent = 1);
- }
- }, {
- key: "updateImageFormat",
- value: function (e) {
- this.content.imageFormat = at.IMAGE_FORMAT[e.toUpperCase()] || at.IMAGE_FORMAT.UNKNOWN;
- }
- }, {
- key: "createImageDataASURLInWeb",
- value: function (e) {
- void 0 !== e && e.files.length > 0 && (this._imageMemoryURL = window.URL.createObjectURL(e.files[0]));
- }
- }, {
- key: "createImageDataASURLInWXMiniApp",
- value: function (e) {
- e && e.url && (this._imageMemoryURL = e.url);
- }
- }, {
- key: "replaceImageInfo",
- value: function (e, t) {
- this.content.imageInfoArray[t] instanceof this._ImageInfoModel || (this.content.imageInfoArray[t] = e);
- }
- }, {
- key: "addImageInfo",
- value: function (e) {
- this.content.imageInfoArray.length >= 3 || this.content.imageInfoArray.push(e);
- }
- }, {
- key: "updateAccessSideImageInfoArray",
- value: function () {
- var e = this.content.imageInfoArray,
- t = e[0],
- n = t.width,
- o = void 0 === n ? 0 : n,
- r = t.height,
- i = void 0 === r ? 0 : r;
- 0 !== o && 0 !== i && (We(e), Object.assign(e[2], ze({
- originWidth: o,
- originHeight: i,
- min: 720
- })));
- }
- }, {
- key: "sendable",
- value: function () {
- return 0 !== this.content.imageInfoArray.length && "" !== this.content.imageInfoArray[0].imageUrl && 0 !== this.content.imageInfoArray[0].size;
- }
- }]), e;
- }(),
- kt = function () {
- function e(n) {
- o(this, e), this.type = t.MSG_FACE, this.content = n || null;
- }
- return i(e, [{
- key: "sendable",
- value: function () {
- return null !== this.content;
- }
- }]), e;
- }(),
- At = function () {
- function e(n) {
- o(this, e), this.type = t.MSG_AUDIO, this._percent = 0, this.content = {
- downloadFlag: 2,
- second: n.second,
- size: n.size,
- url: n.url,
- remoteAudioUrl: "",
- uuid: n.uuid
- };
- }
- return i(e, [{
- key: "updatePercent",
- value: function (e) {
- this._percent = e, this._percent > 1 && (this._percent = 1);
- }
- }, {
- key: "updateAudioUrl",
- value: function (e) {
- this.content.remoteAudioUrl = e;
- }
- }, {
- key: "sendable",
- value: function () {
- return "" !== this.content.remoteAudioUrl;
- }
- }]), e;
- }(),
- Ot = {
- from: !0,
- groupID: !0,
- groupName: !0,
- to: !0
- },
- Rt = function () {
- function e(n) {
- o(this, e), this.type = t.MSG_GRP_TIP, this.content = {}, this._initContent(n);
- }
- return i(e, [{
- key: "_initContent",
- value: function (e) {
- var t = this;
- Object.keys(e).forEach(function (n) {
- switch (n) {
- case "remarkInfo":
- break;
- case "groupProfile":
- t.content.groupProfile = {}, t._initGroupProfile(e[n]);
- break;
- case "operatorInfo":
- case "memberInfoList":
- break;
- case "msgMemberInfo":
- t.content.memberList = e[n], Object.defineProperty(t.content, "msgMemberInfo", {
- get: function () {
- return de.warn("!!! 禁言的群提示消息中的 payload.msgMemberInfo 属性即将废弃,请使用 payload.memberList 属性替代。 \n", "msgMemberInfo 中的 shutupTime 属性对应更改为 memberList 中的 muteTime 属性,表示禁言时长。 \n", "参考:群提示消息 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/Message.html#.GroupTipPayload"), t.content.memberList.map(function (e) {
- return {
- userID: e.userID,
- shutupTime: e.muteTime
- };
- });
- }
- });
- break;
- case "onlineMemberInfo":
- break;
- case "memberNum":
- t.content[n] = e[n], t.content.memberCount = e[n];
- break;
- default:
- t.content[n] = e[n];
- }
- }), this.content.userIDList || (this.content.userIDList = [this.content.operatorID]);
- }
- }, {
- key: "_initGroupProfile",
- value: function (e) {
- for (var t = Object.keys(e), n = 0; n < t.length; n++) {
- var o = t[n];
- Ot[o] && (this.content.groupProfile[o] = e[o]);
- }
- }
- }]), e;
- }(),
- Nt = {
- from: !0,
- groupID: !0,
- name: !0,
- to: !0
- },
- Lt = function () {
- function e(n) {
- o(this, e), this.type = t.MSG_GRP_SYS_NOTICE, this.content = {}, this._initContent(n);
- }
- return i(e, [{
- key: "_initContent",
- value: function (e) {
- var t = this;
- Object.keys(e).forEach(function (n) {
- switch (n) {
- case "memberInfoList":
- break;
- case "remarkInfo":
- t.content.handleMessage = e[n];
- break;
- case "groupProfile":
- t.content.groupProfile = {}, t._initGroupProfile(e[n]);
- break;
- default:
- t.content[n] = e[n];
- }
- });
- }
- }, {
- key: "_initGroupProfile",
- value: function (e) {
- for (var t = Object.keys(e), n = 0; n < t.length; n++) {
- var o = t[n];
- Nt[o] && (this.content.groupProfile[o] = e[o]);
- }
- }
- }]), e;
- }(),
- wt = "https://cloud.tencent.com/document/product/",
- Pt = "您可以在即时通信 IM 控制台的【开发辅助工具(https://console.cloud.tencent.com/im-detail/tool-usersig)】页面校验 UserSig。",
- Gt = "UserSig 非法,请使用官网提供的 API 重新生成 UserSig(".concat(wt, "269/32688)。"),
- bt = {
- 70001: "UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。",
- 70002: "UserSig 长度为0,请检查传入的 UserSig 是否正确。",
- 70003: Gt,
- 70005: Gt,
- 70009: "UserSig 验证失败,可能因为生成 UserSig 时混用了其他 SDKAppID 的私钥或密钥导致,请使用对应 SDKAppID 下的私钥或密钥重新生成 UserSig(".concat(wt, "269/32688)。"),
- 70013: "请求中的 UserID 与生成 UserSig 时使用的 UserID 不匹配。".concat(Pt),
- 70014: "请求中的 SDKAppID 与生成 UserSig 时使用的 SDKAppID 不匹配。".concat(Pt),
- 70016: "密钥不存在,UserSig 验证失败,请在即时通信 IM 控制台获取密钥(".concat(wt, "269/32578#.E8.8E.B7.E5.8F.96.E5.AF.86.E9.92.A5)。"),
- 70020: "SDKAppID 未找到,请在即时通信 IM 控制台确认应用信息。",
- 70050: "UserSig 验证次数过于频繁。请检查 UserSig 是否正确,并于1分钟后重新验证。".concat(Pt),
- 70051: "帐号被拉入黑名单。",
- 70052: "UserSig 已经失效,请重新生成,再次尝试。",
- 70107: "因安全原因被限制登录,请不要频繁登录。",
- 70169: "请求的用户帐号不存在。",
- 70114: "".concat("服务端内部超时,请稍后重试。"),
- 70202: "".concat("服务端内部超时,请稍后重试。"),
- 70206: "请求中批量数量不合法。",
- 70402: "参数非法,请检查必填字段是否填充,或者字段的填充是否满足协议要求。",
- 70403: "请求失败,需要 App 管理员权限。",
- 70398: "帐号数超限。如需创建多于100个帐号,请将应用升级为专业版,具体操作指引请参见购买指引(".concat(wt, "269/32458)。"),
- 70500: "".concat("服务端内部错误,请重试。"),
- 71e3: "删除帐号失败。仅支持删除体验版帐号,您当前应用为专业版,暂不支持帐号删除。",
- 20001: "请求包非法。",
- 20002: "UserSig 或 A2 失效。",
- 20003: "消息发送方或接收方 UserID 无效或不存在,请检查 UserID 是否已导入即时通信 IM。",
- 20004: "网络异常,请重试。",
- 20005: "".concat("服务端内部错误,请重试。"),
- 20006: "触发发送".concat("单聊消息", "之前回调,App 后台返回禁止下发该消息。"),
- 20007: "发送".concat("单聊消息", ",被对方拉黑,禁止发送。消息发送状态默认展示为失败,您可以登录控制台修改该场景下的消息发送状态展示结果,具体操作请参见消息保留设置(").concat(wt, "269/38656)。"),
- 20009: "消息发送双方互相不是好友,禁止发送(配置".concat("单聊消息", "校验好友关系才会出现)。"),
- 20010: "发送".concat("单聊消息", ",自己不是对方的好友(单向关系),禁止发送。"),
- 20011: "发送".concat("单聊消息", ",对方不是自己的好友(单向关系),禁止发送。"),
- 20012: "发送方被禁言,该条消息被禁止发送。",
- 20016: "消息撤回超过了时间限制(默认2分钟)。",
- 20018: "删除漫游内部错误。",
- 90001: "JSON 格式解析失败,请检查请求包是否符合 JSON 规范。",
- 90002: "".concat("JSON 格式请求包体", "中 MsgBody 不符合消息格式描述,或者 MsgBody 不是 Array 类型,请参考 TIMMsgElement 对象的定义(").concat(wt, "269/2720#.E6.B6.88.E6.81.AF.E5.85.83.E7.B4.A0-timmsgelement)。"),
- 90003: "".concat("JSON 格式请求包体", "中缺少 To_Account 字段或者 To_Account 帐号不存在。"),
- 90005: "".concat("JSON 格式请求包体", "中缺少 MsgRandom 字段或者 MsgRandom 字段不是 Integer 类型。"),
- 90006: "".concat("JSON 格式请求包体", "中缺少 MsgTimeStamp 字段或者 MsgTimeStamp 字段不是 Integer 类型。"),
- 90007: "".concat("JSON 格式请求包体", "中 MsgBody 类型不是 Array 类型,请将其修改为 Array 类型。"),
- 90008: "".concat("JSON 格式请求包体", "中缺少 From_Account 字段或者 From_Account 帐号不存在。"),
- 90009: "请求需要 App 管理员权限。",
- 90010: "".concat("JSON 格式请求包体", "不符合消息格式描述,请参考 TIMMsgElement 对象的定义(").concat(wt, "269/2720#.E6.B6.88.E6.81.AF.E5.85.83.E7.B4.A0-timmsgelement)。"),
- 90011: "批量发消息目标帐号超过500,请减少 To_Account 中目标帐号数量。",
- 90012: "To_Account 没有注册或不存在,请确认 To_Account 是否导入即时通信 IM 或者是否拼写错误。",
- 90026: "消息离线存储时间错误(最多不能超过7天)。",
- 90031: "".concat("JSON 格式请求包体", "中 SyncOtherMachine 字段不是 Integer 类型。"),
- 90044: "".concat("JSON 格式请求包体", "中 MsgLifeTime 字段不是 Integer 类型。"),
- 90048: "请求的用户帐号不存在。",
- 90054: "撤回请求中的 MsgKey 不合法。",
- 90994: "".concat("服务端内部错误,请重试。"),
- 90995: "".concat("服务端内部错误,请重试。"),
- 91e3: "".concat("服务端内部错误,请重试。"),
- 90992: "".concat("服务端内部错误,请重试。", "如果所有请求都返回该错误码,且 App 配置了第三方回调,请检查 App 服务端是否正常向即时通信 IM 后台服务端返回回调结果。"),
- 93e3: "JSON 数据包超长,消息包体请不要超过8k。",
- 91101: "Web 端长轮询被踢(Web 端同时在线实例个数超出限制)。",
- 10002: "".concat("服务端内部错误,请重试。"),
- 10003: "请求中的接口名称错误,请核对接口名称并重试。",
- 10004: "参数非法,请根据错误描述检查请求是否正确。",
- 10005: "请求包体中携带的帐号数量过多。",
- 10006: "操作频率限制,请尝试降低调用的频率。",
- 10007: "操作权限不足,例如 Work ".concat("群组", "中普通成员尝试执行踢人操作,但只有 App 管理员才有权限。"),
- 10008: "请求非法,可能是请求中携带的签名信息验证不正确,请再次尝试。",
- 10009: "该群不允许群主主动退出。",
- 10010: "".concat("群组", "不存在,或者曾经存在过,但是目前已经被解散。"),
- 10011: "解析 JSON 包体失败,请检查包体的格式是否符合 JSON 格式。",
- 10012: "发起操作的 UserID 非法,请检查发起操作的用户 UserID 是否填写正确。",
- 10013: "被邀请加入的用户已经是群成员。",
- 10014: "群已满员,无法将请求中的用户加入".concat("群组", ",如果是批量加人,可以尝试减少加入用户的数量。"),
- 10015: "找不到指定 ID 的".concat("群组", "。"),
- 10016: "App 后台通过第三方回调拒绝本次操作。",
- 10017: "因被禁言而不能发送消息,请检查发送者是否被设置禁言。",
- 10018: "应答包长度超过最大包长(1MB),请求的内容过多,请尝试减少单次请求的数据量。",
- 10019: "请求的用户帐号不存在。",
- 10021: "".concat("群组", " ID 已被使用,请选择其他的").concat("群组", " ID。"),
- 10023: "发消息的频率超限,请延长两次发消息时间的间隔。",
- 10024: "此邀请或者申请请求已经被处理。",
- 10025: "".concat("群组", " ID 已被使用,并且操作者为群主,可以直接使用。"),
- 10026: "该 SDKAppID 请求的命令字已被禁用。",
- 10030: "请求撤回的消息不存在。",
- 10031: "消息撤回超过了时间限制(默认2分钟)。",
- 10032: "请求撤回的消息不支持撤回操作。",
- 10033: "".concat("群组", "类型不支持消息撤回操作。"),
- 10034: "该消息类型不支持删除操作。",
- 10035: "直播群和在线成员广播大群不支持删除消息。",
- 10036: "直播群创建数量超过了限制,请参考价格说明(".concat(wt, "269/11673)购买预付费套餐“IM直播群”。"),
- 10037: "单个用户可创建和加入的".concat("群组", "数量超过了限制,请参考价格说明(").concat(wt, "269/11673)购买或升级预付费套餐“单人可创建与加入").concat("群组", "数”。"),
- 10038: "群成员数量超过限制,请参考价格说明(".concat(wt, "269/11673)购买或升级预付费套餐“扩展群人数上限”。"),
- 10041: "该应用(SDKAppID)已配置不支持群消息撤回。"
- },
- Ut = function (e) {
- c(n, e);
- var t = v(n);
- function n(e) {
- var r;
- return o(this, n), (r = t.call(this)).code = e.code, r.message = bt[e.code] || e.message, r.data = e.data || {}, r;
- }
- return n;
- }(d(Error)),
- qt = {
- NO_SDKAPPID: 2e3,
- NO_ACCOUNT_TYPE: 2001,
- NO_IDENTIFIER: 2002,
- NO_USERSIG: 2003,
- NO_TINYID: 2022,
- NO_A2KEY: 2023,
- USER_NOT_LOGGED_IN: 2024,
- COS_UNDETECTED: 2040,
- MESSAGE_SEND_FAIL: 2100,
- MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS: 2103,
- MESSAGE_SEND_NEED_MESSAGE_INSTANCE: 2105,
- MESSAGE_SEND_INVALID_CONVERSATION_TYPE: 2106,
- MESSAGE_FILE_IS_EMPTY: 2108,
- MESSAGE_ONPROGRESS_FUNCTION_ERROR: 2109,
- MESSAGE_REVOKE_FAIL: 2110,
- MESSAGE_IMAGE_SELECT_FILE_FIRST: 2251,
- MESSAGE_IMAGE_TYPES_LIMIT: 2252,
- MESSAGE_IMAGE_SIZE_LIMIT: 2253,
- MESSAGE_AUDIO_UPLOAD_FAIL: 2300,
- MESSAGE_AUDIO_SIZE_LIMIT: 2301,
- MESSAGE_VIDEO_UPLOAD_FAIL: 2350,
- MESSAGE_VIDEO_SIZE_LIMIT: 2351,
- MESSAGE_VIDEO_TYPES_LIMIT: 2352,
- MESSAGE_FILE_UPLOAD_FAIL: 2400,
- MESSAGE_FILE_SELECT_FILE_FIRST: 2401,
- MESSAGE_FILE_SIZE_LIMIT: 2402,
- MESSAGE_FILE_URL_IS_EMPTY: 2403,
- CONVERSATION_NOT_FOUND: 2500,
- USER_OR_GROUP_NOT_FOUND: 2501,
- CONVERSATION_UN_RECORDED_TYPE: 2502,
- ILLEGAL_GROUP_TYPE: 2600,
- CANNOT_JOIN_WORK: 2601,
- CANNOT_CHANGE_OWNER_IN_AVCHATROOM: 2620,
- CANNOT_CHANGE_OWNER_TO_SELF: 2621,
- CANNOT_DISMISS_Work: 2622,
- JOIN_GROUP_FAIL: 2660,
- CANNOT_ADD_MEMBER_IN_AVCHATROOM: 2661,
- CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN: 2662,
- CANNOT_KICK_MEMBER_IN_AVCHATROOM: 2680,
- NOT_OWNER: 2681,
- CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM: 2682,
- INVALID_MEMBER_ROLE: 2683,
- CANNOT_SET_SELF_MEMBER_ROLE: 2684,
- CANNOT_MUTE_SELF: 2685,
- DEL_FRIEND_INVALID_PARAM: 2700,
- UPDATE_PROFILE_INVALID_PARAM: 2721,
- UPDATE_PROFILE_NO_KEY: 2722,
- ADD_BLACKLIST_INVALID_PARAM: 2740,
- DEL_BLACKLIST_INVALID_PARAM: 2741,
- CANNOT_ADD_SELF_TO_BLACKLIST: 2742,
- NETWORK_ERROR: 2800,
- NETWORK_TIMEOUT: 2801,
- NETWORK_BASE_OPTIONS_NO_URL: 2802,
- NETWORK_UNDEFINED_SERVER_NAME: 2803,
- NETWORK_PACKAGE_UNDEFINED: 2804,
- NO_NETWORK: 2805,
- CONVERTOR_IRREGULAR_PARAMS: 2900,
- NOTICE_RUNLOOP_UNEXPECTED_CONDITION: 2901,
- NOTICE_RUNLOOP_OFFSET_LOST: 2902,
- UNCAUGHT_ERROR: 2903,
- GET_LONGPOLL_ID_FAILED: 2904,
- INVALID_OPERATION: 2905,
- SDK_IS_NOT_READY: 2999,
- LONG_POLL_KICK_OUT: 91101,
- MESSAGE_A2KEY_EXPIRED: 20002,
- ACCOUNT_A2KEY_EXPIRED: 70001,
- LONG_POLL_API_PARAM_ERROR: 90001
- },
- Ft = "无 SDKAppID",
- xt = "无 accountType",
- Vt = "无 userID",
- Kt = "无 userSig",
- Ht = "无 tinyID",
- Bt = "无 a2key",
- jt = "用户未登录",
- $t = "未检测到 COS 上传插件",
- Yt = "消息发送失败",
- zt = "MessageController.constructor() 需要参数 options",
- Wt = "需要 Message 的实例",
- Jt = 'Message.conversationType 只能为 "C2C" 或 "GROUP"',
- Xt = "无法发送空文件",
- Qt = "回调函数运行时遇到错误,请检查接入侧代码",
- Zt = "消息撤回失败",
- en = "请先选择一个图片",
- tn = "只允许上传 jpg png jpeg gif bmp格式的图片",
- nn = "图片大小超过20M,无法发送",
- on = "语音上传失败",
- rn = "语音大小大于20M,无法发送",
- sn = "视频上传失败",
- an = "视频大小超过100M,无法发送",
- un = "只允许上传 mp4 格式的视频",
- cn = "文件上传失败",
- ln = "请先选择一个文件",
- pn = "文件大小超过100M,无法发送 ",
- gn = "缺少必要的参数文件 URL",
- hn = "没有找到相应的会话,请检查传入参数",
- dn = "没有找到相应的用户或群组,请检查传入参数",
- mn = "未记录的会话类型",
- fn = "非法的群类型,请检查传入参数",
- _n = "不能加入 Work 类型的群组",
- vn = "AVChatRoom 类型的群组不能转让群主",
- yn = "不能把群主转让给自己",
- In = "不能解散 Work 类型的群组",
- Mn = "加群失败,请检查传入参数或重试",
- Cn = "AVChatRoom 类型的群不支持邀请群成员",
- En = "非 AVChatRoom 类型的群组不允许匿名加群,请先登录后再加群",
- Tn = "不能在 AVChatRoom 类型的群组踢人",
- Dn = "你不是群主,只有群主才有权限操作",
- Sn = "不能在 Work / AVChatRoom 类型的群中设置群成员身份",
- kn = "不合法的群成员身份,请检查传入参数",
- An = "不能设置自己的群成员身份,请检查传入参数",
- On = "不能将自己禁言,请检查传入参数",
- Rn = "传入 deleteFriend 接口的参数无效",
- Nn = "传入 updateMyProfile 接口的参数无效",
- Ln = "updateMyProfile 无标配资料字段或自定义资料字段",
- wn = "传入 addToBlacklist 接口的参数无效",
- Pn = "传入 removeFromBlacklist 接口的参数无效",
- Gn = "不能拉黑自己",
- bn = "网络层初始化错误,缺少 URL 参数",
- Un = "打包错误,未定义的 serverName",
- qn = "未定义的 packageConfig",
- Fn = "未连接到网络",
- xn = "不规范的参数名称",
- Vn = "_syncOffset 丢失",
- Kn = "获取 longpolling id 失败",
- Hn = "无效操作,如调用了未定义或者未实现的方法等",
- Bn = "接口需要 SDK 处于 ready 状态后才能调用",
- jn = ["jpg", "jpeg", "gif", "png", "bmp"],
- $n = ["mp4"],
- Yn = function () {
- function e(n) {
- o(this, e);
- var r = this._check(n);
- if (r instanceof Ut) throw r;
- this.type = t.MSG_FILE, this._percent = 0;
- var i = this._getFileInfo(n);
- this.content = {
- downloadFlag: 2,
- fileUrl: n.url || "",
- uuid: n.uuid,
- fileName: i.name || "",
- fileSize: i.size || 0
- };
- }
- return i(e, [{
- key: "_getFileInfo",
- value: function (e) {
- if (e.fileName && e.fileSize) return {
- size: e.fileSize,
- name: e.fileName
- };
- if (V) return {};
- var t = e.file.files[0];
- return {
- size: t.size,
- name: t.name,
- type: t.type.slice(t.type.lastIndexOf("/") + 1).toLowerCase()
- };
- }
- }, {
- key: "updatePercent",
- value: function (e) {
- this._percent = e, this._percent > 1 && (this._percent = 1);
- }
- }, {
- key: "updateFileUrl",
- value: function (e) {
- this.content.fileUrl = e;
- }
- }, {
- key: "_check",
- value: function (e) {
- if (e.size > 104857600) return new Ut({
- code: qt.MESSAGE_FILE_SIZE_LIMIT,
- message: "".concat(pn, ": ").concat(104857600, " bytes")
- });
- }
- }, {
- key: "sendable",
- value: function () {
- return "" !== this.content.fileUrl && "" !== this.content.fileName && 0 !== this.content.fileSize;
- }
- }]), e;
- }(),
- zn = function () {
- function e(n) {
- o(this, e), this.type = t.MSG_CUSTOM, this.content = {
- data: n.data || "",
- description: n.description || "",
- extension: n.extension || ""
- };
- }
- return i(e, [{
- key: "setData",
- value: function (e) {
- return this.content.data = e, this;
- }
- }, {
- key: "setDescription",
- value: function (e) {
- return this.content.description = e, this;
- }
- }, {
- key: "setExtension",
- value: function (e) {
- return this.content.extension = e, this;
- }
- }, {
- key: "sendable",
- value: function () {
- return 0 !== this.content.data.length || 0 !== this.content.description.length || 0 !== this.content.extension.length;
- }
- }]), e;
- }(),
- Wn = function () {
- function e(n) {
- o(this, e), this.type = t.MSG_VIDEO, this._percent = 0, this.content = {
- remoteVideoUrl: n.remoteVideoUrl,
- videoFormat: n.videoFormat,
- videoSecond: parseInt(n.videoSecond, 10),
- videoSize: n.videoSize,
- videoUrl: n.videoUrl,
- videoDownloadFlag: 2,
- videoUUID: n.videoUUID,
- thumbUUID: n.thumbUUID,
- thumbFormat: n.thumbFormat,
- thumbWidth: n.thumbWidth,
- thumbHeight: n.thumbHeight,
- thumbSize: n.thumbSize,
- thumbDownloadFlag: 2,
- thumbUrl: n.thumbUrl
- };
- }
- return i(e, [{
- key: "updatePercent",
- value: function (e) {
- this._percent = e, this._percent > 1 && (this._percent = 1);
- }
- }, {
- key: "updateVideoUrl",
- value: function (e) {
- e && (this.content.remoteVideoUrl = e);
- }
- }, {
- key: "sendable",
- value: function () {
- return "" !== this.content.remoteVideoUrl;
- }
- }]), e;
- }(),
- Jn = function e(n) {
- o(this, e), this.type = t.MSG_GEO, this.content = n;
- },
- Xn = {
- 1: t.MSG_PRIORITY_HIGH,
- 2: t.MSG_PRIORITY_NORMAL,
- 3: t.MSG_PRIORITY_LOW,
- 4: t.MSG_PRIORITY_LOWEST
- },
- Qn = function () {
- function e(n) {
- o(this, e), this.ID = "", this.conversationID = n.conversationID || null, this.conversationType = n.conversationType || t.CONV_C2C, this.conversationSubType = n.conversationSubType, this.time = n.time || Math.ceil(Date.now() / 1e3), this.sequence = n.sequence || 0, this.clientSequence = n.clientSequence || n.sequence || 0, this.random = n.random || we(), this.priority = this._computePriority(n.priority), this.nick = "", this.avatar = "", this.isPeerRead = !1, this.nameCard = "", this._elements = [], this.isPlaceMessage = n.isPlaceMessage || 0, this.isRevoked = 2 === n.isPlaceMessage || 8 === n.msgFlagBits, this.geo = {}, this.from = n.from || null, this.to = n.to || null, this.flow = "", this.isSystemMessage = n.isSystemMessage || !1, this.protocol = n.protocol || "JSON", this.isResend = !1, this.isRead = !1, this.status = n.status || rt.SUCCESS, this._onlineOnlyFlag = !1, this._groupAtInfoList = [], this.atUserList = [], this.reInitialize(n.currentUser), this.extractGroupInfo(n.groupProfile || null), this.handleGroupAtInfo(n);
- }
- return i(e, [{
- key: "getElements",
- value: function () {
- return this._elements;
- }
- }, {
- key: "extractGroupInfo",
- value: function (e) {
- if (null !== e) {
- _e(e.fromAccountNick) && (this.nick = e.fromAccountNick), _e(e.fromAccountHeadurl) && (this.avatar = e.fromAccountHeadurl);
- var t = e.messageFromAccountExtraInformation;
- ye(t) && _e(t.nameCard) && (this.nameCard = t.nameCard);
- }
- }
- }, {
- key: "handleGroupAtInfo",
- value: function (e) {
- var n = this;
- e.payload && e.payload.atUserList && e.payload.atUserList.forEach(function (e) {
- e !== t.MSG_AT_ALL ? (n._groupAtInfoList.push({
- groupAtAllFlag: 0,
- groupAtUserID: e
- }), n.atUserList.push(e)) : (n._groupAtInfoList.push({
- groupAtAllFlag: 1
- }), n.atUserList.push(t.MSG_AT_ALL));
- }), Ie(e.groupAtInfo) && e.groupAtInfo.forEach(function (e) {
- 1 === e.groupAtAllFlag ? n.atUserList.push(e.groupAtUserID) : 2 === e.groupAtAllFlag && n.atUserList.push(t.MSG_AT_ALL);
- });
- }
- }, {
- key: "getGroupAtInfoList",
- value: function () {
- return this._groupAtInfoList;
- }
- }, {
- key: "_initProxy",
- value: function () {
- this.payload = this._elements[0].content, this.type = this._elements[0].type;
- }
- }, {
- key: "reInitialize",
- value: function (e) {
- e && (this.status = this.from ? rt.SUCCESS : rt.UNSEND, !this.from && (this.from = e)), this._initFlow(e), this._initielizeSequence(e), this._concactConversationID(e), this.generateMessageID(e);
- }
- }, {
- key: "isSendable",
- value: function () {
- return 0 !== this._elements.length && ("function" != typeof this._elements[0].sendable ? (de.warn("".concat(this._elements[0].type, ' need "boolean : sendable()" method')), !1) : this._elements[0].sendable());
- }
- }, {
- key: "_initTo",
- value: function (e) {
- this.conversationType === t.CONV_GROUP && (this.to = e.groupID);
- }
- }, {
- key: "_initielizeSequence",
- value: function (e) {
- 0 === this.clientSequence && e && (this.clientSequence = function (e) {
- if (!e) return de.error("autoincrementIndex(string: key) need key parameter"), !1;
- if (void 0 === Ue[e]) {
- var t = new Date(),
- n = "3".concat(t.getHours()).slice(-2),
- o = "0".concat(t.getMinutes()).slice(-2),
- r = "0".concat(t.getSeconds()).slice(-2);
- Ue[e] = parseInt([n, o, r, "0001"].join("")), n = null, o = null, r = null, de.warn("utils.autoincrementIndex() create new sequence : ".concat(e, " = ").concat(Ue[e]));
- }
- return Ue[e]++;
- }(e)), 0 === this.sequence && this.conversationType === t.CONV_C2C && (this.sequence = this.clientSequence);
- }
- }, {
- key: "generateMessageID",
- value: function (e) {
- var t = e === this.from ? 1 : 0,
- n = this.sequence > 0 ? this.sequence : this.clientSequence;
- this.ID = "".concat(this.conversationID, "-").concat(n, "-").concat(this.random, "-").concat(t);
- }
- }, {
- key: "_initFlow",
- value: function (e) {
- "" !== e && (e === this.from ? (this.flow = "out", this.isRead = !0) : this.flow = "in");
- }
- }, {
- key: "_concactConversationID",
- value: function (e) {
- var n = this.to,
- o = "",
- r = this.conversationType;
- r !== t.CONV_SYSTEM ? (o = r === t.CONV_C2C ? e === this.from ? n : this.from : this.to, this.conversationID = "".concat(r).concat(o)) : this.conversationID = t.CONV_SYSTEM;
- }
- }, {
- key: "isElement",
- value: function (e) {
- return e instanceof st || e instanceof St || e instanceof kt || e instanceof At || e instanceof Yn || e instanceof Wn || e instanceof Rt || e instanceof Lt || e instanceof zn || e instanceof Jn;
- }
- }, {
- key: "setElement",
- value: function (e) {
- var n = this;
- if (this.isElement(e)) return this._elements = [e], void this._initProxy();
- var o = function (e) {
- switch (e.type) {
- case t.MSG_TEXT:
- n.setTextElement(e.content);
- break;
- case t.MSG_IMAGE:
- n.setImageElement(e.content);
- break;
- case t.MSG_AUDIO:
- n.setAudioElement(e.content);
- break;
- case t.MSG_FILE:
- n.setFileElement(e.content);
- break;
- case t.MSG_VIDEO:
- n.setVideoElement(e.content);
- break;
- case t.MSG_CUSTOM:
- n.setCustomElement(e.content);
- break;
- case t.MSG_GEO:
- n.setGEOElement(e.content);
- break;
- case t.MSG_GRP_TIP:
- n.setGroupTipElement(e.content);
- break;
- case t.MSG_GRP_SYS_NOTICE:
- n.setGroupSystemNoticeElement(e.content);
- break;
- case t.MSG_FACE:
- n.setFaceElement(e.content);
- break;
- default:
- de.warn(e.type, e.content, "no operation......");
- }
- };
- if (Ie(e)) for (var r = 0; r < e.length; r++) o(e[r]);else o(e);
- this._initProxy();
- }
- }, {
- key: "setTextElement",
- value: function (e) {
- var t = "string" == typeof e ? e : e.text,
- n = new st({
- text: t
- });
- this._elements.push(n);
- }
- }, {
- key: "setImageElement",
- value: function (e) {
- var t = new St(e);
- this._elements.push(t);
- }
- }, {
- key: "setAudioElement",
- value: function (e) {
- var t = new At(e);
- this._elements.push(t);
- }
- }, {
- key: "setFileElement",
- value: function (e) {
- var t = new Yn(e);
- this._elements.push(t);
- }
- }, {
- key: "setVideoElement",
- value: function (e) {
- var t = new Wn(e);
- this._elements.push(t);
- }
- }, {
- key: "setGEOElement",
- value: function (e) {
- var t = new Jn(e);
- this._elements.push(t);
- }
- }, {
- key: "setCustomElement",
- value: function (e) {
- var t = new zn(e);
- this._elements.push(t);
- }
- }, {
- key: "setGroupTipElement",
- value: function (e) {
- var n = {},
- o = e.operationType;
- Xe(e.memberInfoList) || o !== t.GRP_TIP_MBR_JOIN && o !== t.GRP_TIP_MBR_KICKED_OUT ? e.operatorInfo && (n = e.operatorInfo) : n = e.memberInfoList[0];
- var r = n,
- i = r.nick,
- s = r.avatar;
- _e(i) && (this.nick = i), _e(s) && (this.avatar = s);
- var a = new Rt(e);
- this._elements.push(a);
- }
- }, {
- key: "setGroupSystemNoticeElement",
- value: function (e) {
- var t = new Lt(e);
- this._elements.push(t);
- }
- }, {
- key: "setFaceElement",
- value: function (e) {
- var t = new kt(e);
- this._elements.push(t);
- }
- }, {
- key: "setIsRead",
- value: function (e) {
- this.isRead = e;
- }
- }, {
- key: "setOnlineOnlyFlag",
- value: function (e) {
- this._onlineOnlyFlag = e;
- }
- }, {
- key: "getOnlineOnlyFlag",
- value: function () {
- return this._onlineOnlyFlag;
- }
- }, {
- key: "_computePriority",
- value: function (e) {
- if (Me(e)) return t.MSG_PRIORITY_NORMAL;
- if (_e(e) && -1 !== Object.values(Xn).indexOf(e)) return e;
- if (fe(e)) {
- var n = "" + e;
- if (-1 !== Object.keys(Xn).indexOf(n)) return Xn[n];
- }
- return t.MSG_PRIORITY_NORMAL;
- }
- }, {
- key: "elements",
- get: function () {
- return de.warn("!!!Message 实例的 elements 属性即将废弃,请尽快修改。使用 type 和 payload 属性处理单条消息,兼容组合消息使用 _elements 属性!!!"), this._elements;
- }
- }]), e;
- }(),
- Zn = function (e) {
- return !!e && (!!(function (e) {
- return _e(e) && e.slice(0, 3) === t.CONV_C2C;
- }(e) || function (e) {
- return _e(e) && e.slice(0, 5) === t.CONV_GROUP;
- }(e) || je(e)) || (console.warn("非法的会话 ID:".concat(e, "。会话 ID 组成方式:C2C + userID(单聊)GROUP + groupID(群聊)@TIM#SYSTEM(系统通知会话)")), !1));
- },
- eo = "请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#",
- to = function (e) {
- return e.param ? "".concat(e.api, " ").concat(e.param, " ").concat(e.desc, "。").concat(eo).concat(e.api) : "".concat(e.api, " ").concat(e.desc, "。").concat(eo).concat(e.api);
- },
- no = {
- type: "String",
- required: !0
- },
- oo = {
- type: "Array",
- required: !0
- },
- ro = {
- type: "Object",
- required: !0
- },
- io = {
- login: {
- userID: no,
- userSig: no
- },
- addToBlacklist: {
- userIDList: oo
- },
- on: [{
- name: "eventName",
- type: "String",
- validator: function (e) {
- return "string" == typeof e && 0 !== e.length || (console.warn(to({
- api: "on",
- param: "eventName",
- desc: "类型必须为 String,且不能为空"
- })), !1);
- }
- }, {
- name: "handler",
- type: "Function",
- validator: function (e) {
- return "function" != typeof e ? (console.warn(to({
- api: "on",
- param: "handler",
- desc: "参数必须为 Function"
- })), !1) : ("" === e.name && console.warn("on 接口的 handler 参数推荐使用具名函数。具名函数可以使用 off 接口取消订阅,匿名函数无法取消订阅。"), !0);
- }
- }],
- once: [{
- name: "eventName",
- type: "String",
- validator: function (e) {
- return "string" == typeof e && 0 !== e.length || (console.warn(to({
- api: "once",
- param: "eventName",
- desc: "类型必须为 String,且不能为空"
- })), !1);
- }
- }, {
- name: "handler",
- type: "Function",
- validator: function (e) {
- return "function" != typeof e ? (console.warn(to({
- api: "once",
- param: "handler",
- desc: "参数必须为 Function"
- })), !1) : ("" === e.name && console.warn("once 接口的 handler 参数推荐使用具名函数。"), !0);
- }
- }],
- off: [{
- name: "eventName",
- type: "String",
- validator: function (e) {
- return "string" == typeof e && 0 !== e.length || (console.warn(to({
- api: "off",
- param: "eventName",
- desc: "类型必须为 String,且不能为空"
- })), !1);
- }
- }, {
- name: "handler",
- type: "Function",
- validator: function (e) {
- return "function" != typeof e ? (console.warn(to({
- api: "off",
- param: "handler",
- desc: "参数必须为 Function"
- })), !1) : ("" === e.name && console.warn("off 接口无法为匿名函数取消监听事件。"), !0);
- }
- }],
- sendMessage: [u({
- name: "message"
- }, ro)],
- getMessageList: {
- conversationID: u(u({}, no), {}, {
- validator: function (e) {
- return Zn(e);
- }
- }),
- nextReqMessageID: {
- type: "String"
- },
- count: {
- type: "Number",
- validator: function (e) {
- return !(!Me(e) && !/^[1-9][0-9]*$/.test(e)) || (console.warn(to({
- api: "getMessageList",
- param: "count",
- desc: "必须为正整数"
- })), !1);
- }
- }
- },
- setMessageRead: {
- conversationID: u(u({}, no), {}, {
- validator: function (e) {
- return Zn(e);
- }
- })
- },
- getConversationProfile: [u(u({
- name: "conversationID"
- }, no), {}, {
- validator: function (e) {
- return Zn(e);
- }
- })],
- deleteConversation: [u(u({
- name: "conversationID"
- }, no), {}, {
- validator: function (e) {
- return Zn(e);
- }
- })],
- getGroupList: {
- groupProfileFilter: {
- type: "Array"
- }
- },
- getGroupProfile: {
- groupID: no,
- groupCustomFieldFilter: {
- type: "Array"
- },
- memberCustomFieldFilter: {
- type: "Array"
- }
- },
- getGroupProfileAdvance: {
- groupIDList: oo
- },
- createGroup: {
- name: no
- },
- joinGroup: {
- groupID: no,
- type: {
- type: "String"
- },
- applyMessage: {
- type: "String"
- }
- },
- quitGroup: [u({
- name: "groupID"
- }, no)],
- handleApplication: {
- message: ro,
- handleAction: no,
- handleMessage: {
- type: "String"
- }
- },
- changeGroupOwner: {
- groupID: no,
- newOwnerID: no
- },
- updateGroupProfile: {
- groupID: no,
- muteAllMembers: {
- type: "Boolean"
- }
- },
- dismissGroup: [u({
- name: "groupID"
- }, no)],
- searchGroupByID: [u({
- name: "groupID"
- }, no)],
- getGroupMemberList: {
- groupID: no,
- offset: {
- type: "Number"
- },
- count: {
- type: "Number"
- }
- },
- getGroupMemberProfile: {
- groupID: no,
- userIDList: oo,
- memberCustomFieldFilter: {
- type: "Array"
- }
- },
- addGroupMemeber: {
- groupID: no,
- userIDList: oo
- },
- setGroupMemberRole: {
- groupID: no,
- userID: no,
- role: no
- },
- setGroupMemberMuteTime: {
- groupID: no,
- userID: no,
- muteTime: {
- type: "Number",
- validator: function (e) {
- return e >= 0;
- }
- }
- },
- setGroupMemberNameCard: {
- groupID: no,
- userID: {
- type: "String"
- },
- nameCard: u(u({}, no), {}, {
- validator: function (e) {
- return !0 !== /^\s+$/.test(e);
- }
- })
- },
- setMessageRemindType: {
- groupID: no,
- messageRemindType: no
- },
- setGroupMemberCustomField: {
- groupID: no,
- userID: {
- type: "String"
- },
- memberCustomField: oo
- },
- deleteGroupMember: {
- groupID: no
- },
- createTextMessage: {
- to: no,
- conversationType: no,
- payload: u(u({}, ro), {}, {
- validator: function (e) {
- return ye(e) ? _e(e.text) ? 0 !== e.text.length || (console.warn(to({
- api: "createTextMessage",
- desc: "消息内容不能为空"
- })), !1) : (console.warn(to({
- api: "createTextMessage",
- param: "payload.text",
- desc: "类型必须为 String"
- })), !1) : (console.warn(to({
- api: "createTextMessage",
- param: "payload",
- desc: "类型必须为 plain object"
- })), !1);
- }
- })
- },
- createTextAtMessage: {
- to: no,
- conversationType: no,
- payload: u(u({}, ro), {}, {
- validator: function (e) {
- return ye(e) ? _e(e.text) ? 0 === e.text.length ? (console.warn(to({
- api: "createTextAtMessage",
- desc: "消息内容不能为空"
- })), !1) : !(e.atUserList && !Ie(e.atUserList)) || (console.warn(to({
- api: "createTextAtMessage",
- desc: "payload.atUserList 类型必须为数组"
- })), !1) : (console.warn(to({
- api: "createTextAtMessage",
- param: "payload.text",
- desc: "类型必须为 String"
- })), !1) : (console.warn(to({
- api: "createTextAtMessage",
- param: "payload",
- desc: "类型必须为 plain object"
- })), !1);
- }
- })
- },
- createCustomMessage: {
- to: no,
- conversationType: no,
- payload: u(u({}, ro), {}, {
- validator: function (e) {
- return ye(e) ? e.data && !_e(e.data) ? (console.warn(to({
- api: "createCustomMessage",
- param: "payload.data",
- desc: "类型必须为 String"
- })), !1) : e.description && !_e(e.description) ? (console.warn(to({
- api: "createCustomMessage",
- param: "payload.description",
- desc: "类型必须为 String"
- })), !1) : !(e.extension && !_e(e.extension)) || (console.warn(to({
- api: "createCustomMessage",
- param: "payload.extension",
- desc: "类型必须为 String"
- })), !1) : (console.warn(to({
- api: "createCustomMessage",
- param: "payload",
- desc: "类型必须为 plain object"
- })), !1);
- }
- })
- },
- createImageMessage: {
- to: no,
- conversationType: no,
- payload: u(u({}, ro), {}, {
- validator: function (e) {
- if (!ye(e)) return console.warn(to({
- api: "createImageMessage",
- param: "payload",
- desc: "类型必须为 plain object"
- })), !1;
- if (Me(e.file)) return console.warn(to({
- api: "createImageMessage",
- param: "payload.file",
- desc: "不能为 undefined"
- })), !1;
- if (G) {
- if (!(e.file instanceof HTMLInputElement || me(e.file))) return console.warn(to({
- api: "createImageMessage",
- param: "payload.file",
- desc: "类型必须是 HTMLInputElement 或 File"
- })), !1;
- if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(to({
- api: "createImageMessage",
- param: "payload.file",
- desc: "您没有选择文件,无法发送"
- })), !1;
- }
- return !0;
- },
- onProgress: {
- type: "Function",
- required: !1,
- validator: function (e) {
- return Me(e) && console.warn(to({
- api: "createImageMessage",
- desc: "没有 onProgress 回调,您将无法获取上传进度"
- })), !0;
- }
- }
- })
- },
- createAudioMessage: {
- to: no,
- conversationType: no,
- payload: u(u({}, ro), {}, {
- validator: function (e) {
- return !!ye(e) || (console.warn(to({
- api: "createAudioMessage",
- param: "payload",
- desc: "类型必须为 plain object"
- })), !1);
- }
- }),
- onProgress: {
- type: "Function",
- required: !1,
- validator: function (e) {
- return Me(e) && console.warn(to({
- api: "createAudioMessage",
- desc: "没有 onProgress 回调,您将无法获取上传进度"
- })), !0;
- }
- }
- },
- createVideoMessage: {
- to: no,
- conversationType: no,
- payload: u(u({}, ro), {}, {
- validator: function (e) {
- if (!ye(e)) return console.warn(to({
- api: "createVideoMessage",
- param: "payload",
- desc: "类型必须为 plain object"
- })), !1;
- if (Me(e.file)) return console.warn(to({
- api: "createVideoMessage",
- param: "payload.file",
- desc: "不能为 undefined"
- })), !1;
- if (G) {
- if (!(e.file instanceof HTMLInputElement || me(e.file))) return console.warn(to({
- api: "createVideoMessage",
- param: "payload.file",
- desc: "类型必须是 HTMLInputElement 或 File"
- })), !1;
- if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(to({
- api: "createVideoMessage",
- param: "payload.file",
- desc: "您没有选择文件,无法发送"
- })), !1;
- }
- return !0;
- }
- }),
- onProgress: {
- type: "Function",
- required: !1,
- validator: function (e) {
- return Me(e) && console.warn(to({
- api: "createVideoMessage",
- desc: "没有 onProgress 回调,您将无法获取上传进度"
- })), !0;
- }
- }
- },
- createFaceMessage: {
- to: no,
- conversationType: no,
- payload: u(u({}, ro), {}, {
- validator: function (e) {
- return ye(e) ? fe(e.index) ? !!_e(e.data) || (console.warn(to({
- api: "createFaceMessage",
- param: "payload.data",
- desc: "类型必须为 String"
- })), !1) : (console.warn(to({
- api: "createFaceMessage",
- param: "payload.index",
- desc: "类型必须为 Number"
- })), !1) : (console.warn(to({
- api: "createFaceMessage",
- param: "payload",
- desc: "类型必须为 plain object"
- })), !1);
- }
- })
- },
- createFileMessage: {
- to: no,
- conversationType: no,
- payload: u(u({}, ro), {}, {
- validator: function (e) {
- if (!ye(e)) return console.warn(to({
- api: "createFileMessage",
- param: "payload",
- desc: "类型必须为 plain object"
- })), !1;
- if (Me(e.file)) return console.warn(to({
- api: "createFileMessage",
- param: "payload.file",
- desc: "不能为 undefined"
- })), !1;
- if (G) {
- if (!(e.file instanceof HTMLInputElement || me(e.file))) return console.warn(to({
- api: "createFileMessage",
- param: "payload.file",
- desc: "类型必须是 HTMLInputElement 或 File"
- })), !1;
- if (e.file instanceof HTMLInputElement && 0 === e.file.files.length) return console.warn(to({
- api: "createFileMessage",
- desc: "您没有选择文件,无法发送"
- })), !1;
- }
- return !0;
- }
- }),
- onProgress: {
- type: "Function",
- required: !1,
- validator: function (e) {
- return Me(e) && console.warn(to({
- api: "createFileMessage",
- desc: "没有 onProgress 回调,您将无法获取上传进度"
- })), !0;
- }
- }
- },
- revokeMessage: [u(u({
- name: "message"
- }, ro), {}, {
- validator: function (e) {
- return e instanceof Qn ? e.conversationType === t.CONV_SYSTEM ? (console.warn("revokeMessage 不能撤回系统会话消息,只能撤回单聊消息或群消息"), !1) : !0 !== e.isRevoked || (console.warn("revokeMessage 消息已经被撤回,请勿重复操作"), !1) : (console.warn("revokeMessage 参数 message 必须为 Message(".concat(eo, "Message.html) 实例。")), !1);
- }
- })],
- getUserProfile: {
- userIDList: {
- type: "Array",
- validator: function (e) {
- return Ie(e) ? (0 === e.length && console.warn(to({
- api: "getUserProfile",
- param: "userIDList",
- desc: "不能为空数组"
- })), !0) : (console.warn(to({
- api: "getUserProfile",
- param: "userIDList",
- desc: "必须为数组"
- })), !1);
- }
- }
- },
- updateMyProfile: {
- profileCustomField: {
- type: "Array",
- validator: function (e) {
- return !!Me(e) || !!Ie(e) || (console.warn(to({
- api: "updateMyProfile",
- param: "profileCustomField",
- desc: "必须为数组"
- })), !1);
- }
- }
- }
- },
- so = {
- login: "login",
- logout: "logout",
- on: "on",
- once: "once",
- off: "off",
- setLogLevel: "setLogLevel",
- registerPlugin: "registerPlugin",
- destroy: "destroy",
- createTextMessage: "createTextMessage",
- createTextAtMessage: "createTextAtMessage",
- createImageMessage: "createImageMessage",
- createAudioMessage: "createAudioMessage",
- createVideoMessage: "createVideoMessage",
- createCustomMessage: "createCustomMessage",
- createFaceMessage: "createFaceMessage",
- createFileMessage: "createFileMessage",
- sendMessage: "sendMessage",
- resendMessage: "resendMessage",
- getMessageList: "getMessageList",
- setMessageRead: "setMessageRead",
- revokeMessage: "revokeMessage",
- getConversationList: "getConversationList",
- getConversationProfile: "getConversationProfile",
- deleteConversation: "deleteConversation",
- getGroupList: "getGroupList",
- getGroupProfile: "getGroupProfile",
- createGroup: "createGroup",
- joinGroup: "joinGroup",
- updateGroupProfile: "updateGroupProfile",
- quitGroup: "quitGroup",
- dismissGroup: "dismissGroup",
- changeGroupOwner: "changeGroupOwner",
- searchGroupByID: "searchGroupByID",
- setMessageRemindType: "setMessageRemindType",
- handleGroupApplication: "handleGroupApplication",
- getGroupMemberProfile: "getGroupMemberProfile",
- getGroupMemberList: "getGroupMemberList",
- addGroupMember: "addGroupMember",
- deleteGroupMember: "deleteGroupMember",
- setGroupMemberNameCard: "setGroupMemberNameCard",
- setGroupMemberMuteTime: "setGroupMemberMuteTime",
- setGroupMemberRole: "setGroupMemberRole",
- setGroupMemberCustomField: "setGroupMemberCustomField",
- getGroupOnlineMemberCount: "getGroupOnlineMemberCount",
- getMyProfile: "getMyProfile",
- getUserProfile: "getUserProfile",
- updateMyProfile: "updateMyProfile",
- getBlacklist: "getBlacklist",
- addToBlacklist: "addToBlacklist",
- removeFromBlacklist: "removeFromBlacklist",
- getFriendList: "getFriendList",
- callExperimentalAPI: "callExperimentalAPI"
- },
- ao = "1.7.3",
- uo = "537048168",
- co = "10",
- lo = "protobuf",
- po = "json",
- go = 1,
- ho = 2,
- mo = 3,
- fo = 4,
- _o = {
- HOST: {
- CURRENT: {
- COMMON: "https://webim.tim.qq.com",
- PIC: "https://pic.tim.qq.com",
- COS: "https://yun.tim.qq.com"
- },
- PRODUCTION: {
- COMMON: "https://webim.tim.qq.com",
- PIC: "https://pic.tim.qq.com",
- COS: "https://yun.tim.qq.com"
- },
- OVERSEA_PRODUCTION: {
- COMMON: "https://api.im.qcloud.com",
- PIC: "https://api.im.qcloud.com",
- COS: "https://api.im.qcloud.com"
- },
- SANDBOX: {
- COMMON: "https://events.tim.qq.com",
- PIC: "https://pic.tim.qq.com",
- COS: "https://yun.tim.qq.com"
- },
- TEST: {
- COMMON: "https://test.tim.qq.com",
- PIC: "https://pic.tim.qq.com",
- COS: "https://test.tim.qq.com"
- },
- setCurrent: function () {
- var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 3;
- e === go ? this.CURRENT = this.SANDBOX : e === ho ? this.CURRENT = this.TEST : e === mo ? this.CURRENT = this.PRODUCTION : e === fo && (this.CURRENT = this.OVERSEA_PRODUCTION);
- }
- },
- NAME: {
- OPEN_IM: "openim",
- GROUP: "group_open_http_svc",
- FRIEND: "sns",
- PROFILE: "profile",
- RECENT_CONTACT: "recentcontact",
- PIC: "openpic",
- BIG_GROUP_NO_AUTH: "group_open_http_noauth_svc",
- BIG_GROUP_LONG_POLLING: "group_open_long_polling_http_svc",
- BIG_GROUP_LONG_POLLING_NO_AUTH: "group_open_long_polling_http_noauth_svc",
- IM_OPEN_STAT: "imopenstat",
- WEB_IM: "webim",
- IM_COS_SIGN: "im_cos_sign_svr"
- },
- CMD: {
- ACCESS_LAYER: "accesslayer",
- LOGIN: "login",
- LOGOUT_LONG_POLL: "longpollinglogout",
- LOGOUT_ALL: "logout",
- PORTRAIT_GET: "portrait_get_all",
- PORTRAIT_SET: "portrait_set",
- GET_LONG_POLL_ID: "getlongpollingid",
- LONG_POLL: "longpolling",
- AVCHATROOM_LONG_POLL: "get_msg",
- FRIEND_ADD: "friend_add",
- FRIEND_GET_ALL: "friend_get_all",
- FRIEND_DELETE: "friend_delete",
- RESPONSE_PENDENCY: "friend_response",
- GET_PENDENCY: "pendency_get",
- DELETE_PENDENCY: "pendency_delete",
- GET_GROUP_PENDENCY: "get_pendency",
- GET_BLACKLIST: "black_list_get",
- ADD_BLACKLIST: "black_list_add",
- DELETE_BLACKLIST: "black_list_delete",
- CREATE_GROUP: "create_group",
- GET_JOINED_GROUPS: "get_joined_group_list",
- SEND_MESSAGE: "sendmsg",
- REVOKE_C2C_MESSAGE: "msgwithdraw",
- SEND_GROUP_MESSAGE: "send_group_msg",
- REVOKE_GROUP_MESSAGE: "group_msg_recall",
- GET_GROUP_INFO: "get_group_info",
- GET_GROUP_MEMBER_INFO: "get_specified_group_member_info",
- GET_GROUP_MEMBER_LIST: "get_group_member_info",
- QUIT_GROUP: "quit_group",
- CHANGE_GROUP_OWNER: "change_group_owner",
- DESTROY_GROUP: "destroy_group",
- ADD_GROUP_MEMBER: "add_group_member",
- DELETE_GROUP_MEMBER: "delete_group_member",
- SEARCH_GROUP_BY_ID: "get_group_public_info",
- APPLY_JOIN_GROUP: "apply_join_group",
- HANDLE_APPLY_JOIN_GROUP: "handle_apply_join_group",
- MODIFY_GROUP_INFO: "modify_group_base_info",
- MODIFY_GROUP_MEMBER_INFO: "modify_group_member_info",
- DELETE_GROUP_SYSTEM_MESSAGE: "deletemsg",
- DELETE_GROUP_AT_TIPS: "deletemsg",
- GET_CONVERSATION_LIST: "get",
- PAGING_GET_CONVERSATION_LIST: "page_get",
- DELETE_CONVERSATION: "delete",
- GET_MESSAGES: "getmsg",
- GET_C2C_ROAM_MESSAGES: "getroammsg",
- GET_GROUP_ROAM_MESSAGES: "group_msg_get",
- SET_C2C_MESSAGE_READ: "msgreaded",
- GET_PEER_READ_TIME: "get_peer_read_time",
- SET_GROUP_MESSAGE_READ: "msg_read_report",
- FILE_READ_AND_WRITE_AUTHKEY: "authkey",
- FILE_UPLOAD: "pic_up",
- COS_SIGN: "cos",
- TIM_WEB_REPORT: "tim_web_report",
- BIG_DATA_HALLWAY_AUTH_KEY: "authkey",
- GET_ONLINE_MEMBER_NUM: "get_online_member_num"
- },
- CHANNEL: {
- SOCKET: 1,
- XHR: 2,
- AUTO: 0
- },
- NAME_VERSION: {
- openim: "v4",
- group_open_http_svc: "v4",
- sns: "v4",
- profile: "v4",
- recentcontact: "v4",
- openpic: "v4",
- group_open_http_noauth_svc: "v4",
- group_open_long_polling_http_svc: "v4",
- group_open_long_polling_http_noauth_svc: "v4",
- imopenstat: "v4",
- im_cos_sign_svr: "v4",
- webim: "v4"
- }
- };
- _o.HOST.setCurrent(mo);
- var vo = {
- request: {
- toAccount: "To_Account",
- fromAccount: "From_Account",
- to: "To_Account",
- from: "From_Account",
- groupID: "GroupId",
- avatar: "FaceUrl",
- groupAtUserID: "GroupAt_Account"
- },
- response: {
- GroupId: "groupID",
- Member_Account: "userID",
- MsgList: "messageList",
- SyncFlag: "syncFlag",
- To_Account: "to",
- From_Account: "from",
- MsgSeq: "sequence",
- MsgRandom: "random",
- MsgTimeStamp: "time",
- MsgContent: "content",
- MsgBody: "elements",
- GroupWithdrawInfoArray: "revokedInfos",
- WithdrawC2cMsgNotify: "c2cMessageRevokedNotify",
- C2cWithdrawInfoArray: "revokedInfos",
- C2cReadedReceipt: "c2cMessageReadReceipt",
- LastReadTime: "peerReadTime",
- MsgRand: "random",
- MsgType: "type",
- MsgShow: "messageShow",
- NextMsgSeq: "nextMessageSeq",
- FaceUrl: "avatar",
- ProfileDataMod: "profileModify",
- Profile_Account: "userID",
- ValueBytes: "value",
- ValueNum: "value",
- NoticeSeq: "noticeSequence",
- NotifySeq: "notifySequence",
- MsgFrom_AccountExtraInfo: "messageFromAccountExtraInformation",
- Operator_Account: "operatorID",
- OpType: "operationType",
- ReportType: "operationType",
- UserId: "userID",
- User_Account: "userID",
- List_Account: "userIDList",
- MsgOperatorMemberExtraInfo: "operatorInfo",
- MsgMemberExtraInfo: "memberInfoList",
- ImageUrl: "avatar",
- NickName: "nick",
- MsgGroupNewInfo: "newGroupProfile",
- MsgAppDefinedData: "groupCustomField",
- Owner_Account: "ownerID",
- GroupName: "name",
- GroupFaceUrl: "avatar",
- GroupIntroduction: "introduction",
- GroupNotification: "notification",
- GroupApplyJoinOption: "joinOption",
- MsgKey: "messageKey",
- GroupInfo: "groupProfile",
- ShutupTime: "muteTime",
- Desc: "description",
- Ext: "extension",
- GroupAt_Account: "groupAtUserID"
- },
- ignoreKeyWord: ["C2C", "ID", "USP"]
- },
- yo = "_contextWasUpdated",
- Io = "_contextWasReset",
- Mo = "_a2KeyAndTinyIDUpdated",
- Co = "_specifiedConfigUpdated",
- Eo = "_noticeIsSynchronizing",
- To = "_noticeIsSynchronized",
- Do = "_messageSent",
- So = "_syncMessageProcessing",
- ko = "_syncMessageFinished",
- Ao = "_receiveInstantMessage",
- Oo = "_receiveGroupInstantMessage",
- Ro = "_receveGroupSystemNotice",
- No = "_messageRevoked",
- Lo = "_longPollGetIDFailed",
- wo = "_longPollRequestFailed",
- Po = "_longPollResponseOK",
- Go = "_longPollKickedOut",
- bo = "_longPollMitipuleDeviceKickedOut",
- Uo = "_longPollGetNewC2CNotice",
- qo = "_longPollGetNewGroupMessages",
- Fo = "_longPollGetNewGroupTips",
- xo = "_longPollGetNewGroupAtTips",
- Vo = "_longPollGetNewGroupNotice",
- Ko = "_longPollGetNewFriendMessages",
- Ho = "_longPollProfileModified",
- Bo = " _longpollGroupMessageRevoked",
- jo = "_longpollC2CMessageRevoked",
- $o = "_longpollC2CMessageReadReceipt",
- Yo = "_avlongPollRequestFailed",
- zo = "_avlongPollResponseOK",
- Wo = "_onGroupListUpdated",
- Jo = "_loginSuccess",
- Xo = "_signLogoutExcuting",
- Qo = "_logoutSuccess",
- Zo = "_a2keyExpired",
- er = "_errorHasBeenDetected",
- tr = "_onConversationListUpdated",
- nr = "_onConversationListProfileUpdated",
- or = "_conversationDeleted",
- rr = "onProfileUpdated",
- ir = "joinAVChatRoomSuccess",
- sr = "joinAVChatRoomSuccessNoAuth",
- ar = "_sdkStateReady",
- ur = "_sdkReload";
- function cr(e, t) {
- if ("string" != typeof e && !Array.isArray(e)) throw new TypeError("Expected the input to be `string | string[]`");
- t = Object.assign({
- pascalCase: !1
- }, t);
- var n;
- return 0 === (e = Array.isArray(e) ? e.map(function (e) {
- return e.trim();
- }).filter(function (e) {
- return e.length;
- }).join("-") : e.trim()).length ? "" : 1 === e.length ? t.pascalCase ? e.toUpperCase() : e.toLowerCase() : (e !== e.toLowerCase() && (e = lr(e)), e = e.replace(/^[_.\- ]+/, "").toLowerCase().replace(/[_.\- ]+(\w|$)/g, function (e, t) {
- return t.toUpperCase();
- }).replace(/\d+(\w|$)/g, function (e) {
- return e.toUpperCase();
- }), n = e, t.pascalCase ? n.charAt(0).toUpperCase() + n.slice(1) : n);
- }
- var lr = function (e) {
- for (var t = !1, n = !1, o = !1, r = 0; r < e.length; r++) {
- var i = e[r];
- t && /[a-zA-Z]/.test(i) && i.toUpperCase() === i ? (e = e.slice(0, r) + "-" + e.slice(r), t = !1, o = n, n = !0, r++) : n && o && /[a-zA-Z]/.test(i) && i.toLowerCase() === i ? (e = e.slice(0, r - 1) + "-" + e.slice(r - 1), o = n, n = !1, t = !0) : (t = i.toLowerCase() === i && i.toUpperCase() !== i, o = n, n = i.toUpperCase() === i && i.toLowerCase() !== i);
- }
- return e;
- };
- function pr(e, t, n) {
- var o = [],
- r = 0,
- i = function e(t, n) {
- if (++r > 10) return r--, t;
- if (Ie(t)) {
- var i = t.map(function (t) {
- return ve(t) ? e(t, n) : t;
- });
- return r--, i;
- }
- if (ve(t)) {
- var s = (a = t, u = function (e, t) {
- if (!Se(t)) return !1;
- if ((s = t) !== cr(s)) {
- for (var r = !0, i = 0; i < vo.ignoreKeyWord.length; i++) if (t.includes(vo.ignoreKeyWord[i])) {
- r = !1;
- break;
- }
- r && o.push(t);
- }
- var s;
- return Me(n[t]) ? function (e) {
- return "OPPOChannelID" === e ? e : e[0].toUpperCase() + cr(e).slice(1);
- }(t) : n[t];
- }, c = Object.create(null), Object.keys(a).forEach(function (e) {
- var t = u(a[e], e);
- t && (c[t] = a[e]);
- }), c);
- return s = $e(s, function (t, o) {
- return Ie(t) || ve(t) ? e(t, n) : t;
- }), r--, s;
- }
- var a, u, c;
- }(e, t = u(u({}, vo.request), t));
- return o.length > 0 && n.innerEmitter.emit(er, {
- code: qt.CONVERTOR_IRREGULAR_PARAMS,
- message: xn
- }), i;
- }
- function gr(e, t) {
- if (t = u(u({}, vo.response), t), Ie(e)) return e.map(function (e) {
- return ve(e) ? gr(e, t) : e;
- });
- if (ve(e)) {
- var n = (o = e, r = function (e, n) {
- return Me(t[n]) ? cr(n) : t[n];
- }, i = {}, Object.keys(o).forEach(function (e) {
- i[r(o[e], e)] = o[e];
- }), i);
- return n = $e(n, function (e) {
- return Ie(e) || ve(e) ? gr(e, t) : e;
- });
- }
- var o, r, i;
- }
- var hr = function () {
- function e(t) {
- var n = this;
- o(this, e), this.url = "", this.requestData = null, this.method = t.method || "POST", this.callback = function (e) {
- return gr(e = t.decode(e), n._getResponseMap(t));
- }, this._initializeServerMap(), this._initializeURL(t), this._initializeRequestData(t);
- }
- return i(e, [{
- key: "_initializeServerMap",
- value: function () {
- this._serverMap = Object.create(null);
- var e = "";
- for (var t in _o.NAME) if (Object.prototype.hasOwnProperty.call(_o.NAME, t)) switch (e = _o.NAME[t]) {
- case _o.NAME.PIC:
- this._serverMap[e] = _o.HOST.CURRENT.PIC;
- break;
- case _o.NAME.IM_COS_SIGN:
- this._serverMap[e] = _o.HOST.CURRENT.COS;
- break;
- default:
- this._serverMap[e] = _o.HOST.CURRENT.COMMON;
- }
- }
- }, {
- key: "_getHost",
- value: function (e) {
- if (void 0 !== this._serverMap[e]) return this._serverMap[e];
- throw new Ut({
- code: qt.NETWORK_UNDEFINED_SERVER_NAME,
- message: Un
- });
- }
- }, {
- key: "_initializeURL",
- value: function (e) {
- var t = e.serverName,
- n = e.cmd,
- o = this._getHost(t),
- r = "".concat(o, "/").concat(_o.NAME_VERSION[t], "/").concat(t, "/").concat(n);
- r += "?".concat(this._getQueryString(e.queryString)), this.url = r;
- }
- }, {
- key: "getUrl",
- value: function () {
- return this.url.replace(/&reqtime=(\d+)/, "&reqtime=".concat(Math.ceil(+new Date() / 1e3)));
- }
- }, {
- key: "_initializeRequestData",
- value: function (e) {
- var t,
- n = e.requestData;
- t = this._requestDataCleaner(n), this.requestData = e.encode(t);
- }
- }, {
- key: "_requestDataCleaner",
- value: function (e) {
- var t = Array.isArray(e) ? [] : Object.create(null);
- for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && Se(o) && null !== e[o] && ("object" !== n(e[o]) ? t[o] = e[o] : t[o] = this._requestDataCleaner.bind(this)(e[o]));
- return t;
- }
- }, {
- key: "_getQueryString",
- value: function (e) {
- var t = [];
- for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && ("function" != typeof e[n] ? t.push("".concat(n, "=").concat(e[n])) : t.push("".concat(n, "=").concat(e[n]())));
- return t.join("&");
- }
- }, {
- key: "_getResponseMap",
- value: function (e) {
- if (e.keyMaps && e.keyMaps.response && Object.keys(e.keyMaps.response).length > 0) return e.keyMaps.response;
- }
- }]), e;
- }();
- function dr(e) {
- this.mixin(e);
- }
- dr.mixin = function (e) {
- var t = e.prototype || e;
- t._isReady = !1, t.ready = function (e) {
- var t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
- if (e) return this._isReady ? void (t ? e.call(this) : setTimeout(e, 1)) : (this._readyQueue = this._readyQueue || [], void this._readyQueue.push(e));
- }, t.triggerReady = function () {
- var e = this;
- this._isReady = !0, setTimeout(function () {
- var t = e._readyQueue;
- e._readyQueue = [], t && t.length > 0 && t.forEach(function (e) {
- e.call(this);
- }, e);
- }, 1);
- }, t.resetReady = function () {
- this._isReady = !1, this._readyQueue = [];
- }, t.isReady = function () {
- return this._isReady;
- };
- };
- var mr = function () {
- function e(t) {
- o(this, e), dr.mixin(this), this.tim = t;
- }
- return i(e, [{
- key: "isLoggedIn",
- value: function () {
- return this.tim.context.login === ot.IS_LOGIN || !!this.tim.context.a2Key;
- }
- }, {
- key: "createTransportCapsule",
- value: function (e) {
- var t = this.tim.packageConfig.get(e);
- return t ? new hr(t) : null;
- }
- }, {
- key: "request",
- value: function (e) {
- var t = this.createTransportCapsule(e);
- return t || de.error("unknown transport capsule, please check!", e), this.tim.connectionController.request(t);
- }
- }, {
- key: "emitInnerEvent",
- value: function (e, t) {
- this.tim.innerEmitter.emit(e, t);
- }
- }, {
- key: "emitOuterEvent",
- value: function (e, t) {
- this.tim.outerEmitter.emit(e, t);
- }
- }, {
- key: "reset",
- value: function () {
- de.warn(["method: IMController.reset() method must be implemented"].join());
- }
- }, {
- key: "probeNetwork",
- value: function () {
- return this.tim.netMonitor.probe();
- }
- }, {
- key: "getNetworkType",
- value: function () {
- return this.tim.netMonitor.getNetworkType();
- }
- }, {
- key: "getPlatform",
- value: function () {
- return H;
- }
- }]), e;
- }(),
- fr = function () {
- function e(t, n) {
- o(this, e), this.data = t, this._innerEmitter = n, this.defaultData = {}, Object.assign(this.defaultData, t), this.initGetterAndSetter();
- }
- return i(e, [{
- key: "initGetterAndSetter",
- value: function () {
- var e = this,
- t = function (t) {
- Object.defineProperty(e, t, {
- enumerable: !0,
- configurable: !0,
- get: function () {
- return e.data[t];
- },
- set: function (n) {
- e.data[t] !== n && (e.data[t] = n, e.onChange.bind(e)(t, n));
- }
- });
- };
- for (var n in e.data) Object.prototype.hasOwnProperty.call(e.data, n) && t(n);
- }
- }, {
- key: "onChange",
- value: function (e, t) {
- this._innerEmitter.emit(yo, {
- key: e,
- value: t
- });
- }
- }, {
- key: "reset",
- value: function () {
- for (var e in de.log("Context.reset"), this.data) Object.prototype.hasOwnProperty.call(this.data, e) && (this.data[e] = this.defaultData.hasOwnProperty(e) ? this.defaultData[e] : null);
- }
- }]), e;
- }(),
- _r = function (e) {
- c(n, e);
- var t = v(n);
- function n(e) {
- var r;
- o(this, n);
- var i = (r = t.call(this, e)).tim.loginInfo;
- return r._context = new fr({
- login: ot.IS_NOT_LOGIN,
- SDKAppID: i.SDKAppID,
- appIDAt3rd: null,
- accountType: i.accountType,
- identifier: i.identifier,
- tinyID: null,
- identifierNick: i.identifierNick,
- userSig: i.userSig,
- a2Key: null,
- contentType: "json",
- apn: 1,
- unlimitedAVChatRoom: i.unlimitedAVChatRoom,
- scene: i.scene,
- oversea: i.oversea,
- instanceID: i.instanceID
- }, r.tim.innerEmitter), r._initListener(), r;
- }
- return i(n, [{
- key: "reset",
- value: function () {
- this._context.reset(), this.emitInnerEvent(Io);
- }
- }, {
- key: "_initListener",
- value: function () {
- this.tim.innerEmitter.on(yo, this._onContextMemberChange, this), this.tim.innerEmitter.on(Jo, this._updateA2KeyAndTinyID, this);
- }
- }, {
- key: "_updateA2KeyAndTinyID",
- value: function (e) {
- var t = e.data,
- n = t.a2Key,
- o = t.tinyID;
- this._context.a2Key = n, this._context.tinyID = o, this.emitInnerEvent(Mo), this.triggerReady();
- }
- }, {
- key: "getContext",
- value: function () {
- return this._context;
- }
- }, {
- key: "_onContextMemberChange",
- value: function (e) {
- var t = e.data,
- n = t.key,
- o = t.value;
- ("tinyID" === n || "a2Key" === n) && (o.length <= 0 ? this._context.login = ot.IS_NOT_LOGIN : this._context.login = null !== this._context.a2Key ? ot.IS_LOGIN : ot.IS_NOT_LOGIN);
- }
- }]), n;
- }(mr),
- vr = function e(t) {
- o(this, e), this.code = 0, this.data = t || {};
- },
- yr = null,
- Ir = function (e) {
- yr = e;
- },
- Mr = function (e) {
- return e instanceof vr ? (de.warn("IMPromise.resolve 此函数会自动用options创建IMResponse实例,调用侧不需创建,建议修改!"), Promise.resolve(e)) : Promise.resolve(new vr(e));
- },
- Cr = function (t) {
- var n = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
- if (t instanceof Ut) return n && null !== yr && yr.emit(e.ERROR, t), Promise.reject(t);
- if (t instanceof Error) {
- var o = new Ut({
- code: qt.UNCAUGHT_ERROR,
- message: t.message
- });
- return n && null !== yr && yr.emit(e.ERROR, o), Promise.reject(o);
- }
- if (Me(t) || Me(t.code) || Me(t.message)) de.error("IMPromise.reject 必须指定code(错误码)和message(错误信息)!!!");else {
- if (fe(t.code) && _e(t.message)) {
- var r = new Ut(t);
- return n && null !== yr && yr.emit(e.ERROR, r), Promise.reject(r);
- }
- de.error("IMPromise.reject code(错误码)必须为数字,message(错误信息)必须为字符串!!!");
- }
- },
- Er = "sdkReady",
- Tr = "login",
- Dr = "longpolling",
- Sr = "longpollingAV",
- kr = "sendMessage",
- Ar = "sendMessageC2C",
- Or = "sendMessageGroupWork",
- Rr = "sendMessageGroupPublic",
- Nr = "sendMessageGroupMeeting",
- Lr = "sendMessageGroupAV",
- wr = "messageReceived",
- Pr = "messageReceivedAV",
- Gr = "initConversationList",
- br = "initGroupList",
- Ur = "upload",
- qr = function () {
- function e(t) {
- o(this, e), this.SDKAppID = "", this.version = "", this.tinyID = "", this.userID = "", this.platform = "", this.method = t, this.time = "", this.startts = Date.now(), this.endts = 0, this.timespan = 0, this.codeint = 0, this.message = "", this.text = "", this.msgType = "", this.networkType = "", this.platform = "", this.scene = "", this._sentFlag = !1, this.instanceID = "", this.host = function () {
- var e = "unknown";
- if (ie && (e = "mac"), re && (e = "windows"), W && (e = "ios"), J && (e = "android"), V) try {
- var t = K.getSystemInfoSync().platform;
- void 0 !== t && (e = t);
- } catch (n) {}
- return e;
- }(), this.mpLibVersion = function () {
- if (V) try {
- var e;
- return void 0 === (e = x ? my.getSystemInfoSync().version : K.getSystemInfoSync().SDKVersion) ? "-" : e;
- } catch (t) {
- return "-";
- }
- return "-";
- }();
- }
- return i(e, [{
- key: "setCommonInfo",
- value: function (e) {
- var t = e.SDKAppID,
- n = e.version,
- o = e.tinyID,
- r = e.userID,
- i = e.platform,
- s = e.scene,
- a = e.instanceID;
- this.SDKAppID = "".concat(t), this.version = "".concat(n), this.tinyID = o, this.userID = r, this.platform = i, this.scene = s, this.time = Ne(), this.instanceID = a, this.startts && this.endts && !this.timespan && (this.timespan = Math.abs(this.endts - this.startts));
- }
- }, {
- key: "setEnd",
- value: function () {
- var e = this,
- t = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];
- this._sentFlag || (this.endts = Date.now(), t ? (this._sentFlag = !0, this._eventStatController.pushIn(this)) : setTimeout(function () {
- e._sentFlag = !0, e._eventStatController.pushIn(e);
- }, 0));
- }
- }, {
- key: "setError",
- value: function (e, t, n) {
- return e instanceof Error ? (this._sentFlag || (this.setNetworkType(n), t ? (e.code && this.setCode(e.code), e.message && this.setMessage(e.message)) : (this.setCode(qt.NO_NETWORK), this.setMessage(Fn))), this) : (de.warn("SSOLogData.setError value not instanceof Error, please check!"), this);
- }
- }, {
- key: "setCode",
- value: function (e) {
- return Me(e) || this._sentFlag || ("ECONNABORTED" === e && (this.codeint = 103), fe(e) ? this.codeint = e : de.warn("SSOLogData.setCode value not a number, please check!", e, n(e))), this;
- }
- }, {
- key: "setMessage",
- value: function (e) {
- return Me(e) || this._sentFlag ? this : _e(e) ? (this.message = e, this) : this;
- }
- }, {
- key: "setText",
- value: function (e) {
- return fe(e) ? this.text = e.toString() : _e(e) && (this.text = e), this;
- }
- }, {
- key: "setMessageType",
- value: function (e) {
- return this.msgType = e, this;
- }
- }, {
- key: "setNetworkType",
- value: function (e) {
- return Me(e) ? de.warn("SSOLogData.setNetworkType value is undefined, please check!") : this.networkType = e, this;
- }
- }], [{
- key: "bindController",
- value: function (t) {
- e.prototype._eventStatController = t;
- }
- }]), e;
- }(),
- Fr = "sdkConstruct",
- xr = "sdkReady",
- Vr = "accessLayer",
- Kr = "login",
- Hr = "logout",
- Br = "kickedOut",
- jr = "registerPlugin",
- $r = "getCosAuthKey",
- Yr = "upload",
- zr = "sendMessage",
- Wr = "sendComboMessage",
- Jr = "getC2CRoamingMessages",
- Xr = "getGroupRoamingMessages",
- Qr = "revokeMessage",
- Zr = "setC2CMessageRead",
- ei = "setGroupMessageRead",
- ti = "emptyMessageBody",
- ni = "getPeerReadTime",
- oi = "getConversationList",
- ri = "getConversationProfile",
- ii = "deleteConversation",
- si = "getConversationListInStorage",
- ai = "syncConversationList",
- ui = "createGroup",
- ci = "applyJoinGroup",
- li = "joinAVChatRoomSilently",
- pi = "quitGroup",
- gi = "searchGroupByID",
- hi = "changeGroupOwner",
- di = "handleGroupApplication",
- mi = "setMessageRemindType",
- fi = "dismissGroup",
- _i = "updateGroupProfile",
- vi = "getGroupList",
- yi = "getGroupProfile",
- Ii = "getGroupListInStorage",
- Mi = "getGroupLastSequence",
- Ci = "getGroupMemberList",
- Ei = "getGroupMemberProfile",
- Ti = "addGroupMember",
- Di = "deleteGroupMember",
- Si = "setGroupMemberMuteTime",
- ki = "setGroupMemberNameCard",
- Ai = "setGroupMemberRole",
- Oi = "setGroupMemberCustomField",
- Ri = "getGroupOnlineMemberCount",
- Ni = "getLongPollID",
- Li = "longPollingError",
- wi = "networkJitter",
- Pi = "sdkReload",
- Gi = "messageLoss",
- bi = "messageStacked",
- Ui = "getUserProfile",
- qi = "updateMyProfile",
- Fi = "getBlacklist",
- xi = "addToBlacklist",
- Vi = "removeFromBlacklist",
- Ki = "mpHideToShow",
- Hi = "callbackFunctionError",
- Bi = "exceptionError",
- ji = function (n) {
- c(s, n);
- var r = v(s);
- function s(e) {
- var t;
- return o(this, s), !0 === (t = r.call(this, e)).tim.context.oversea && _o.HOST.setCurrent(fo), t._initializeListener(), t;
- }
- return i(s, [{
- key: "login",
- value: function (e) {
- if (this.isLoggedIn()) {
- var t = "您已经登录账号".concat(e.identifier, "!如需切换账号登录,请先调用 logout 接口登出,再调用 login 接口登录。");
- return de.warn(t), Mr({
- actionStatus: "OK",
- errorCode: 0,
- errorInfo: t,
- repeatLogin: !0
- });
- }
- de.log("SignController.login userID=".concat(e.identifier)), de.time(Tr);
- var n = this._checkLoginInfo(e);
- return Xe(n) ? (this.tim.context.identifier = e.identifier, this.tim.context.userSig = e.userSig, this.tim.context.identifier && this.tim.context.userSig ? this._accessLayer() : void 0) : Cr(n);
- }
- }, {
- key: "_isLoginCurrentUser",
- value: function (e) {
- return this.tim.context.identifier === e;
- }
- }, {
- key: "_initializeListener",
- value: function () {
- var e = this.tim.innerEmitter;
- e.on(Go, this._onMultipleAccountKickedOut, this), e.on(bo, this._onMultipleDeviceKickedOut, this), e.on(Zo, this._onUserSigExpired, this);
- }
- }, {
- key: "_accessLayer",
- value: function () {
- var e = this,
- t = new qr(Vr);
- return de.log("SignController._accessLayer."), this.request({
- name: "accessLayer",
- action: "query"
- }).then(function (n) {
- return t.setNetworkType(e.getNetworkType()).setText(n.data.webImAccessLayer).setEnd(), de.log("SignController._accessLayer ok. webImAccessLayer=".concat(n.data.webImAccessLayer)), e.tim.context.oversea || n.data.webImAccessLayer !== go || _o.HOST.setCurrent(n.data.webImAccessLayer), e._login();
- }).catch(function (n) {
- return e.probeNetwork().then(function (o) {
- var r = y(o, 2),
- i = r[0],
- s = r[1];
- t.setError(n, i, s).setEnd(!0), e.tim.eventStatController.reportAtOnce();
- }), de.error("SignController._accessLayer failed. error:", n), Cr(n);
- });
- }
- }, {
- key: "_login",
- value: function () {
- var e = this,
- t = new qr(Kr);
- return this.request({
- name: "login",
- action: "query"
- }).then(function (n) {
- var o = null;
- if (!n.data.tinyID) throw o = new Ut({
- code: qt.NO_TINYID,
- message: Ht
- }), t.setError(o, !0, e.getNetworkType()).setEnd(), o;
- if (!n.data.a2Key) throw o = new Ut({
- code: qt.NO_A2KEY,
- message: Bt
- }), t.setError(o, !0, e.getNetworkType()).setEnd(), o;
- return t.setNetworkType(e.getNetworkType()).setText("".concat(e.tim.loginInfo.identifier)).setEnd(), de.log("SignController.login ok. userID=".concat(e.tim.loginInfo.identifier, " loginCost=").concat(de.timeEnd(Tr), "ms")), e.emitInnerEvent(Jo, {
- a2Key: n.data.a2Key,
- tinyID: n.data.tinyID
- }), Mr(n.data);
- }).catch(function (n) {
- return e.probeNetwork().then(function (e) {
- var o = y(e, 2),
- r = o[0],
- i = o[1];
- t.setError(n, r, i).setEnd(!0);
- }), de.error("SignController.login failed. error:", n), Cr(n);
- });
- }
- }, {
- key: "logout",
- value: function () {
- return this.isLoggedIn() ? (new qr(Hr).setNetworkType(this.getNetworkType()).setText("userID=".concat(this.tim.loginInfo.identifier, " type=").concat("longPollLogout")).setEnd(!0), de.info("SignController.logout"), this.emitInnerEvent(Xo), this._logout(Mt).then(this._emitLogoutSuccess.bind(this)).catch(this._emitLogoutSuccess.bind(this))) : Cr({
- code: qt.USER_NOT_LOGGED_IN,
- message: jt
- });
- }
- }, {
- key: "_logout",
- value: function (e) {
- var t = this.tim.notificationController,
- n = e === It ? "logout" : "longPollLogout",
- o = e === It ? {
- name: n,
- action: "query"
- } : {
- name: n,
- action: "query",
- param: {
- longPollID: t.getLongPollID()
- }
- };
- return this.request(o).catch(function (e) {
- return de.error("SignController._logout error:", e), Cr(e);
- });
- }
- }, {
- key: "_checkLoginInfo",
- value: function (e) {
- var t = 0,
- n = "";
- return null === e.SDKAppID ? (t = qt.NO_SDKAPPID, n = Ft) : null === e.accountType ? (t = qt.NO_ACCOUNT_TYPE, n = xt) : null === e.identifier ? (t = qt.NO_IDENTIFIER, n = Vt) : null === e.userSig && (t = qt.NO_USERSIG, n = Kt), Xe(t) || Xe(n) ? {} : {
- code: t,
- message: n
- };
- }
- }, {
- key: "_emitLogoutSuccess",
- value: function () {
- return this.emitInnerEvent(Qo), Mr({});
- }
- }, {
- key: "_onMultipleAccountKickedOut",
- value: function () {
- var n = this;
- new qr(Br).setNetworkType(this.getNetworkType()).setText(t.KICKED_OUT_MULT_ACCOUNT).setEnd(!0), de.warn("SignController._onMultipleAccountKickedOut kicked out. userID=".concat(this.tim.loginInfo.identifier)), this.tim.logout().then(function () {
- n.emitOuterEvent(e.KICKED_OUT, {
- type: t.KICKED_OUT_MULT_ACCOUNT
- });
- });
- }
- }, {
- key: "_onMultipleDeviceKickedOut",
- value: function () {
- var n = this;
- new qr(Br).setNetworkType(this.getNetworkType()).setText(t.KICKED_OUT_MULT_DEVICE).setEnd(!0), de.warn("SignController._onMultipleDeviceKickedOut kicked out. userID=".concat(this.tim.loginInfo.identifier)), this.tim.logout().then(function () {
- n.emitOuterEvent(e.KICKED_OUT, {
- type: t.KICKED_OUT_MULT_DEVICE
- });
- });
- }
- }, {
- key: "_onUserSigExpired",
- value: function () {
- new qr(Br).setNetworkType(this.getNetworkType()).setText(t.KICKED_OUT_USERSIG_EXPIRED).setEnd(!0), de.warn("SignController._onUserSigExpired: userSig 签名过期被踢下线"), this.emitOuterEvent(e.KICKED_OUT, {
- type: t.KICKED_OUT_USERSIG_EXPIRED
- }), this.tim.resetSDK();
- }
- }, {
- key: "reset",
- value: function () {
- de.info("SignController.reset");
- }
- }]), s;
- }(mr),
- $i = function e() {
- o(this, e);
- },
- Yi = function (e) {
- c(n, e);
- var t = v(n);
- function n() {
- var e;
- return o(this, n), (e = t.call(this)).retry = 2, e._request = e.promisify(K.request), e;
- }
- return i(n, [{
- key: "request",
- value: function (e) {
- return this._checkOptions(e), this._initOptions(e), e = u(u({}, e), {}, {
- responseType: "text"
- }), this._requestWithRetry(e);
- }
- }, {
- key: "_requestWithRetry",
- value: function (e) {
- var t = this,
- n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0;
- return this._request(e).then(this._handleResolve).catch(function (o) {
- if (_e(o.errMsg)) {
- if (o.errMsg.includes("abort")) return Mr({});
- if (o.errMsg.includes("timeout")) return t.retry > 0 && n < t.retry ? t._requestWithRetry(e, ++n) : Cr(new Ut({
- code: qt.NETWORK_TIMEOUT,
- message: o.errMsg
- }));
- if (o.errMsg.includes("fail")) return t.retry > 0 && n < t.retry ? t._requestWithRetry(e, ++n) : Cr(new Ut({
- code: qt.NETWORK_ERROR,
- message: o.errMsg
- }));
- }
- return Cr(new Ut(u({
- code: qt.UNCAUGHT_ERROR,
- message: o.message
- }, o)));
- });
- }
- }, {
- key: "_handleResolve",
- value: function (e) {
- var t = e.data,
- n = t.error_code,
- o = t.ErrorCode;
- return fe(n) && (o = n), o !== nt.SUCCESS && (e.data.ErrorCode = Number("".concat(o))), e;
- }
- }, {
- key: "promisify",
- value: function (e) {
- return function (t) {
- return new Promise(function (n, o) {
- var r = e(Object.assign({}, t, {
- success: n,
- fail: o
- }));
- t.updateAbort && t.updateAbort(function () {
- r && Ee(r.abort) && r.abort();
- });
- });
- };
- }
- }]), n;
- }(function () {
- function e() {
- o(this, e);
- }
- return i(e, [{
- key: "request",
- value: function (e) {
- console.warn("请注意: ConnectionBase.request() 方法必须被派生类重写:");
- }
- }, {
- key: "_checkOptions",
- value: function (e) {
- if (!1 == !!e.url) throw new Ut({
- code: qt.NETWORK_BASE_OPTIONS_NO_URL,
- message: bn
- });
- }
- }, {
- key: "_initOptions",
- value: function (e) {
- e.method = ["POST", "GET", "PUT", "DELETE", "OPTION"].indexOf(e.method) >= 0 ? e.method : "POST", e.dataType = e.dataType || "json", e.responseType = e.responseType || "json";
- }
- }]), e;
- }()),
- zi = function e() {
- o(this, e);
- },
- Wi = function () {
- function e() {
- o(this, e), this.request = 0, this.success = 0, this.fail = 0, this.reportRate = 10, this.requestTimeCost = [];
- }
- return i(e, [{
- key: "report",
- value: function () {
- if (1 !== this.request) {
- if (this.request % this.reportRate != 0) return null;
- var e = this.avgRequestTime(),
- t = "runLoop reports: success=".concat(this.success, ",fail=").concat(this.fail, ",total=").concat(this.request, ",avg=").concat(e, ",cur=").concat(this.requestTimeCost[this.requestTimeCost.length - 1], ",max=").concat(Math.max.apply(null, this.requestTimeCost), ",min=").concat(Math.min.apply(null, this.requestTimeCost));
- de.log(t);
- }
- }
- }, {
- key: "setRequestTime",
- value: function (e, t) {
- var n = Math.abs(t - e);
- 100 === this.requestTimeCost.length && this.requestTimeCost.shift(), this.requestTimeCost.push(n);
- }
- }, {
- key: "avgRequestTime",
- value: function () {
- for (var e, t = this.requestTimeCost.length, n = 0, o = 0; o < t; o++) n += this.requestTimeCost[o];
- return e = n / t, Math.round(100 * e) / 100;
- }
- }]), e;
- }(),
- Ji = function () {
- function e(t) {
- o(this, e), this._initializeOptions(t), this._initializeMembers(), this.status = new Wi();
- }
- return i(e, [{
- key: "destructor",
- value: function () {
- clearTimeout(this._seedID);
- var e = this._index();
- for (var t in this) Object.prototype.hasOwnProperty.call(this, t) && (this[t] = null);
- return e;
- }
- }, {
- key: "setIndex",
- value: function (e) {
- this._index = e;
- }
- }, {
- key: "isRunning",
- value: function () {
- return !this._stoped;
- }
- }, {
- key: "getIndex",
- value: function () {
- return this._index;
- }
- }, {
- key: "_initializeOptions",
- value: function (e) {
- this.options = e;
- }
- }, {
- key: "_initializeMembers",
- value: function () {
- this._index = -1, this._seedID = 0, this._requestStatus = !1, this._stoped = !1, this._intervalTime = 0, this._intervalIncreaseStep = 1e3, this._intervalDecreaseStep = 1e3, this._intervalTimeMax = 5e3, this._protectTimeout = 3e3, this._getNoticeSeq = this.options.getNoticeSeq, this._retryCount = 0, this._responseTime = Date.now(), this._responseTimeThreshold = 2e3, this.requestor = new Yi(), this.abort = null;
- }
- }, {
- key: "start",
- value: function () {
- 0 === this._seedID ? (this._stoped = !1, this._send()) : de.log('WXRunLoop.start(): WXRunLoop is running now, if you want to restart runLoop , please run "stop()" first.');
- }
- }, {
- key: "_reset",
- value: function () {
- de.log("WXRunLoop.reset(), long poll _intervalMaxRate", this._intervalMaxRate), this.stop(), this.start();
- }
- }, {
- key: "_intervalTimeIncrease",
- value: function () {
- this._intervalTime !== this._responseTimeThreshold && (this._intervalTime < this._responseTimeThreshold && (this._intervalTime += this._intervalIncreaseStep), this._intervalTime > this._responseTimeThreshold && (this._intervalTime = this._responseTimeThreshold));
- }
- }, {
- key: "_intervalTimeDecrease",
- value: function () {
- 0 !== this._intervalTime && (this._intervalTime > 0 && (this._intervalTime -= this._intervalDecreaseStep), this._intervalTime < 0 && (this._intervalTime = 0));
- }
- }, {
- key: "_intervalTimeAdjustment",
- value: function () {
- var e = Date.now();
- 100 * Math.floor((e - this._responseTime) / 100) <= this._responseTimeThreshold ? this._intervalTimeIncrease() : this._intervalTimeDecrease(), this._responseTime = e;
- }
- }, {
- key: "_intervalTimeAdjustmentBaseOnResponseData",
- value: function (e) {
- e.ErrorCode === nt.SUCCESS ? this._intervalTimeDecrease() : this._intervalTimeIncrease();
- }
- }, {
- key: "_send",
- value: function () {
- var e = this;
- if (!0 !== this._requestStatus) {
- var t = this;
- this._requestStatus = !0, this.status.request++, "function" == typeof this.options.before && this.options.before(t.options.pack.requestData);
- var n = Date.now(),
- o = 0;
- this.requestor.request({
- url: t.options.pack.getUrl(),
- data: t.options.pack.requestData,
- method: t.options.pack.method,
- updateAbort: function (t) {
- e.abort = t;
- }
- }).then(function (r) {
- if (t._intervalTimeAdjustmentBaseOnResponseData.bind(e)(r.data), t._retryCount > 0 && (t._retryCount = 0), e.status.success++, o = Date.now(), e.status.setRequestTime(n, o), r.data.timecost = o - n, "function" == typeof t.options.success) try {
- e.options.success({
- pack: e.options.pack,
- error: !1,
- data: e.options.pack.callback(r.data)
- });
- } catch (i) {
- de.warn("WXRunLoop._send(), error:", i);
- }
- t._requestStatus = !1, !1 === t._stoped && (t._seedID = setTimeout(t._send.bind(t), t._intervalTime)), e.status.report();
- }).catch(function (r) {
- if (e.status.fail++, t._retryCount++, t._intervalTimeAdjustment.bind(e)(), !1 === t._stoped && (t._seedID = setTimeout(t._send.bind(t), t._intervalTime)), t._requestStatus = !1, "function" == typeof t.options.fail) try {
- e.options.fail({
- pack: e.options.pack,
- error: r,
- data: !1
- });
- } catch (i) {
- de.warn("WXRunLoop._send(), fail callback error:", i), de.error(i);
- }
- o = Date.now(), e.status.setRequestTime(n, o), e.status.report();
- });
- }
- }
- }, {
- key: "stop",
- value: function () {
- this._clearAllTimeOut(), this._stoped = !0;
- }
- }, {
- key: "_clearAllTimeOut",
- value: function () {
- clearTimeout(this._seedID), this._seedID = 0;
- }
- }]), e;
- }(),
- Xi = function () {
- function e(t) {
- o(this, e), this.tim = t, this.httpConnection = V ? new Yi() : new $i(), this.keepAliveConnections = [];
- }
- return i(e, [{
- key: "initializeListener",
- value: function () {
- this.tim.innerEmitter.on(Xo, this._stopAllRunLoop, this);
- }
- }, {
- key: "request",
- value: function (e) {
- var t = {
- url: e.url,
- data: e.requestData,
- method: e.method,
- callback: e.callback
- };
- return this.httpConnection.request(t).then(function (t) {
- return t.data = e.callback(t.data), t.data.errorCode !== nt.SUCCESS ? Cr(new Ut({
- code: t.data.errorCode,
- message: t.data.errorInfo
- })) : t;
- });
- }
- }, {
- key: "createRunLoop",
- value: function (e) {
- var t = this.createKeepAliveConnection(e);
- return t.setIndex(this.keepAliveConnections.push(t) - 1), t;
- }
- }, {
- key: "stopRunLoop",
- value: function (e) {
- e.stop();
- }
- }, {
- key: "_stopAllRunLoop",
- value: function () {
- for (var e = this.keepAliveConnections.length, t = 0; t < e; t++) this.keepAliveConnections[t].stop();
- }
- }, {
- key: "destroyRunLoop",
- value: function (e) {
- e.stop();
- var t = e.destructor();
- this.keepAliveConnections.slice(t, 1);
- }
- }, {
- key: "startRunLoopExclusive",
- value: function (e) {
- for (var t = e.getIndex(), n = 0; n < this.keepAliveConnections.length; n++) n !== t && this.keepAliveConnections[n].stop();
- e.start();
- }
- }, {
- key: "createKeepAliveConnection",
- value: function (e) {
- return V ? new Ji(e) : (this.tim.options.runLoopNetType === yt || this.tim.options.runLoopNetType, new zi(e));
- }
- }, {
- key: "clearAll",
- value: function () {
- this.conn.cancelAll();
- }
- }, {
- key: "reset",
- value: function () {
- this.keepAliveConnections = [];
- }
- }]), e;
- }(),
- Qi = function () {
- function t(e) {
- o(this, t), this.tim = e, this.tim.innerEmitter.on(er, this._onErrorDetected, this);
- }
- return i(t, [{
- key: "_onErrorDetected",
- value: function (t) {
- var n = t.data;
- new qr(Bi).setText("code=".concat(n.code, " message=").concat(n.message)).setNetworkType(this.tim.netMonitor.getNetworkType()).setEnd(), n.code ? de.warn("Oops! code:".concat(n.code, " message:").concat(n.message)) : de.warn("Oops! message:".concat(n.message, " stack:").concat(n.stack)), this.tim.outerEmitter.emit(e.ERROR, n);
- }
- }]), t;
- }(),
- Zi = function () {
- function e(n) {
- var r = this;
- o(this, e), Xe(n) || (this.userID = n.userID || "", this.nick = n.nick || "", this.gender = n.gender || "", this.birthday = n.birthday || 0, this.location = n.location || "", this.selfSignature = n.selfSignature || "", this.allowType = n.allowType || t.ALLOW_TYPE_ALLOW_ANY, this.language = n.language || 0, this.avatar = n.avatar || "", this.messageSettings = n.messageSettings || 0, this.adminForbidType = n.adminForbidType || t.FORBID_TYPE_NONE, this.level = n.level || 0, this.role = n.role || 0, this.lastUpdatedTime = 0, this.profileCustomField = [], Xe(n.profileCustomField) || n.profileCustomField.forEach(function (e) {
- r.profileCustomField.push({
- key: e.key,
- value: e.value
- });
- }));
- }
- return i(e, [{
- key: "validate",
- value: function (e) {
- var t = !0,
- n = "";
- if (Xe(e)) return {
- valid: !1,
- tips: "empty options"
- };
- if (e.profileCustomField) for (var o = e.profileCustomField.length, r = null, i = 0; i < o; i++) {
- if (r = e.profileCustomField[i], !_e(r.key) || -1 === r.key.indexOf("Tag_Profile_Custom")) return {
- valid: !1,
- tips: "自定义资料字段的前缀必须是 Tag_Profile_Custom"
- };
- if (!_e(r.value)) return {
- valid: !1,
- tips: "自定义资料字段的 value 必须是字符串"
- };
- }
- for (var s in e) if (Object.prototype.hasOwnProperty.call(e, s)) {
- if ("profileCustomField" === s) continue;
- if (Xe(e[s]) && !_e(e[s]) && !fe(e[s])) {
- n = "key:" + s + ", invalid value:" + e[s], t = !1;
- continue;
- }
- switch (s) {
- case "nick":
- _e(e[s]) || (n = "nick should be a string", t = !1), Le(e[s]) > 500 && (n = "nick name limited: must less than or equal to ".concat(500, " bytes, current size: ").concat(Le(e[s]), " bytes"), t = !1);
- break;
- case "gender":
- be(Et, e.gender) || (n = "key:gender, invalid value:" + e.gender, t = !1);
- break;
- case "birthday":
- fe(e.birthday) || (n = "birthday should be a number", t = !1);
- break;
- case "location":
- _e(e.location) || (n = "location should be a string", t = !1);
- break;
- case "selfSignature":
- _e(e.selfSignature) || (n = "selfSignature should be a string", t = !1);
- break;
- case "allowType":
- be(Dt, e.allowType) || (n = "key:allowType, invalid value:" + e.allowType, t = !1);
- break;
- case "language":
- fe(e.language) || (n = "language should be a number", t = !1);
- break;
- case "avatar":
- _e(e.avatar) || (n = "avatar should be a string", t = !1);
- break;
- case "messageSettings":
- 0 !== e.messageSettings && 1 !== e.messageSettings && (n = "messageSettings should be 0 or 1", t = !1);
- break;
- case "adminForbidType":
- be(Tt, e.adminForbidType) || (n = "key:adminForbidType, invalid value:" + e.adminForbidType, t = !1);
- break;
- case "level":
- fe(e.level) || (n = "level should be a number", t = !1);
- break;
- case "role":
- fe(e.role) || (n = "role should be a number", t = !1);
- break;
- default:
- n = "unknown key:" + s + " " + e[s], t = !1;
- }
- }
- return {
- valid: t,
- tips: n
- };
- }
- }]), e;
- }(),
- es = function () {
- function t(e) {
- o(this, t), this.userController = e, this.TAG = "profile", this.Actions = {
- Q: "query",
- U: "update"
- }, this.accountProfileMap = new Map(), this.expirationTime = 864e5;
- }
- return i(t, [{
- key: "setExpirationTime",
- value: function (e) {
- this.expirationTime = e;
- }
- }, {
- key: "getUserProfile",
- value: function (e) {
- var t = this,
- n = e.userIDList;
- e.fromAccount = this.userController.getMyAccount(), n.length > 100 && (de.warn("ProfileHandler.getUserProfile 获取用户资料人数不能超过100人"), n.length = 100);
- for (var o, r = [], i = [], s = 0, a = n.length; s < a; s++) o = n[s], this.userController.isMyFriend(o) && this._containsAccount(o) ? i.push(this._getProfileFromMap(o)) : r.push(o);
- if (0 === r.length) return Mr(i);
- e.toAccount = r;
- var u = e.bFromGetMyProfile || !1,
- c = [];
- e.toAccount.forEach(function (e) {
- c.push({
- toAccount: e,
- standardSequence: 0,
- customSequence: 0
- });
- }), e.userItem = c;
- var l = new qr(Ui);
- l.setText(n.length > 5 ? "userIDList.length=".concat(n.length) : "userIDList=".concat(n));
- var p = this.userController.generateConfig(this.TAG, this.Actions.Q, e);
- return this.userController.request(p).then(function (e) {
- l.setNetworkType(t.userController.getNetworkType()).setEnd(), de.info("ProfileHandler.getUserProfile ok");
- var n = t._handleResponse(e).concat(i);
- return u ? (t.userController.onGotMyProfile(), new vr(n[0])) : new vr(n);
- }).catch(function (e) {
- return t.userController.probeNetwork().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- r = n[1];
- l.setError(e, o, r).setEnd();
- }), de.error("ProfileHandler.getUserProfile error:", e), Cr(e);
- });
- }
- }, {
- key: "getMyProfile",
- value: function () {
- var e = this.userController.getMyAccount();
- if (de.log("ProfileHandler.getMyProfile myAccount=" + e), this._fillMap(), this._containsAccount(e)) {
- var t = this._getProfileFromMap(e);
- return de.debug("ProfileHandler.getMyProfile from cache, myProfile:" + JSON.stringify(t)), this.userController.onGotMyProfile(), Mr(t);
- }
- return this.getUserProfile({
- fromAccount: e,
- userIDList: [e],
- bFromGetMyProfile: !0
- });
- }
- }, {
- key: "_handleResponse",
- value: function (e) {
- for (var t, n, o = Ae.now(), r = e.data.userProfileItem, i = [], s = 0, a = r.length; s < a; s++) "@TLS#NOT_FOUND" !== r[s].to && "" !== r[s].to && (t = r[s].to, n = this._updateMap(t, this._getLatestProfileFromResponse(t, r[s].profileItem)), i.push(n));
- return de.log("ProfileHandler._handleResponse cost " + (Ae.now() - o) + " ms"), i;
- }
- }, {
- key: "_getLatestProfileFromResponse",
- value: function (e, t) {
- var n = {};
- if (n.userID = e, n.profileCustomField = [], !Xe(t)) for (var o = 0, r = t.length; o < r; o++) if (t[o].tag.indexOf("Tag_Profile_Custom") > -1) n.profileCustomField.push({
- key: t[o].tag,
- value: t[o].value
- });else switch (t[o].tag) {
- case Ct.NICK:
- n.nick = t[o].value;
- break;
- case Ct.GENDER:
- n.gender = t[o].value;
- break;
- case Ct.BIRTHDAY:
- n.birthday = t[o].value;
- break;
- case Ct.LOCATION:
- n.location = t[o].value;
- break;
- case Ct.SELFSIGNATURE:
- n.selfSignature = t[o].value;
- break;
- case Ct.ALLOWTYPE:
- n.allowType = t[o].value;
- break;
- case Ct.LANGUAGE:
- n.language = t[o].value;
- break;
- case Ct.AVATAR:
- n.avatar = t[o].value;
- break;
- case Ct.MESSAGESETTINGS:
- n.messageSettings = t[o].value;
- break;
- case Ct.ADMINFORBIDTYPE:
- n.adminForbidType = t[o].value;
- break;
- case Ct.LEVEL:
- n.level = t[o].value;
- break;
- case Ct.ROLE:
- n.role = t[o].value;
- break;
- default:
- de.warn("ProfileHandler._handleResponse unkown tag->", t[o].tag, t[o].value);
- }
- return n;
- }
- }, {
- key: "updateMyProfile",
- value: function (t) {
- var n = this,
- o = new qr(qi);
- o.setText(JSON.stringify(t));
- var r = new Zi().validate(t);
- if (!r.valid) return o.setCode(qt.UPDATE_PROFILE_INVALID_PARAM).setMessage("ProfileHandler.updateMyProfile info:".concat(r.tips)).setNetworkType(this.userController.getNetworkType()).setEnd(), de.error("ProfileHandler.updateMyProfile info:".concat(r.tips, ",请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#updateMyProfile")), Cr({
- code: qt.UPDATE_PROFILE_INVALID_PARAM,
- message: Nn
- });
- var i = [];
- for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && ("profileCustomField" === s ? t.profileCustomField.forEach(function (e) {
- i.push({
- tag: e.key,
- value: e.value
- });
- }) : i.push({
- tag: Ct[s.toUpperCase()],
- value: t[s]
- }));
- if (0 === i.length) return o.setCode(qt.UPDATE_PROFILE_NO_KEY).setMessage(Ln).setNetworkType(this.userController.getNetworkType()).setEnd(), de.error("ProfileHandler.updateMyProfile info:".concat(Ln, ",请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#updateMyProfile")), Cr({
- code: qt.UPDATE_PROFILE_NO_KEY,
- message: Ln
- });
- var a = this.userController.generateConfig(this.TAG, this.Actions.U, {
- fromAccount: this.userController.getMyAccount(),
- profileItem: i
- });
- return this.userController.request(a).then(function (r) {
- o.setNetworkType(n.userController.getNetworkType()).setEnd(), de.info("ProfileHandler.updateMyProfile ok");
- var i = n._updateMap(n.userController.getMyAccount(), t);
- return n.userController.emitOuterEvent(e.PROFILE_UPDATED, [i]), Mr(i);
- }).catch(function (e) {
- return n.userController.probeNetwork().then(function (t) {
- var n = y(t, 2),
- r = n[0],
- i = n[1];
- o.setError(e, r, i).setEnd();
- }), de.error("ProfileHandler.updateMyProfile error:", e), Cr(e);
- });
- }
- }, {
- key: "onProfileModified",
- value: function (t) {
- var n = t.data;
- if (!Xe(n)) {
- var o,
- r,
- i = n.length;
- de.info("ProfileHandler.onProfileModified length=" + i);
- for (var s = [], a = 0; a < i; a++) o = n[a].userID, r = this._updateMap(o, this._getLatestProfileFromResponse(o, n[a].profileList)), s.push(r);
- this.userController.emitInnerEvent(rr, s), this.userController.emitOuterEvent(e.PROFILE_UPDATED, s);
- }
- }
- }, {
- key: "_fillMap",
- value: function () {
- if (0 === this.accountProfileMap.size) {
- for (var e = this._getCachedProfiles(), t = Date.now(), n = 0, o = e.length; n < o; n++) t - e[n].lastUpdatedTime < this.expirationTime && this.accountProfileMap.set(e[n].userID, e[n]);
- de.log("ProfileHandler._fillMap from cache, map.size=" + this.accountProfileMap.size);
- }
- }
- }, {
- key: "_updateMap",
- value: function (e, t) {
- var n,
- o = Date.now();
- return this._containsAccount(e) ? (n = this._getProfileFromMap(e), t.profileCustomField && xe(n.profileCustomField, t.profileCustomField), Oe(n, t, ["profileCustomField"]), n.lastUpdatedTime = o) : (n = new Zi(t), (this.userController.isMyFriend(e) || e === this.userController.getMyAccount()) && (n.lastUpdatedTime = o, this.accountProfileMap.set(e, n))), this._flushMap(e === this.userController.getMyAccount()), n;
- }
- }, {
- key: "_flushMap",
- value: function (e) {
- var t = I(this.accountProfileMap.values()),
- n = this.userController.tim.storage;
- de.debug("ProfileHandler._flushMap length=".concat(t.length, " flushAtOnce=").concat(e)), n.setItem(this.TAG, t, e);
- }
- }, {
- key: "_containsAccount",
- value: function (e) {
- return this.accountProfileMap.has(e);
- }
- }, {
- key: "_getProfileFromMap",
- value: function (e) {
- return this.accountProfileMap.get(e);
- }
- }, {
- key: "_getCachedProfiles",
- value: function () {
- var e = this.userController.tim.storage.getItem(this.TAG);
- return Xe(e) ? [] : e;
- }
- }, {
- key: "onConversationsProfileUpdated",
- value: function (e) {
- for (var t, n, o, r = [], i = 0, s = e.length; i < s; i++) n = (t = e[i]).userID, this.userController.isMyFriend(n) && (this._containsAccount(n) ? (o = this._getProfileFromMap(n), Oe(o, t) > 0 && r.push(n)) : r.push(t.userID));
- 0 !== r.length && (de.info("ProfileHandler.onConversationsProfileUpdated toAccount:", r), this.getUserProfile({
- userIDList: r
- }));
- }
- }, {
- key: "reset",
- value: function () {
- this._flushMap(!0), this.accountProfileMap.clear();
- }
- }]), t;
- }(),
- ts = function () {
- function e(t) {
- o(this, e), this.options = t ? t.options : {
- enablePointer: !0
- }, this.pointsList = {}, this.reportText = {}, this.maxNameLen = 0, this.gapChar = "-", this.log = console.log, this.currentTask = "";
- }
- return i(e, [{
- key: "newTask",
- value: function (e) {
- !1 !== this.options.enablePointer && (e || (e = ["task", this._timeFormat()].join("-")), this.pointsList[e] = [], this.currentTask = e, console.log("Pointer new Task : ".concat(this.currentTask)));
- }
- }, {
- key: "deleteTask",
- value: function (e) {
- !1 !== this.options.enablePointer && (e || (e = this.currentTask), this.pointsList[e].length = 0, delete this.pointsList[e]);
- }
- }, {
- key: "dot",
- value: function () {
- var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "",
- t = arguments.length > 1 ? arguments[1] : void 0;
- if (!1 !== this.options.enablePointer) {
- t = t || this.currentTask;
- var n = +new Date();
- this.maxNameLen = this.maxNameLen < e.length ? e.length : this.maxNameLen, this.flen = this.maxNameLen + 10, this.pointsList[t].push({
- pointerName: e,
- time: n
- });
- }
- }
- }, {
- key: "_analisys",
- value: function (e) {
- if (!1 !== this.options.enablePointer) {
- e = e || this.currentTask;
- for (var t = this.pointsList[e], n = t.length, o = [], r = [], i = 0; i < n; i++) 0 !== i && (r = this._analisysTowPoints(t[i - 1], t[i]), o.push(r.join("")));
- return r = this._analisysTowPoints(t[0], t[n - 1], !0), o.push(r.join("")), o.join("");
- }
- }
- }, {
- key: "_analisysTowPoints",
- value: function (e, t) {
- var n = arguments.length > 2 && void 0 !== arguments[2] && arguments[2];
- if (!1 !== this.options.enablePointer) {
- var o = this.flen,
- r = t.time - e.time,
- i = r.toString(),
- s = e.pointerName + this.gapChar.repeat(o - e.pointerName.length),
- a = t.pointerName + this.gapChar.repeat(o - t.pointerName.length),
- u = this.gapChar.repeat(4 - i.length) + i,
- c = n ? ["%c", s, a, u, "ms\n%c"] : [s, a, u, "ms\n"];
- return c;
- }
- }
- }, {
- key: "report",
- value: function (e) {
- if (!1 !== this.options.enablePointer) {
- e = e || this.currentTask;
- var t = this._analisys(e);
- this.pointsList = [];
- var n = this._timeFormat(),
- o = "Pointer[".concat(e, "(").concat(n, ")]"),
- r = 4 * this.maxNameLen,
- i = (r - o.length) / 2;
- console.log(["-".repeat(i), o, "-".repeat(i)].join("")), console.log("%c" + t, "color:#66a", "color:red", "color:#66a"), console.log("-".repeat(r));
- }
- }
- }, {
- key: "_timeFormat",
- value: function () {
- var e = new Date(),
- t = this.zeroFix(e.getMonth() + 1, 2),
- n = this.zeroFix(e.getDate(), 2);
- return "".concat(t, "-").concat(n, " ").concat(e.getHours(), ":").concat(e.getSeconds(), ":").concat(e.getMinutes(), "~").concat(e.getMilliseconds());
- }
- }, {
- key: "zeroFix",
- value: function (e, t) {
- return ("000000000" + e).slice(-t);
- }
- }, {
- key: "reportAll",
- value: function () {
- if (!1 !== this.options.enablePointer) for (var e in this.pointsList) Object.prototype.hasOwnProperty.call(this.pointsList, e) && this.eport(e);
- }
- }]), e;
- }(),
- ns = function e(t, n) {
- o(this, e), this.userID = t;
- var r = {};
- if (r.userID = t, !Xe(n)) for (var i = 0, s = n.length; i < s; i++) switch (n[i].tag) {
- case Ct.NICK:
- r.nick = n[i].value;
- break;
- case Ct.GENDER:
- r.gender = n[i].value;
- break;
- case Ct.BIRTHDAY:
- r.birthday = n[i].value;
- break;
- case Ct.LOCATION:
- r.location = n[i].value;
- break;
- case Ct.SELFSIGNATURE:
- r.selfSignature = n[i].value;
- break;
- case Ct.ALLOWTYPE:
- r.allowType = n[i].value;
- break;
- case Ct.LANGUAGE:
- r.language = n[i].value;
- break;
- case Ct.AVATAR:
- r.avatar = n[i].value;
- break;
- case Ct.MESSAGESETTINGS:
- r.messageSettings = n[i].value;
- break;
- case Ct.ADMINFORBIDTYPE:
- r.adminForbidType = n[i].value;
- break;
- case Ct.LEVEL:
- r.level = n[i].value;
- break;
- case Ct.ROLE:
- r.role = n[i].value;
- break;
- default:
- de.debug("snsProfileItem unkown tag->", n[i].tag);
- }
- this.profile = new Zi(r);
- },
- os = function () {
- function e(t) {
- o(this, e), this.userController = t, this.TAG = "friend", this.Actions = {
- G: "get",
- D: "delete"
- }, this.friends = new Map(), this.pointer = new ts();
- }
- return i(e, [{
- key: "isMyFriend",
- value: function (e) {
- var t = this.friends.has(e);
- return t || de.debug("FriendHandler.isMyFriend " + e + " is not my friend"), t;
- }
- }, {
- key: "_transformFriendList",
- value: function (e) {
- if (!Xe(e) && !Xe(e.infoItem)) {
- de.info("FriendHandler._transformFriendList friendNum=" + e.friendNum);
- for (var t, n, o = e.infoItem, r = 0, i = o.length; r < i; r++) n = o[r].infoAccount, t = new ns(n, o[r].snsProfileItem), this.friends.set(n, t);
- }
- }
- }, {
- key: "_friends2map",
- value: function (e) {
- var t = new Map();
- for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.set(n, e[n]);
- return t;
- }
- }, {
- key: "getFriendList",
- value: function () {
- var e = this,
- t = {};
- t.fromAccount = this.userController.getMyAccount(), de.info("FriendHandler.getFriendList myAccount=" + t.fromAccount);
- var n = this.userController.generateConfig(this.TAG, this.Actions.G, t);
- return this.userController.request(n).then(function (t) {
- de.info("FriendHandler.getFriendList ok"), e._transformFriendList(t.data);
- var n = I(e.friends.values());
- return Mr(n);
- }).catch(function (e) {
- return de.error("FriendHandler.getFriendList error:", e), Cr(e);
- });
- }
- }, {
- key: "deleteFriend",
- value: function (e) {
- if (!Array.isArray(e.toAccount)) return de.error("FriendHandler.deleteFriend options.toAccount 必需是数组"), Cr({
- code: qt.DEL_FRIEND_INVALID_PARAM,
- message: Rn
- });
- e.toAccount.length > 1e3 && (de.warn("FriendHandler.deleteFriend 删除好友人数不能超过1000人"), e.toAccount.length = 1e3);
- var t = this.userController.generateConfig(this.TAG, this.Actions.D, e);
- return this.userController.request(t).then(function (e) {
- return de.info("FriendHandler.deleteFriend ok"), Mr();
- }).catch(function (e) {
- return de.error("FriendHandler.deleteFriend error:", e), Cr(e);
- });
- }
- }]), e;
- }(),
- rs = function e(t) {
- o(this, e), Xe || (this.userID = t.userID || "", this.timeStamp = t.timeStamp || 0);
- },
- is = function () {
- function t(e) {
- o(this, t), this.userController = e, this.TAG = "blacklist", this.Actions = {
- G: "get",
- C: "create",
- D: "delete"
- }, this.blacklistMap = new Map(), this.startIndex = 0, this.maxLimited = 100, this.curruentSequence = 0;
- }
- return i(t, [{
- key: "getBlacklist",
- value: function () {
- var e = this,
- t = {};
- t.fromAccount = this.userController.getMyAccount(), t.maxLimited = this.maxLimited, t.startIndex = 0, t.lastSequence = this.curruentSequence;
- var n = new qr(Fi),
- o = this.userController.generateConfig(this.TAG, this.Actions.G, t);
- return this.userController.request(o).then(function (t) {
- var o = Xe(t.data.blackListItem) ? 0 : t.data.blackListItem.length;
- return n.setNetworkType(e.userController.getNetworkType()).setText(o).setEnd(), de.info("BlacklistHandler.getBlacklist ok"), e.curruentSequence = t.data.curruentSequence, e._handleResponse(t.data.blackListItem, !0), e._onBlacklistUpdated();
- }).catch(function (t) {
- return e.userController.probeNetwork().then(function (e) {
- var o = y(e, 2),
- r = o[0],
- i = o[1];
- n.setError(t, r, i).setEnd();
- }), de.error("BlacklistHandler.getBlacklist error:", t), Cr(t);
- });
- }
- }, {
- key: "addBlacklist",
- value: function (e) {
- var t = this,
- n = new qr(xi);
- if (!Ie(e.userIDList)) return n.setCode(qt.ADD_BLACKLIST_INVALID_PARAM).setMessage("BlacklistHandler.addBlacklist options.userIDList 必需是数组").setNetworkType(this.userController.getNetworkType()).setEnd(), de.error("BlacklistHandler.addBlacklist options.userIDList 必需是数组"), Cr({
- code: qt.ADD_BLACKLIST_INVALID_PARAM,
- message: wn
- });
- var o = this.userController.tim.loginInfo.identifier;
- if (1 === e.userIDList.length && e.userIDList[0] === o) return n.setCode(qt.CANNOT_ADD_SELF_TO_BLACKLIST).setMessage(Gn).setNetworkType(this.userController.getNetworkType()).setEnd(), de.error("BlacklistHandler.addBlacklist 不能把自己拉黑"), Cr({
- code: qt.CANNOT_ADD_SELF_TO_BLACKLIST,
- message: Gn
- });
- e.userIDList.includes(o) && (e.userIDList = e.userIDList.filter(function (e) {
- return e !== o;
- }), de.warn("BlacklistHandler.addBlacklist 不能把自己拉黑,已过滤")), e.fromAccount = this.userController.getMyAccount(), e.toAccount = e.userIDList;
- var r = this.userController.generateConfig(this.TAG, this.Actions.C, e);
- return this.userController.request(r).then(function (o) {
- return n.setNetworkType(t.userController.getNetworkType()).setText(e.userIDList.length > 5 ? "userIDList.length=".concat(e.userIDList.length) : "userIDList=".concat(e.userIDList)).setEnd(), de.info("BlacklistHandler.addBlacklist ok"), t._handleResponse(o.data.resultItem, !0), t._onBlacklistUpdated();
- }).catch(function (e) {
- return t.userController.probeNetwork().then(function (t) {
- var o = y(t, 2),
- r = o[0],
- i = o[1];
- n.setError(e, r, i).setEnd();
- }), de.error("BlacklistHandler.addBlacklist error:", e), Cr(e);
- });
- }
- }, {
- key: "_handleResponse",
- value: function (e, t) {
- if (!Xe(e)) for (var n, o, r, i = 0, s = e.length; i < s; i++) o = e[i].to, r = e[i].resultCode, (Me(r) || 0 === r) && (t ? ((n = this.blacklistMap.has(o) ? this.blacklistMap.get(o) : new rs()).userID = o, !Xe(e[i].addBlackTimeStamp) && (n.timeStamp = e[i].addBlackTimeStamp), this.blacklistMap.set(o, n)) : this.blacklistMap.has(o) && (n = this.blacklistMap.get(o), this.blacklistMap.delete(o)));
- de.log("BlacklistHandler._handleResponse total=" + this.blacklistMap.size + " bAdd=" + t);
- }
- }, {
- key: "deleteBlacklist",
- value: function (e) {
- var t = this,
- n = new qr(Vi);
- if (!Ie(e.userIDList)) return n.setCode(qt.DEL_BLACKLIST_INVALID_PARAM).setMessage("BlacklistHandler.deleteBlacklist options.userIDList 必需是数组").setNetworkType(this.userController.getNetworkType()).setEnd(), de.error("BlacklistHandler.deleteBlacklist options.userIDList 必需是数组"), Cr({
- code: qt.DEL_BLACKLIST_INVALID_PARAM,
- message: Pn
- });
- e.fromAccount = this.userController.getMyAccount(), e.toAccount = e.userIDList;
- var o = this.userController.generateConfig(this.TAG, this.Actions.D, e);
- return this.userController.request(o).then(function (o) {
- return n.setNetworkType(t.userController.getNetworkType()).setText(e.userIDList.length > 5 ? "userIDList.length=".concat(e.userIDList.length) : "userIDList=".concat(e.userIDList)).setEnd(), de.info("BlacklistHandler.deleteBlacklist ok"), t._handleResponse(o.data.resultItem, !1), t._onBlacklistUpdated();
- }).catch(function (e) {
- return t.userController.probeNetwork().then(function (t) {
- var o = y(t, 2),
- r = o[0],
- i = o[1];
- n.setError(e, r, i).setEnd();
- }), de.error("BlacklistHandler.deleteBlacklist error:", e), Cr(e);
- });
- }
- }, {
- key: "_onBlacklistUpdated",
- value: function () {
- var t = I(this.blacklistMap.keys());
- return this.userController.emitOuterEvent(e.BLACKLIST_UPDATED, t), Mr(t);
- }
- }, {
- key: "handleBlackListDelAccount",
- value: function (t) {
- for (var n, o = [], r = 0, i = t.length; r < i; r++) n = t[r], this.blacklistMap.has(n) && (this.blacklistMap.delete(n), o.push(n));
- o.length > 0 && (de.log("BlacklistHandler.handleBlackListDelAccount delCount=" + o.length + " : " + o.join(",")), this.userController.emitOuterEvent(e.BLACKLIST_UPDATED, I(this.blacklistMap.keys())));
- }
- }, {
- key: "handleBlackListAddAccount",
- value: function (t) {
- for (var n, o = [], r = 0, i = t.length; r < i; r++) n = t[r], this.blacklistMap.has(n) || (this.blacklistMap.set(n, new rs({
- userID: n
- })), o.push(n));
- o.length > 0 && (de.log("BlacklistHandler.handleBlackListAddAccount addCount=" + o.length + " : " + o.join(",")), this.userController.emitOuterEvent(e.BLACKLIST_UPDATED, I(this.blacklistMap.keys())));
- }
- }, {
- key: "reset",
- value: function () {
- this.blacklistMap.clear(), this.startIndex = 0, this.maxLimited = 100, this.curruentSequence = 0;
- }
- }]), t;
- }(),
- ss = function () {
- function e(t) {
- o(this, e), this.userController = t, this.TAG = "applyC2C", this.Actions = {
- C: "create",
- G: "get",
- D: "delete",
- U: "update"
- };
- }
- return i(e, [{
- key: "applyAddFriend",
- value: function (e) {
- var t = this,
- n = this.userController.generateConfig(this.TAG, this.Actions.C, e),
- o = this.userController.request(n);
- return o.then(function (e) {
- t.userController.isActionSuccessful("applyAddFriend", t.Actions.C, e);
- }).catch(function (e) {}), o;
- }
- }, {
- key: "getPendency",
- value: function (e) {
- var t = this,
- n = this.userController.generateConfig(this.TAG, this.Actions.G, e),
- o = this.userController.request(n);
- return o.then(function (e) {
- t.userController.isActionSuccessful("getPendency", t.Actions.G, e);
- }).catch(function (e) {}), o;
- }
- }, {
- key: "deletePendency",
- value: function (e) {
- var t = this,
- n = this.userController.generateConfig(this.TAG, this.Actions.D, e),
- o = this.userController.request(n);
- return o.then(function (e) {
- t.userController.isActionSuccessful("deletePendency", t.Actions.D, e);
- }).catch(function (e) {}), o;
- }
- }, {
- key: "replyPendency",
- value: function () {
- var e = this,
- t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
- n = this.userController.generateConfig(this.TAG, this.Actions.U, t),
- o = this.userController.request(n);
- return o.then(function (t) {
- e.userController.isActionSuccessful("replyPendency", e.Actions.U, t);
- }).catch(function (e) {}), o;
- }
- }]), e;
- }(),
- as = function (e) {
- c(n, e);
- var t = v(n);
- function n(e) {
- var r;
- return o(this, n), (r = t.call(this, e)).profileHandler = new es(f(r)), r.friendHandler = new os(f(r)), r.blacklistHandler = new is(f(r)), r.applyC2CHandler = new ss(f(r)), r._initializeListener(), r;
- }
- return i(n, [{
- key: "_initializeListener",
- value: function (e) {
- var t = this.tim.innerEmitter;
- t.on(Mo, this.onContextUpdated, this), t.on(Ho, this.onProfileModified, this), t.on(Ko, this.onNewFriendMessages, this), t.on(nr, this.onConversationsProfileUpdated, this);
- }
- }, {
- key: "onContextUpdated",
- value: function (e) {
- var t = this.tim.context;
- !1 != !!t.a2Key && !1 != !!t.tinyID && (this.profileHandler.getMyProfile(), this.friendHandler.getFriendList(), this.blacklistHandler.getBlacklist());
- }
- }, {
- key: "onGotMyProfile",
- value: function () {
- this.triggerReady();
- }
- }, {
- key: "onProfileModified",
- value: function (e) {
- this.profileHandler.onProfileModified(e);
- }
- }, {
- key: "onNewFriendMessages",
- value: function (e) {
- de.debug("onNewFriendMessages", JSON.stringify(e.data)), Xe(e.data.blackListDelAccount) || this.blacklistHandler.handleBlackListDelAccount(e.data.blackListDelAccount), Xe(e.data.blackListAddAccount) || this.blacklistHandler.handleBlackListAddAccount(e.data.blackListAddAccount);
- }
- }, {
- key: "onConversationsProfileUpdated",
- value: function (e) {
- this.profileHandler.onConversationsProfileUpdated(e.data);
- }
- }, {
- key: "getMyAccount",
- value: function () {
- return this.tim.context.identifier;
- }
- }, {
- key: "isMyFriend",
- value: function (e) {
- return this.friendHandler.isMyFriend(e);
- }
- }, {
- key: "generateConfig",
- value: function (e, t, n) {
- return {
- name: e,
- action: t,
- param: n
- };
- }
- }, {
- key: "getMyProfile",
- value: function () {
- return this.profileHandler.getMyProfile();
- }
- }, {
- key: "getUserProfile",
- value: function (e) {
- return this.profileHandler.getUserProfile(e);
- }
- }, {
- key: "updateMyProfile",
- value: function (e) {
- return this.profileHandler.updateMyProfile(e);
- }
- }, {
- key: "getFriendList",
- value: function () {
- return this.friendHandler.getFriendList();
- }
- }, {
- key: "deleteFriend",
- value: function (e) {
- return this.friendHandler.deleteFriend(e);
- }
- }, {
- key: "getBlacklist",
- value: function () {
- return this.blacklistHandler.getBlacklist();
- }
- }, {
- key: "addBlacklist",
- value: function (e) {
- return this.blacklistHandler.addBlacklist(e);
- }
- }, {
- key: "deleteBlacklist",
- value: function (e) {
- return this.blacklistHandler.deleteBlacklist(e);
- }
- }, {
- key: "applyAddFriend",
- value: function (e) {
- return this.applyC2CHandler.applyAddFriend(e);
- }
- }, {
- key: "getPendency",
- value: function (e) {
- return this.applyC2CHandler.getPendency(e);
- }
- }, {
- key: "deletePendency",
- value: function (e) {
- return this.applyC2CHandler.deletePendency(e);
- }
- }, {
- key: "replyPendency",
- value: function (e) {
- return this.applyC2CHandler.replyPendency(e);
- }
- }, {
- key: "reset",
- value: function () {
- de.info("UserController.reset"), this.resetReady(), this.profileHandler.reset(), this.blacklistHandler.reset(), this.checkTimes = 0;
- }
- }]), n;
- }(mr),
- us = ["groupID", "name", "avatar", "type", "introduction", "notification", "ownerID", "selfInfo", "createTime", "infoSequence", "lastInfoTime", "lastMessage", "nextMessageSeq", "memberNum", "maxMemberNum", "memberList", "joinOption", "groupCustomField", "muteAllMembers"],
- cs = function () {
- function e(t) {
- o(this, e), this.groupID = "", this.name = "", this.avatar = "", this.type = "", this.introduction = "", this.notification = "", this.ownerID = "", this.createTime = "", this.infoSequence = "", this.lastInfoTime = "", this.selfInfo = {
- messageRemindType: "",
- joinTime: "",
- nameCard: "",
- role: ""
- }, this.lastMessage = {
- lastTime: "",
- lastSequence: "",
- fromAccount: "",
- messageForShow: ""
- }, this.nextMessageSeq = "", this.memberNum = "", this.memberCount = "", this.maxMemberNum = "", this.maxMemberCount = "", this.joinOption = "", this.groupCustomField = [], this.muteAllMembers = void 0, this._initGroup(t);
- }
- return i(e, [{
- key: "_initGroup",
- value: function (e) {
- for (var t in e) us.indexOf(t) < 0 || ("selfInfo" !== t ? ("memberNum" === t && (this.memberCount = e[t]), "maxMemberNum" === t && (this.maxMemberCount = e[t]), this[t] = e[t]) : this.updateSelfInfo(e[t]));
- }
- }, {
- key: "updateGroup",
- value: function (e) {
- var t = JSON.parse(JSON.stringify(e));
- t.lastMsgTime && (this.lastMessage.lastTime = t.lastMsgTime), Me(t.muteAllMembers) || ("On" === t.muteAllMembers ? t.muteAllMembers = !0 : t.muteAllMembers = !1), t.groupCustomField && xe(this.groupCustomField, t.groupCustomField), Me(t.memberNum) || (this.memberCount = t.memberNum), Me(t.maxMemberNum) || (this.maxMemberCount = t.maxMemberNum), Oe(this, t, ["members", "errorCode", "lastMsgTime", "groupCustomField", "memberNum", "maxMemberNum"]);
- }
- }, {
- key: "updateSelfInfo",
- value: function (e) {
- var t = e.nameCard,
- n = e.joinTime,
- o = e.role,
- r = e.messageRemindType;
- Oe(this.selfInfo, {
- nameCard: t,
- joinTime: n,
- role: o,
- messageRemindType: r
- }, [], ["", null, void 0, 0, NaN]);
- }
- }, {
- key: "setSelfNameCard",
- value: function (e) {
- this.selfInfo.nameCard = e;
- }
- }, {
- key: "memberNum",
- set: function (e) {},
- get: function () {
- return de.warn("!!!v2.8.0起弃用memberNum,请使用 memberCount"), this.memberCount;
- }
- }, {
- key: "maxMemberNum",
- set: function (e) {},
- get: function () {
- return de.warn("!!!v2.8.0起弃用maxMemberNum,请使用 maxMemberCount"), this.maxMemberCount;
- }
- }]), e;
- }(),
- ls = function (e, n) {
- if (Me(n)) return "";
- switch (e) {
- case t.MSG_TEXT:
- return n.text;
- case t.MSG_IMAGE:
- return "[图片]";
- case t.MSG_GEO:
- return "[位置]";
- case t.MSG_AUDIO:
- return "[语音]";
- case t.MSG_VIDEO:
- return "[视频]";
- case t.MSG_FILE:
- return "[文件]";
- case t.MSG_CUSTOM:
- return "[自定义消息]";
- case t.MSG_GRP_TIP:
- return "[群提示消息]";
- case t.MSG_GRP_SYS_NOTICE:
- return "[群系统通知]";
- case t.MSG_FACE:
- return "[动画表情]";
- default:
- return "";
- }
- },
- ps = function (e) {
- return Me(e) ? {
- lastTime: 0,
- lastSequence: 0,
- fromAccount: 0,
- messageForShow: "",
- payload: null,
- type: "",
- isRevoked: !1
- } : e instanceof Qn ? {
- lastTime: e.time || 0,
- lastSequence: e.sequence || 0,
- fromAccount: e.from || "",
- messageForShow: ls(e.type, e.payload),
- payload: e.payload || null,
- type: e.type || null,
- isRevoked: !1
- } : u(u({}, e), {}, {
- isRevoked: !1,
- messageForShow: ls(e.type, e.payload)
- });
- },
- gs = function () {
- function e(t) {
- o(this, e), this.conversationID = t.conversationID || "", this.unreadCount = t.unreadCount || 0, this.type = t.type || "", this.lastMessage = ps(t.lastMessage), t.lastMsgTime && (this.lastMessage.lastTime = t.lastMsgTime), this._isInfoCompleted = !1, this.peerReadTime = t.peerReadTime || 0, this.groupAtInfoList = [], this._initProfile(t);
- }
- return i(e, [{
- key: "_initProfile",
- value: function (e) {
- var n = this;
- Object.keys(e).forEach(function (t) {
- switch (t) {
- case "userProfile":
- n.userProfile = e.userProfile;
- break;
- case "groupProfile":
- n.groupProfile = e.groupProfile;
- }
- }), Me(this.userProfile) && this.type === t.CONV_C2C ? this.userProfile = new Zi({
- userID: e.conversationID.replace("C2C", "")
- }) : Me(this.groupProfile) && this.type === t.CONV_GROUP && (this.groupProfile = new cs({
- groupID: e.conversationID.replace("GROUP", "")
- }));
- }
- }, {
- key: "updateUnreadCount",
- value: function (e, n) {
- Me(e) || (He(this.subType) || Be(this.subType) ? this.unreadCount = 0 : n && this.type === t.CONV_GROUP ? this.unreadCount = e : this.unreadCount = this.unreadCount + e);
- }
- }, {
- key: "updateLastMessage",
- value: function (e) {
- this.lastMessage = ps(e);
- }
- }, {
- key: "updateGroupAtInfoList",
- value: function (e) {
- var n,
- o = (M(n = e.groupAtType) || C(n) || E(n) || D()).slice(0);
- -1 !== o.indexOf(t.CONV_AT_ME) && -1 !== o.indexOf(t.CONV_AT_ALL) && (o = [t.CONV_AT_ALL_AT_ME]);
- var r = {
- from: e.from,
- groupID: e.groupID,
- messageSequence: e.sequence,
- atTypeArray: o,
- __random: e.__random,
- __sequence: e.__sequence
- };
- this.groupAtInfoList.push(r), de.debug("Conversation.updateGroupAtInfoList conversationID=".concat(this.conversationID), this.groupAtInfoList);
- }
- }, {
- key: "clearGroupAtInfoList",
- value: function () {
- this.groupAtInfoList.length = 0;
- }
- }, {
- key: "reduceUnreadCount",
- value: function () {
- this.unreadCount >= 1 && (this.unreadCount -= 1);
- }
- }, {
- key: "isLastMessageRevoked",
- value: function (e) {
- var n = e.sequence,
- o = e.time;
- return this.type === t.CONV_C2C && n === this.lastMessage.lastSequence && o === this.lastMessage.lastTime || this.type === t.CONV_GROUP && n === this.lastMessage.lastSequence;
- }
- }, {
- key: "setLastMessageRevoked",
- value: function (e) {
- this.lastMessage.isRevoked = e;
- }
- }, {
- key: "toAccount",
- get: function () {
- return this.conversationID.replace("C2C", "").replace("GROUP", "");
- }
- }, {
- key: "subType",
- get: function () {
- return this.groupProfile ? this.groupProfile.type : "";
- }
- }]), e;
- }(),
- hs = function (n) {
- c(s, n);
- var r = v(s);
- function s(e) {
- var t;
- return o(this, s), (t = r.call(this, e)).pagingStatus = it.NOT_START, t.pagingTimeStamp = 0, t.conversationMap = new Map(), t.tempGroupList = [], t.tempGroupAtTipsList = [], t._initListeners(), t;
- }
- return i(s, [{
- key: "hasLocalConversationMap",
- value: function () {
- return this.conversationMap.size > 0;
- }
- }, {
- key: "_createLocalConversation",
- value: function (e) {
- return this.conversationMap.has(e) ? this.conversationMap.get(e) : (de.log("ConversationController._createLocalConversation conversationID:".concat(e)), new gs({
- conversationID: e,
- type: e.slice(0, 3) === t.CONV_C2C ? t.CONV_C2C : t.CONV_GROUP
- }));
- }
- }, {
- key: "hasLocalConversation",
- value: function (e) {
- return this.conversationMap.has(e);
- }
- }, {
- key: "getConversationList",
- value: function () {
- var e = this;
- de.log("ConversationController.getConversationList."), this.pagingStatus === it.REJECTED && (de.log("ConversationController.getConversationList. continue to sync conversationList"), this._syncConversationList());
- var t = new qr(oi);
- return this.request({
- name: "conversation",
- action: "query"
- }).then(function (n) {
- var o = n.data.conversations,
- r = void 0 === o ? [] : o,
- i = e._getConversationOptions(r);
- return e._updateLocalConversationList(i, !0), e._setStorageConversationList(), e._handleC2CPeerReadTime(), t.setText(r.length).setNetworkType(e.getNetworkType()).setEnd(), de.log("ConversationController.getConversationList ok."), Mr({
- conversationList: e.getLocalConversationList()
- });
- }).catch(function (n) {
- return e.probeNetwork().then(function (e) {
- var o = y(e, 2),
- r = o[0],
- i = o[1];
- t.setError(n, r, i).setEnd();
- }), de.error("ConversationController.getConversationList error:", n), Cr(n);
- });
- }
- }, {
- key: "_syncConversationList",
- value: function () {
- var e = this,
- t = new qr(ai);
- return this.pagingStatus === it.NOT_START && this.conversationMap.clear(), this._autoPagingSyncConversationList().then(function (n) {
- return e.pagingStatus = it.RESOLVED, e._setStorageConversationList(), e._handleC2CPeerReadTime(), t.setText("".concat(e.conversationMap.size)).setNetworkType(e.getNetworkType()).setEnd(), n;
- }).catch(function (n) {
- return e.pagingStatus = it.REJECTED, t.setText(e.pagingTimeStamp), e.probeNetwork().then(function (e) {
- var o = y(e, 2),
- r = o[0],
- i = o[1];
- t.setError(n, r, i).setEnd();
- }), Cr(n);
- });
- }
- }, {
- key: "_autoPagingSyncConversationList",
- value: function () {
- var e = this;
- return this.pagingStatus = it.PENDING, this.request({
- name: "conversation",
- action: "pagingQuery",
- param: {
- fromAccount: this.tim.context.identifier,
- timeStamp: this.pagingTimeStamp,
- orderType: 1
- }
- }).then(function (t) {
- var n = t.data,
- o = n.completeFlag,
- r = n.conversations,
- i = void 0 === r ? [] : r,
- s = n.timeStamp;
- if (de.log("ConversationController._autoPagingSyncConversationList completeFlag=".concat(o, " nums=").concat(i.length)), i.length > 0) {
- var a = e._getConversationOptions(i);
- e._updateLocalConversationList(a, !0);
- }
- if (e._isReady) e._emitConversationUpdate();else {
- if (!e.isLoggedIn()) return Mr();
- e.triggerReady();
- }
- return e.pagingTimeStamp = s, 1 !== o ? e._autoPagingSyncConversationList() : (e._handleGroupAtTipsList(), Mr());
- }).catch(function (t) {
- throw e.isLoggedIn() && (e._isReady || (de.warn("ConversationController._autoPagingSyncConversationList failed. error:".concat(Re(t))), e.triggerReady())), t;
- });
- }
- }, {
- key: "_handleC2CPeerReadTime",
- value: function () {
- var e,
- n = this.tim.messageController,
- o = S(this.conversationMap);
- try {
- for (o.s(); !(e = o.n()).done;) {
- var r = y(e.value, 2),
- i = r[0],
- s = r[1];
- s.type === t.CONV_C2C && (de.debug("ConversationController._handleC2CPeerReadTime", i, s.peerReadTime), n.recordPeerReadTime(i, s.peerReadTime));
- }
- } catch (a) {
- o.e(a);
- } finally {
- o.f();
- }
- }
- }, {
- key: "getConversationProfile",
- value: function (e) {
- var n = this,
- o = this.conversationMap.has(e) ? this.conversationMap.get(e) : this._createLocalConversation(e);
- if (o._isInfoCompleted || o.type === t.CONV_SYSTEM) return Mr({
- conversation: o
- });
- var r = new qr(ri);
- return de.log("ConversationController.getConversationProfile. conversationID:".concat(e, " lastMessage:"), o.lastMessage), this._updateUserOrGroupProfileCompletely(o).then(function (t) {
- return r.setNetworkType(n.getNetworkType()).setText("conversationID=".concat(e, " unreadCount=").concat(t.data.conversation.unreadCount)).setEnd(), de.log("ConversationController.getConversationProfile ok. conversationID:", e), t;
- }).catch(function (t) {
- return n.probeNetwork().then(function (n) {
- var o = y(n, 2),
- i = o[0],
- s = o[1];
- r.setError(t, i, s).setText("conversationID=".concat(e)).setEnd();
- }), de.error("ConversationController.getConversationProfile error:", t), Cr(t);
- });
- }
- }, {
- key: "deleteConversation",
- value: function (e) {
- var n = this,
- o = {};
- if (!this.conversationMap.has(e)) {
- var r = new Ut({
- code: qt.CONVERSATION_NOT_FOUND,
- message: hn
- });
- return Cr(r);
- }
- switch (this.conversationMap.get(e).type) {
- case t.CONV_C2C:
- o.type = 1, o.toAccount = e.replace(t.CONV_C2C, "");
- break;
- case t.CONV_GROUP:
- o.type = 2, o.toGroupID = e.replace(t.CONV_GROUP, "");
- break;
- case t.CONV_SYSTEM:
- return this.tim.groupController.deleteGroupSystemNotice({
- messageList: this.tim.messageController.getLocalMessageList(e)
- }), this.deleteLocalConversation(e), Mr({
- conversationID: e
- });
- default:
- var i = new Ut({
- code: qt.CONVERSATION_UN_RECORDED_TYPE,
- message: mn
- });
- return Cr(i);
- }
- var s = new qr(ii);
- return s.setText("conversationID=".concat(e)), de.log("ConversationController.deleteConversation. conversationID=".concat(e)), this.tim.setMessageRead({
- conversationID: e
- }).then(function () {
- return n.request({
- name: "conversation",
- action: "delete",
- param: o
- });
- }).then(function () {
- return s.setNetworkType(n.getNetworkType()).setEnd(), de.log("ConversationController.deleteConversation ok."), n.deleteLocalConversation(e), Mr({
- conversationID: e
- });
- }).catch(function (e) {
- return n.probeNetwork().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- r = n[1];
- s.setError(e, o, r).setEnd();
- }), de.error("ConversationController.deleteConversation error:", e), Cr(e);
- });
- }
- }, {
- key: "getLocalConversationList",
- value: function () {
- return I(this.conversationMap.values());
- }
- }, {
- key: "getLocalConversation",
- value: function (e) {
- return this.conversationMap.get(e);
- }
- }, {
- key: "_initLocalConversationList",
- value: function () {
- var e = new qr(si);
- de.time(Gr), de.log("ConversationController._initLocalConversationList.");
- var t = this._getStorageConversationList();
- if (t) {
- for (var n = t.length, o = 0; o < n; o++) this.conversationMap.set(t[o].conversationID, new gs(t[o]));
- this._emitConversationUpdate(!0, !1), e.setNetworkType(this.getNetworkType()).setText(n).setEnd();
- } else e.setNetworkType(this.getNetworkType()).setText(0).setEnd();
- this._syncConversationList();
- }
- }, {
- key: "_getStorageConversationList",
- value: function () {
- return this.tim.storage.getItem("conversationMap");
- }
- }, {
- key: "_setStorageConversationList",
- value: function () {
- var e = this.getLocalConversationList().slice(0, 20).map(function (e) {
- return {
- conversationID: e.conversationID,
- type: e.type,
- subType: e.subType,
- lastMessage: e.lastMessage,
- groupProfile: e.groupProfile,
- userProfile: e.userProfile
- };
- });
- this.tim.storage.setItem("conversationMap", e);
- }
- }, {
- key: "_initListeners",
- value: function () {
- var e = this;
- this.tim.innerEmitter.once(Mo, this._initLocalConversationList, this), this.tim.innerEmitter.on(Do, this._onSendOrReceiveMessage, this), this.tim.innerEmitter.on(So, this._handleSyncMessages, this), this.tim.innerEmitter.on(ko, this._handleSyncMessages, this), this.tim.innerEmitter.on(Ao, this._onSendOrReceiveMessage, this), this.tim.innerEmitter.on(Oo, this._onSendOrReceiveMessage, this), this.tim.innerEmitter.on(Ro, this._onSendOrReceiveMessage, this), this.tim.innerEmitter.on(Wo, this._onGroupListUpdated, this), this.tim.innerEmitter.on(rr, this._updateConversationUserProfile, this), this.tim.innerEmitter.on(No, this._onMessageRevoked, this), this.tim.innerEmitter.on(xo, this._onReceiveGroupAtTips, this), this.ready(function () {
- e.tempGroupList.length > 0 && (e._updateConversationGroupProfile(e.tempGroupList), e.tempGroupList.length = 0);
- });
- }
- }, {
- key: "_onGroupListUpdated",
- value: function (e) {
- this._updateConversationGroupProfile(e.data);
- }
- }, {
- key: "_updateConversationGroupProfile",
- value: function (e) {
- var t = this;
- Ie(e) && 0 === e.length || (this.hasLocalConversationMap() ? (e.forEach(function (e) {
- var n = "GROUP".concat(e.groupID);
- if (t.conversationMap.has(n)) {
- var o = t.conversationMap.get(n);
- o.groupProfile = e, o.lastMessage.lastSequence < e.nextMessageSeq && (o.lastMessage.lastSequence = e.nextMessageSeq - 1), o.subType || (o.subType = e.type);
- }
- }), this._emitConversationUpdate(!0, !1)) : this.tempGroupList = e);
- }
- }, {
- key: "_updateConversationUserProfile",
- value: function (e) {
- var t = this;
- e.data.forEach(function (e) {
- var n = "C2C".concat(e.userID);
- t.conversationMap.has(n) && (t.conversationMap.get(n).userProfile = e);
- }), this._emitConversationUpdate(!0, !1);
- }
- }, {
- key: "_onMessageRevoked",
- value: function (e) {
- var t = this,
- n = e.data;
- if (0 !== n.length) {
- var o = null,
- r = !1;
- n.forEach(function (e) {
- (o = t.conversationMap.get(e.conversationID)) && o.isLastMessageRevoked(e) && (r = !0, o.setLastMessageRevoked(!0));
- }), r && this._emitConversationUpdate(!0, !1);
- }
- }
- }, {
- key: "_onReceiveGroupAtTips",
- value: function (e) {
- var t = this,
- n = e.data,
- o = null;
- n.forEach(function (e) {
- e.groupAtTips ? o = e.groupAtTips : e.elements && (o = e.elements), o.__random = e.random, o.__sequence = e.clientSequence, t.tempGroupAtTipsList.push(o);
- }), de.debug("ConversationController._onReceiveGroupAtTips isReady=".concat(this._isReady), this.tempGroupAtTipsList), this._isReady && this._handleGroupAtTipsList();
- }
- }, {
- key: "_handleGroupAtTipsList",
- value: function () {
- var e = this;
- if (0 !== this.tempGroupAtTipsList.length) {
- var n = !1;
- this.tempGroupAtTipsList.forEach(function (o) {
- var r = o.groupID;
- if (o.from !== e.tim.context.identifier) {
- var i = e.conversationMap.get("".concat(t.CONV_GROUP).concat(r));
- i && (i.updateGroupAtInfoList(o), n = !0);
- }
- }), n && this._emitConversationUpdate(!0, !1), this.tempGroupAtTipsList.length = 0;
- }
- }
- }, {
- key: "deleteGroupAtTips",
- value: function (e) {
- de.log("ConversationController.deleteGroupAtTips");
- var t = this.conversationMap.get(e);
- if (!t) return Promise.resolve();
- var n = t.groupAtInfoList;
- if (0 === n.length) return Promise.resolve();
- var o = this.tim.context.identifier;
- return this.request({
- name: "conversation",
- action: "deleteGroupAtTips",
- param: {
- messageListToDelete: n.map(function (e) {
- return {
- from: e.from,
- to: o,
- messageSeq: e.__sequence,
- messageRandom: e.__random,
- groupID: e.groupID
- };
- })
- }
- }).then(function () {
- return de.log("ConversationController.deleteGroupAtTips ok. nums=".concat(n.length)), t.clearGroupAtInfoList(), Promise.resolve();
- }).catch(function (e) {
- return de.error("ConversationController.deleteGroupAtTips error:", e), Cr(e);
- });
- }
- }, {
- key: "_handleSyncMessages",
- value: function (e) {
- this._onSendOrReceiveMessage(e, !0);
- }
- }, {
- key: "_onSendOrReceiveMessage",
- value: function (e) {
- var t = this,
- n = arguments.length > 1 && void 0 !== arguments[1] && arguments[1],
- o = e.data.eventDataList;
- this._isReady ? 0 !== o.length && (this._getPeerReadTime(o), this._updateLocalConversationList(o, !1, n), this._setStorageConversationList(), this._emitConversationUpdate()) : this.ready(function () {
- t._onSendOrReceiveMessage(e, n);
- });
- }
- }, {
- key: "_getPeerReadTime",
- value: function (e) {
- var n = this,
- o = [];
- e.forEach(function (e) {
- n.conversationMap.has(e.conversationID) || e.type !== t.CONV_C2C || o.push(e.conversationID.replace(t.CONV_C2C, ""));
- }), o.length > 0 && (de.debug("ConversationController._getPeerReadTime userIDList:".concat(o)), this.tim.messageController.getPeerReadTime(o));
- }
- }, {
- key: "_updateLocalConversationList",
- value: function (e, t, n) {
- var o;
- o = this._updateTempConversations(e, t, n), this.conversationMap = new Map(this._sortConversations([].concat(I(o.conversations), I(this.conversationMap)))), t || this._updateUserOrGroupProfile(o.newerConversations);
- }
- }, {
- key: "_updateTempConversations",
- value: function (e, n, o) {
- for (var r = [], i = [], s = 0, a = e.length; s < a; s++) {
- var u = new gs(e[s]),
- c = this.conversationMap.get(u.conversationID);
- if (this.conversationMap.has(u.conversationID)) {
- var l = ["unreadCount", "allowType", "adminForbidType", "payload"];
- o && l.push("lastMessage"), Oe(c, u, l, [null, void 0, "", 0, NaN]), c.updateUnreadCount(u.unreadCount, n), o || (c.lastMessage.payload = e[s].lastMessage.payload), this.conversationMap.delete(c.conversationID), r.push([c.conversationID, c]);
- } else {
- if (u.type === t.CONV_GROUP) {
- var p = u.groupProfile.groupID,
- g = this.tim.groupController.getLocalGroupProfile(p);
- g && (u.groupProfile = g, u.updateUnreadCount(0));
- }
- i.push(u), r.push([u.conversationID, u]);
- }
- }
- return {
- conversations: r,
- newerConversations: i
- };
- }
- }, {
- key: "_sortConversations",
- value: function (e) {
- return e.sort(function (e, t) {
- return t[1].lastMessage.lastTime - e[1].lastMessage.lastTime;
- });
- }
- }, {
- key: "_updateUserOrGroupProfile",
- value: function (e) {
- var n = this;
- if (0 !== e.length) {
- var o = [],
- r = [];
- e.forEach(function (e) {
- if (e.type === t.CONV_C2C) o.push(e.toAccount);else if (e.type === t.CONV_GROUP) {
- var i = e.toAccount;
- n.tim.groupController.hasLocalGroup(i) ? e.groupProfile = n.tim.groupController.getLocalGroupProfile(i) : r.push(i);
- }
- }), o.length > 0 && this.tim.getUserProfile({
- userIDList: o
- }).then(function (e) {
- var t = e.data;
- Ie(t) ? t.forEach(function (e) {
- n.conversationMap.get("C2C".concat(e.userID)).userProfile = e;
- }) : n.conversationMap.get("C2C".concat(t.userID)).userProfile = t;
- }), r.length > 0 && this.tim.groupController.getGroupProfileAdvance({
- groupIDList: r,
- responseFilter: {
- groupBaseInfoFilter: ["Type", "Name", "FaceUrl"]
- }
- }).then(function (e) {
- e.data.successGroupList.forEach(function (e) {
- var t = "GROUP".concat(e.groupID);
- if (n.conversationMap.has(t)) {
- var o = n.conversationMap.get(t);
- Oe(o.groupProfile, e, [], [null, void 0, "", 0, NaN]), !o.subType && e.type && (o.subType = e.type);
- }
- });
- });
- }
- }
- }, {
- key: "_updateUserOrGroupProfileCompletely",
- value: function (e) {
- var n = this;
- return e.type === t.CONV_C2C ? this.tim.getUserProfile({
- userIDList: [e.toAccount]
- }).then(function (t) {
- var o = t.data;
- return 0 === o.length ? Cr(new Ut({
- code: qt.USER_OR_GROUP_NOT_FOUND,
- message: dn
- })) : (e.userProfile = o[0], e._isInfoCompleted = !0, n._unshiftConversation(e), Mr({
- conversation: e
- }));
- }) : this.tim.getGroupProfile({
- groupID: e.toAccount
- }).then(function (t) {
- return e.groupProfile = t.data.group, e._isInfoCompleted = !0, n._unshiftConversation(e), Mr({
- conversation: e
- });
- });
- }
- }, {
- key: "_unshiftConversation",
- value: function (e) {
- e instanceof gs && !this.conversationMap.has(e.conversationID) && (this.conversationMap = new Map([[e.conversationID, e]].concat(I(this.conversationMap))), this._setStorageConversationList(), this._emitConversationUpdate(!0, !1));
- }
- }, {
- key: "deleteLocalConversation",
- value: function (e) {
- this.conversationMap.delete(e), this._setStorageConversationList(), this.emitInnerEvent(or, e), this._emitConversationUpdate(!0, !1);
- }
- }, {
- key: "_getConversationOptions",
- value: function (e) {
- var t = [],
- n = e.filter(function (e) {
- var t = e.lastMsg;
- return ye(t);
- }).map(function (e) {
- if (1 === e.type) {
- var n = {
- userID: e.userID,
- nick: e.c2CNick,
- avatar: e.c2CImage
- };
- return t.push(n), {
- conversationID: "C2C".concat(e.userID),
- type: "C2C",
- lastMessage: {
- lastTime: e.time,
- lastSequence: e.sequence,
- fromAccount: e.lastC2CMsgFromAccount,
- messageForShow: e.messageShow,
- type: e.lastMsg.elements[0] ? e.lastMsg.elements[0].type : null,
- payload: e.lastMsg.elements[0] ? e.lastMsg.elements[0].content : null
- },
- userProfile: new Zi(n),
- peerReadTime: e.c2cPeerReadTime
- };
- }
- return {
- conversationID: "GROUP".concat(e.groupID),
- type: "GROUP",
- lastMessage: {
- lastTime: e.time,
- lastSequence: e.messageReadSeq + e.unreadCount,
- fromAccount: e.msgGroupFromAccount,
- messageForShow: e.messageShow,
- type: e.lastMsg.elements[0] ? e.lastMsg.elements[0].type : null,
- payload: e.lastMsg.elements[0] ? e.lastMsg.elements[0].content : null
- },
- groupProfile: new cs({
- groupID: e.groupID,
- name: e.groupNick,
- avatar: e.groupImage
- }),
- unreadCount: e.unreadCount,
- peerReadTime: 0
- };
- });
- return t.length > 0 && this.emitInnerEvent(nr, t), n;
- }
- }, {
- key: "_emitConversationUpdate",
- value: function () {
- var t = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0],
- n = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1],
- o = I(this.conversationMap.values());
- n && this.emitInnerEvent(tr, o), t && this.emitOuterEvent(e.CONVERSATION_LIST_UPDATED, o);
- }
- }, {
- key: "_conversationMapTreeShaking",
- value: function (e) {
- var n = this,
- o = new Map(I(this.conversationMap));
- e.forEach(function (e) {
- return o.delete(e.conversationID);
- }), o.has(t.CONV_SYSTEM) && o.delete(t.CONV_SYSTEM);
- var r = this.tim.groupController.getJoinedAVChatRoom();
- r && r.forEach(function (e) {
- o.delete("".concat(t.CONV_GROUP).concat(e));
- }), I(o.keys()).forEach(function (e) {
- return n.conversationMap.delete(e);
- });
- }
- }, {
- key: "reset",
- value: function () {
- this.pagingStatus = it.NOT_START, this.pagingTimeStamp = 0, this.conversationMap.clear(), this.tempGroupAtTipsList.length = 0, this.resetReady(), this.tim.innerEmitter.once(Mo, this._initLocalConversationList, this);
- }
- }]), s;
- }(mr),
- ds = function () {
- function e(t) {
- if (o(this, e), void 0 === t) throw new Ut({
- code: qt.MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS,
- message: zt
- });
- if (void 0 === t.tim) throw new Ut({
- code: qt.MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS,
- message: "".concat(zt, ".tim")
- });
- this.list = new Map(), this.tim = t.tim, this._initializeOptions(t);
- }
- return i(e, [{
- key: "getLocalOldestMessageByConversationID",
- value: function (e) {
- if (!e) return null;
- if (!this.list.has(e)) return null;
- var t = this.list.get(e).values();
- return t ? t.next().value : null;
- }
- }, {
- key: "_initializeOptions",
- value: function (e) {
- this.options = {};
- var t = {
- memory: {
- maxDatasPerKey: 100,
- maxBytesPerData: 256,
- maxKeys: 0
- },
- cache: {
- maxDatasPerKey: 10,
- maxBytesPerData: 256,
- maxKeys: 0
- }
- };
- for (var n in t) if (Object.prototype.hasOwnProperty.call(t, n)) {
- if (void 0 === e[n]) {
- this.options[n] = t[n];
- continue;
- }
- var o = t[n];
- for (var r in o) if (Object.prototype.hasOwnProperty.call(o, r)) {
- if (void 0 === e[n][r]) {
- this.options[n][r] = o[r];
- continue;
- }
- this.options[n][r] = e[n][r];
- }
- }
- }
- }, {
- key: "pushIn",
- value: function (e) {
- var t = e.conversationID,
- n = e.ID,
- o = !0;
- return this.list.has(t) || this.list.set(t, new Map()), this.list.has(t) && this.list.get(t).has(n) ? o = !1 : this.list.get(t).set(n, e), o;
- }
- }, {
- key: "unshift",
- value: function (e) {
- Ie(e) ? e.length > 0 && this._unshiftMultipleMessages(e) : this._unshiftSingleMessage(e);
- }
- }, {
- key: "_unshiftSingleMessage",
- value: function (e) {
- var t = e.conversationID,
- n = e.ID;
- if (!this.list.has(t)) return this.list.set(t, new Map()), void this.list.get(t).set(n, e);
- var o = Array.from(this.list.get(t));
- o.unshift([n, e]), this.list.set(t, new Map(o));
- }
- }, {
- key: "_unshiftMultipleMessages",
- value: function (e) {
- for (var t = e.length, n = [], o = e[0].conversationID, r = this.list.has(o) ? Array.from(this.list.get(o)) : [], i = 0; i < t; i++) n.push([e[i].ID, e[i]]);
- this.list.set(o, new Map(n.concat(r)));
- }
- }, {
- key: "remove",
- value: function (e) {
- var t = e.conversationID,
- n = e.ID;
- this.list.has(t) && this.list.get(t).delete(n);
- }
- }, {
- key: "revoke",
- value: function (e, t, n) {
- if (de.debug("revoke message", e, t, n), this.list.has(e)) {
- var o,
- r = S(this.list.get(e));
- try {
- for (r.s(); !(o = r.n()).done;) {
- var i = y(o.value, 2)[1];
- if (i.sequence === t && !i.isRevoked && (Me(n) || i.random === n)) return i.isRevoked = !0, i;
- }
- } catch (s) {
- r.e(s);
- } finally {
- r.f();
- }
- }
- return null;
- }
- }, {
- key: "removeByConversationID",
- value: function (e) {
- this.list.has(e) && this.list.delete(e);
- }
- }, {
- key: "updateMessageIsPeerReadProperty",
- value: function (e, t) {
- var n = [];
- if (this.list.has(e)) {
- var o,
- r = S(this.list.get(e));
- try {
- for (r.s(); !(o = r.n()).done;) {
- var i = y(o.value, 2)[1];
- i.time <= t && !i.isPeerRead && "out" === i.flow && (i.isPeerRead = !0, n.push(i));
- }
- } catch (s) {
- r.e(s);
- } finally {
- r.f();
- }
- de.log("MessagesList.updateMessageIsPeerReadProperty conversationID=".concat(e, " peerReadTime=").concat(t, " count=").concat(n.length));
- }
- return n;
- }
- }, {
- key: "hasLocalMessageList",
- value: function (e) {
- return this.list.has(e);
- }
- }, {
- key: "getLocalMessageList",
- value: function (e) {
- return this.hasLocalMessageList(e) ? I(this.list.get(e).values()) : [];
- }
- }, {
- key: "hasLocalMessage",
- value: function (e, t) {
- return !!this.hasLocalMessageList(e) && this.list.get(e).has(t);
- }
- }, {
- key: "getLocalMessage",
- value: function (e, t) {
- return this.hasLocalMessage(e, t) ? this.list.get(e).get(t) : null;
- }
- }, {
- key: "reset",
- value: function () {
- this.list.clear();
- }
- }]), e;
- }(),
- ms = function () {
- function e(t) {
- o(this, e), this.tim = t;
- }
- return i(e, [{
- key: "setMessageRead",
- value: function (e) {
- var n = e.conversationID,
- o = e.messageID,
- r = this.tim.conversationController,
- i = r.getLocalConversation(n);
- if (de.log("ReadReportHandler.setMessageRead conversationID=".concat(n, " unreadCount=").concat(i ? i.unreadCount : 0)), !i) return Mr();
- if (i.type !== t.CONV_GROUP || Xe(i.groupAtInfoList) || r.deleteGroupAtTips(n), 0 === i.unreadCount) return Mr();
- var s = o ? this.tim.messageController.getLocalMessage(n, o) : null;
- switch (i.type) {
- case t.CONV_C2C:
- return this._setC2CMessageRead({
- conversationID: n,
- lastMessageTime: s ? s.time : i.lastMessage.lastTime
- });
- case t.CONV_GROUP:
- return this._setGroupMessageRead({
- conversationID: n,
- lastMessageSeq: s ? s.sequence : i.lastMessage.lastSequence
- });
- case t.CONV_SYSTEM:
- return i.unreadCount = 0, Mr();
- default:
- return Mr();
- }
- }
- }, {
- key: "_setC2CMessageRead",
- value: function (e) {
- var t = this,
- n = e.conversationID,
- o = e.lastMessageTime;
- de.log("ReadReportHandler._setC2CMessageRead conversationID=".concat(n, " lastMessageTime=").concat(o)), fe(o) || de.warn("ReadReportHandler._setC2CMessageRead 请勿修改 Conversation.lastMessage.lastTime,否则可能会导致已读上报结果不准确");
- var r = new qr(Zr);
- return r.setText("".concat(n, "-").concat(o)), this.tim.messageController.request({
- name: "conversation",
- action: "setC2CMessageRead",
- param: {
- C2CMsgReaded: {
- cookie: "",
- C2CMsgReadedItem: [{
- toAccount: n.replace("C2C", ""),
- lastMessageTime: o,
- receipt: 1
- }]
- }
- }
- }).then(function () {
- return r.setNetworkType(t.tim.netMonitor.getNetworkType()).setEnd(), de.log("ReadReportHandler._setC2CMessageRead ok."), t._updateIsReadAfterReadReport({
- conversationID: n,
- lastMessageTime: o
- }), t._updateUnreadCount(n), new vr();
- }).catch(function (e) {
- return t.tim.netMonitor.probe().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- i = n[1];
- r.setError(e, o, i).setEnd();
- }), de.log("ReadReportHandler._setC2CMessageRead failed. ".concat(Re(e))), Cr(e);
- });
- }
- }, {
- key: "_setGroupMessageRead",
- value: function (e) {
- var t = this,
- n = e.conversationID,
- o = e.lastMessageSeq;
- de.log("ReadReportHandler._setGroupMessageRead conversationID=".concat(n, " lastMessageSeq=").concat(o)), fe(o) || de.warn("ReadReportHandler._setGroupMessageRead 请勿修改 Conversation.lastMessage.lastSequence,否则可能会导致已读上报结果不准确");
- var r = new qr(ei);
- return r.setText("".concat(n, "-").concat(o)), this.tim.messageController.request({
- name: "conversation",
- action: "setGroupMessageRead",
- param: {
- groupID: n.replace("GROUP", ""),
- messageReadSeq: o
- }
- }).then(function () {
- return r.setNetworkType(t.tim.netMonitor.getNetworkType()).setEnd(), de.log("ReadReportHandler._setGroupMessageRead ok."), t._updateIsReadAfterReadReport({
- conversationID: n,
- lastMessageSeq: o
- }), t._updateUnreadCount(n), new vr();
- }).catch(function (e) {
- return t.tim.netMonitor.probe().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- i = n[1];
- r.setError(e, o, i).setEnd();
- }), de.log("ReadReportHandler._setGroupMessageRead failed. ".concat(Re(e))), Cr(e);
- });
- }
- }, {
- key: "_updateUnreadCount",
- value: function (e) {
- var t = this.tim,
- n = t.conversationController,
- o = t.messageController,
- r = n.getLocalConversation(e),
- i = o.getLocalMessageList(e);
- r && (r.unreadCount = i.filter(function (e) {
- return !e.isRead && !e.getOnlineOnlyFlag();
- }).length, de.log("ReadReportHandler._updateUnreadCount conversationID=".concat(r.conversationID, " unreadCount=").concat(r.unreadCount)));
- }
- }, {
- key: "_updateIsReadAfterReadReport",
- value: function (e) {
- var t = e.conversationID,
- n = e.lastMessageSeq,
- o = e.lastMessageTime,
- r = this.tim.messageController.getLocalMessageList(t);
- if (0 !== r.length) for (var i, s = r.length - 1; s >= 0; s--) if (i = r[s], !(o && i.time > o || n && i.sequence > n)) {
- if ("in" === i.flow && i.isRead) break;
- i.setIsRead(!0);
- }
- }
- }, {
- key: "updateIsRead",
- value: function (e) {
- var n = this.tim,
- o = n.conversationController,
- r = n.messageController,
- i = o.getLocalConversation(e),
- s = r.getLocalMessageList(e);
- if (i && 0 !== s.length && !je(i.type)) {
- for (var a = [], u = 0; u < s.length; u++) "in" !== s[u].flow ? "out" !== s[u].flow || s[u].isRead || s[u].setIsRead(!0) : a.push(s[u]);
- var c = 0;
- if (i.type === t.CONV_C2C) {
- var l = a.slice(-i.unreadCount).filter(function (e) {
- return e.isRevoked;
- }).length;
- c = a.length - i.unreadCount - l;
- } else c = a.length - i.unreadCount;
- for (var p = 0; p < c && !a[p].isRead; p++) a[p].setIsRead(!0);
- }
- }
- }]), e;
- }(),
- fs = function () {
- function e(t) {
- var n = t.tim,
- r = t.messageController;
- o(this, e), this.tim = n, this.messageController = r, this.completedMap = new Map(), this._initListener();
- }
- return i(e, [{
- key: "getMessageList",
- value: function (e) {
- var t = this,
- n = e.conversationID,
- o = e.nextReqMessageID,
- r = e.count;
- if (this.tim.groupController.checkJoinedAVChatRoomByID(n.replace("GROUP", ""))) return de.log("GetMessageHandler.getMessageList not available in avchatroom. conversationID=".concat(n)), Mr({
- messageList: [],
- nextReqMessageID: "",
- isCompleted: !0
- });
- (Me(r) || r > 15) && (r = 15);
- var i = this._computeLeftCount({
- conversationID: n,
- nextReqMessageID: o
- });
- return de.log("GetMessageHandler.getMessageList. conversationID=".concat(n, " leftCount=").concat(i, " count=").concat(r, " nextReqMessageID=").concat(o)), this._needGetHistory({
- conversationID: n,
- leftCount: i,
- count: r
- }) ? this.messageController.getHistoryMessages({
- conversationID: n,
- count: 20
- }).then(function () {
- return i = t._computeLeftCount({
- conversationID: n,
- nextReqMessageID: o
- }), new vr(t._computeResult({
- conversationID: n,
- nextReqMessageID: o,
- count: r,
- leftCount: i
- }));
- }) : (de.log("GetMessageHandler.getMessageList. get messagelist from memory"), Mr(this._computeResult({
- conversationID: n,
- nextReqMessageID: o,
- count: r,
- leftCount: i
- })));
- }
- }, {
- key: "setCompleted",
- value: function (e) {
- de.log("GetMessageHandler.setCompleted. conversationID=".concat(e)), this.completedMap.set(e, !0);
- }
- }, {
- key: "deleteCompletedItem",
- value: function (e) {
- de.log("GetMessageHandler.deleteCompletedItem. conversationID=".concat(e)), this.completedMap.delete(e);
- }
- }, {
- key: "_initListener",
- value: function () {
- var e = this;
- this.tim.innerEmitter.on(ar, function () {
- e.setCompleted(t.CONV_SYSTEM);
- }), this.tim.innerEmitter.on(ir, function (n) {
- var o = n.data;
- e.setCompleted("".concat(t.CONV_GROUP).concat(o));
- });
- }
- }, {
- key: "_getMessageListSize",
- value: function (e) {
- return this.messageController.getLocalMessageList(e).length;
- }
- }, {
- key: "_needGetHistory",
- value: function (e) {
- var n = e.conversationID,
- o = e.leftCount,
- r = e.count,
- i = this.tim.conversationController.getLocalConversation(n),
- s = !!i && i.type === t.CONV_SYSTEM,
- a = !!i && i.subType === t.GRP_AVCHATROOM;
- return !s && !a && o < r && !this.completedMap.has(n);
- }
- }, {
- key: "_computeResult",
- value: function (e) {
- var t = e.conversationID,
- n = e.nextReqMessageID,
- o = e.count,
- r = e.leftCount,
- i = this._computeMessageList({
- conversationID: t,
- nextReqMessageID: n,
- count: o
- }),
- s = this._computeIsCompleted({
- conversationID: t,
- leftCount: r,
- count: o
- }),
- a = this._computeNextReqMessageID({
- messageList: i,
- isCompleted: s,
- conversationID: t
- });
- return de.log("GetMessageHandler._computeResult. conversationID=".concat(t, " leftCount=").concat(r, " count=").concat(o, " nextReqMessageID=").concat(a, " nums=").concat(i.length, " isCompleted=").concat(s)), {
- messageList: i,
- nextReqMessageID: a,
- isCompleted: s
- };
- }
- }, {
- key: "_computeNextReqMessageID",
- value: function (e) {
- var t = e.messageList,
- n = e.isCompleted,
- o = e.conversationID;
- if (!n) return 0 === t.length ? "" : t[0].ID;
- var r = this.messageController.getLocalMessageList(o);
- return 0 === r.length ? "" : r[0].ID;
- }
- }, {
- key: "_computeMessageList",
- value: function (e) {
- var t = e.conversationID,
- n = e.nextReqMessageID,
- o = e.count,
- r = this.messageController.getLocalMessageList(t),
- i = this._computeIndexEnd({
- nextReqMessageID: n,
- messageList: r
- }),
- s = this._computeIndexStart({
- indexEnd: i,
- count: o
- });
- return r.slice(s, i);
- }
- }, {
- key: "_computeIndexEnd",
- value: function (e) {
- var t = e.messageList,
- n = void 0 === t ? [] : t,
- o = e.nextReqMessageID;
- return o ? n.findIndex(function (e) {
- return e.ID === o;
- }) : n.length;
- }
- }, {
- key: "_computeIndexStart",
- value: function (e) {
- var t = e.indexEnd,
- n = e.count;
- return t > n ? t - n : 0;
- }
- }, {
- key: "_computeLeftCount",
- value: function (e) {
- var t = e.conversationID,
- n = e.nextReqMessageID;
- return n ? this.messageController.getLocalMessageList(t).findIndex(function (e) {
- return e.ID === n;
- }) : this._getMessageListSize(t);
- }
- }, {
- key: "_computeIsCompleted",
- value: function (e) {
- var t = e.conversationID;
- return !!(e.leftCount <= e.count && this.completedMap.has(t));
- }
- }, {
- key: "reset",
- value: function () {
- de.log("GetMessageHandler.reset"), this.completedMap.clear();
- }
- }]), e;
- }(),
- _s = function e(t) {
- o(this, e), this.value = t, this.next = null;
- },
- vs = function () {
- function e(t) {
- o(this, e), this.MAX_LENGTH = t, this.pTail = null, this.pNodeToDel = null, this.map = new Map(), de.log("SinglyLinkedList init MAX_LENGTH=".concat(this.MAX_LENGTH));
- }
- return i(e, [{
- key: "pushIn",
- value: function (e) {
- var t = new _s(e);
- if (this.map.size < this.MAX_LENGTH) null === this.pTail ? (this.pTail = t, this.pNodeToDel = t) : (this.pTail.next = t, this.pTail = t), this.map.set(e, 1);else {
- var n = this.pNodeToDel;
- this.pNodeToDel = this.pNodeToDel.next, this.map.delete(n.value), n.next = null, n = null, this.pTail.next = t, this.pTail = t, this.map.set(e, 1);
- }
- }
- }, {
- key: "has",
- value: function (e) {
- return this.map.has(e);
- }
- }, {
- key: "tail",
- value: function () {
- return this.pTail;
- }
- }, {
- key: "size",
- value: function () {
- return this.map.size;
- }
- }, {
- key: "data",
- value: function () {
- return Array.from(this.map.keys());
- }
- }, {
- key: "reset",
- value: function () {
- for (var e; null !== this.pNodeToDel;) e = this.pNodeToDel, this.pNodeToDel = this.pNodeToDel.next, e.next = null, e = null;
- this.pTail = null, this.map.clear();
- }
- }]), e;
- }(),
- ys = function () {
- function e(t) {
- o(this, e), this.tim = t;
- }
- return i(e, [{
- key: "upload",
- value: function (e) {
- switch (e.type) {
- case t.MSG_IMAGE:
- return this._uploadImage(e);
- case t.MSG_FILE:
- return this._uploadFile(e);
- case t.MSG_AUDIO:
- return this._uploadAudio(e);
- case t.MSG_VIDEO:
- return this._uploadVideo(e);
- default:
- return Promise.resolve();
- }
- }
- }, {
- key: "_uploadImage",
- value: function (e) {
- var t = this.tim,
- n = t.uploadController,
- o = t.messageController,
- r = e.getElements()[0],
- i = o.getMessageOptionByID(e.messageID);
- return n.uploadImage({
- file: i.payload.file,
- to: i.to,
- onProgress: function (e) {
- if (r.updatePercent(e), Ee(i.onProgress)) try {
- i.onProgress(e);
- } catch (t) {
- return Cr(new Ut({
- code: qt.MESSAGE_ONPROGRESS_FUNCTION_ERROR,
- message: "".concat(Qt)
- }));
- }
- }
- }).then(function (t) {
- var n = t.location,
- o = t.fileType,
- i = t.fileSize,
- s = t.width,
- a = t.height,
- c = Fe(n);
- r.updateImageFormat(o);
- var l = ze({
- originUrl: c,
- originWidth: s,
- originHeight: a,
- min: 198
- }),
- p = ze({
- originUrl: c,
- originWidth: s,
- originHeight: a,
- min: 720
- });
- return r.updateImageInfoArray([{
- size: i,
- url: c,
- width: s,
- height: a
- }, u({}, p), u({}, l)]), e;
- });
- }
- }, {
- key: "_uploadFile",
- value: function (e) {
- var t = this.tim,
- n = t.uploadController,
- o = t.messageController,
- r = e.getElements()[0],
- i = o.getMessageOptionByID(e.messageID);
- return n.uploadFile({
- file: i.payload.file,
- to: i.to,
- onProgress: function (e) {
- if (r.updatePercent(e), Ee(i.onProgress)) try {
- i.onProgress(e);
- } catch (t) {
- return Cr(new Ut({
- code: qt.MESSAGE_ONPROGRESS_FUNCTION_ERROR,
- message: "".concat(Qt)
- }));
- }
- }
- }).then(function (t) {
- var n = t.location,
- o = Fe(n);
- return r.updateFileUrl(o), e;
- });
- }
- }, {
- key: "_uploadAudio",
- value: function (e) {
- var t = this.tim,
- n = t.uploadController,
- o = t.messageController,
- r = e.getElements()[0],
- i = o.getMessageOptionByID(e.messageID);
- return n.uploadAudio({
- file: i.payload.file,
- to: i.to,
- onProgress: function (e) {
- if (r.updatePercent(e), Ee(i.onProgress)) try {
- i.onProgress(e);
- } catch (t) {
- return Cr(new Ut({
- code: qt.MESSAGE_ONPROGRESS_FUNCTION_ERROR,
- message: "".concat(Qt)
- }));
- }
- }
- }).then(function (t) {
- var n = t.location,
- o = Fe(n);
- return r.updateAudioUrl(o), e;
- });
- }
- }, {
- key: "_uploadVideo",
- value: function (e) {
- var t = this.tim,
- n = t.uploadController,
- o = t.messageController,
- r = e.getElements()[0],
- i = o.getMessageOptionByID(e.messageID);
- return n.uploadVideo({
- file: i.payload.file,
- to: i.to,
- onProgress: function (e) {
- if (r.updatePercent(e), Ee(i.onProgress)) try {
- i.onProgress(e);
- } catch (t) {
- return Cr(new Ut({
- code: qt.MESSAGE_ONPROGRESS_FUNCTION_ERROR,
- message: "".concat(Qt)
- }));
- }
- }
- }).then(function (t) {
- var n = Fe(t.location);
- return r.updateVideoUrl(n), e;
- });
- }
- }]), e;
- }(),
- Is = function (n) {
- c(s, n);
- var r = v(s);
- function s(e) {
- var t;
- return o(this, s), (t = r.call(this, e))._initializeMembers(), t._initializeListener(), t._initializeHandlers(), t.messageOptionMap = new Map(), t;
- }
- return i(s, [{
- key: "_initializeMembers",
- value: function () {
- this.messagesList = new ds({
- tim: this.tim
- }), this.currentMessageKey = {}, this.singlyLinkedList = new vs(100), this._peerReadTimeMap = new Map();
- }
- }, {
- key: "_initializeHandlers",
- value: function () {
- this.readReportHandler = new ms(this.tim, this), this.getMessageHandler = new fs({
- messageController: this,
- tim: this.tim
- }), this.uploadFileHandler = new ys(this.tim);
- }
- }, {
- key: "reset",
- value: function () {
- this.messagesList.reset(), this.currentMessageKey = {}, this.getMessageHandler.reset(), this.singlyLinkedList.reset(), this._peerReadTimeMap.clear(), this.messageOptionMap.clear();
- }
- }, {
- key: "_initializeListener",
- value: function () {
- var e = this.tim.innerEmitter;
- e.on(Uo, this._onReceiveC2CMessage, this), e.on(Eo, this._onSyncMessagesProcessing, this), e.on(To, this._onSyncMessagesFinished, this), e.on(qo, this._onReceiveGroupMessage, this), e.on(Fo, this._onReceiveGroupTips, this), e.on(Vo, this._onReceiveSystemNotice, this), e.on(Bo, this._onReceiveGroupMessageRevokedNotice, this), e.on(jo, this._onReceiveC2CMessageRevokedNotice, this), e.on($o, this._onC2CMessageReadReceipt, this), e.on(or, this._clearConversationMessages, this);
- }
- }, {
- key: "_guardForAVChatRoom",
- value: function (e) {
- if (e.conversationType === t.CONV_GROUP) {
- var n = this.tim.groupController,
- o = e.to;
- return n.hasLocalGroup(o) ? Promise.resolve() : n.getGroupProfile({
- groupID: o
- }).then(function (n) {
- var r = n.data.group.type;
- if (de.log("MessageController._guardForAVChatRoom. groupID=".concat(o, " type=").concat(r)), r === t.GRP_AVCHATROOM) {
- var i = "userId=".concat(e.from, " 未加入群 groupID=").concat(o, "。发消息前先使用 joinGroup 接口申请加群,详细请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#joinGroup");
- return de.warn("MessageController._guardForAVChatRoom sendMessage not allowed. ".concat(i)), Cr(new Ut({
- code: qt.MESSAGE_SEND_FAIL,
- message: i,
- data: {
- message: e
- }
- }));
- }
- return Promise.resolve();
- });
- }
- return Promise.resolve();
- }
- }, {
- key: "sendMessageInstance",
- value: function (e, n) {
- var o,
- r = this,
- i = null;
- switch (e.conversationType) {
- case t.CONV_C2C:
- i = this._handleOnSendC2CMessageSuccess.bind(this);
- break;
- case t.CONV_GROUP:
- i = this._handleOnSendGroupMessageSuccess.bind(this);
- break;
- default:
- return Cr(new Ut({
- code: qt.MESSAGE_SEND_INVALID_CONVERSATION_TYPE,
- message: Jt
- }));
- }
- return this.singlyLinkedList.pushIn(e.random), this.uploadFileHandler.upload(e).then(function () {
- return r._guardForAVChatRoom(e).then(function () {
- var i = null;
- return e.isSendable() ? (r._addSendMessageTotalCount(e), o = Date.now(), e.conversationType === t.CONV_C2C ? i = r._createC2CMessagePack(e, n) : e.conversationType === t.CONV_GROUP && (i = r._createGroupMessagePack(e, n)), r.request(i)) : Cr({
- code: qt.MESSAGE_FILE_URL_IS_EMPTY,
- message: gn
- });
- }).then(function (s) {
- return r._addSendMessageSuccessCount(e, o), e.conversationType === t.CONV_GROUP && (e.sequence = s.data.sequence, e.time = s.data.time, e.generateMessageID(r.tim.context.identifier)), r.messagesList.pushIn(e), i(e, s.data), r.messageOptionMap.delete(e.messageID), r._isOnlineMessage(e, n) ? e.setOnlineOnlyFlag(!0) : r.emitInnerEvent(Do, {
- eventDataList: [{
- conversationID: e.conversationID,
- unreadCount: 0,
- type: e.conversationType,
- subType: e.conversationSubType,
- lastMessage: e
- }]
- }), "TIMImageElem" === e.type && We(e.payload.imageInfoArray), new vr({
- message: e
- });
- }).catch(function (t) {
- e.status = rt.FAIL;
- var n = new qr(zr);
- return n.setMessageType(e.type).setText("".concat(r._generateTjgID(e), "-").concat(e.type, "-").concat(e.from, "-").concat(e.to)), r.probeNetwork().then(function (e) {
- var o = y(e, 2),
- r = o[0],
- i = o[1];
- n.setError(t, r, i).setEnd();
- }), de.error("MessageController.sendMessageInstance error:", t), Cr(new Ut({
- code: t && t.code ? t.code : qt.MESSAGE_SEND_FAIL,
- message: t && t.message ? t.message : Yt,
- data: {
- message: e
- }
- }));
- });
- });
- }
- }, {
- key: "_getSendMessageSpecifiedKey",
- value: function (e) {
- if (e.conversationType === t.CONV_C2C) return Ar;
- if (e.conversationType === t.CONV_GROUP) {
- var n = this.tim.groupController.getLocalGroupProfile(e.to);
- if (!n) return;
- var o = n.type;
- if (Ve(o)) return Or;
- if (Ke(o)) return Rr;
- if (He(o)) return Nr;
- if (Be(o)) return Lr;
- }
- }
- }, {
- key: "_addSendMessageTotalCount",
- value: function (e) {
- var t = this.tim.sumStatController;
- t.addTotalCount(kr);
- var n = this._getSendMessageSpecifiedKey(e);
- n && t.addTotalCount(n);
- }
- }, {
- key: "_addSendMessageSuccessCount",
- value: function (e, t) {
- var n = this.tim.sumStatController,
- o = Math.abs(Date.now() - t);
- n.addSuccessCount(kr), n.addCost(kr, o);
- var r = this._getSendMessageSpecifiedKey(e);
- r && (n.addSuccessCount(r), n.addCost(r, o));
- }
- }, {
- key: "resendMessage",
- value: function (e) {
- return e.isResend = !0, e.status = rt.UNSEND, this.sendMessageInstance(e);
- }
- }, {
- key: "_isFileLikeMessage",
- value: function (e) {
- return [t.MSG_IMAGE, t.MSG_FILE, t.MSG_AUDIO, t.MSG_VIDEO].indexOf(e.type) >= 0;
- }
- }, {
- key: "_resendBinaryTypeMessage",
- value: function () {}
- }, {
- key: "_canIUseOnlineOnlyFlag",
- value: function (e) {
- var n = this.tim.groupController.getJoinedAVChatRoom();
- return !n || !n.includes(e.to) || e.conversationType !== t.CONV_GROUP;
- }
- }, {
- key: "_isOnlineMessage",
- value: function (e, t) {
- return !(!this._canIUseOnlineOnlyFlag(e) || !t || !0 !== t.onlineUserOnly);
- }
- }, {
- key: "_createC2CMessagePack",
- value: function (e, t) {
- var n = null;
- return t && (t.offlinePushInfo && (n = t.offlinePushInfo), !0 === t.onlineUserOnly && (n ? n.disablePush = !0 : n = {
- disablePush: !0
- })), {
- name: "c2cMessage",
- action: "create",
- tjgID: this._generateTjgID(e),
- param: {
- toAccount: e.to,
- msgBody: e.getElements(),
- msgSeq: e.sequence,
- msgRandom: e.random,
- msgLifeTime: this._isOnlineMessage(e, t) ? 0 : void 0,
- offlinePushInfo: n ? {
- pushFlag: !0 === n.disablePush ? 1 : 0,
- title: n.title || "",
- desc: n.description || "",
- ext: n.extension || "",
- apnsInfo: {
- badgeMode: !0 === n.ignoreIOSBadge ? 1 : 0
- },
- androidInfo: {
- OPPOChannelID: n.androidOPPOChannelID || ""
- }
- } : void 0
- }
- };
- }
- }, {
- key: "_handleOnSendC2CMessageSuccess",
- value: function (e, t) {
- e.status = rt.SUCCESS, e.time = t.time;
- }
- }, {
- key: "_createGroupMessagePack",
- value: function (e, n) {
- var o = null;
- n && n.offlinePushInfo && (o = n.offlinePushInfo);
- var r = e.getGroupAtInfoList();
- return {
- name: "groupMessage",
- action: "create",
- tjgID: this._generateTjgID(e),
- param: {
- groupID: e.to,
- msgBody: e.getElements(),
- random: e.random,
- priority: e.priority,
- clientSequence: e.clientSequence,
- groupAtInfo: e.type !== t.MSG_TEXT || Xe(r) ? void 0 : r,
- onlineOnlyFlag: this._isOnlineMessage(e, n) ? 1 : 0,
- offlinePushInfo: o ? {
- pushFlag: !0 === o.disablePush ? 1 : 0,
- title: o.title || "",
- desc: o.description || "",
- ext: o.extension || "",
- apnsInfo: {
- badgeMode: !0 === o.ignoreIOSBadge ? 1 : 0
- },
- androidInfo: {
- OPPOChannelID: o.androidOPPOChannelID || ""
- }
- } : void 0
- }
- };
- }
- }, {
- key: "_handleOnSendGroupMessageSuccess",
- value: function (e, t) {
- e.sequence = t.sequence, e.time = t.time, e.status = rt.SUCCESS;
- }
- }, {
- key: "_onReceiveC2CMessage",
- value: function (n) {
- de.debug("MessageController._onReceiveC2CMessage nums=".concat(n.data.length));
- var o = Date.now(),
- r = this._newC2CMessageStoredAndSummary({
- notifiesList: n.data,
- type: t.CONV_C2C,
- C2CRemainingUnreadList: n.C2CRemainingUnreadList
- }),
- i = r.eventDataList,
- s = r.result;
- if (i.length > 0 && this.emitInnerEvent(Ao, {
- eventDataList: i,
- result: s
- }), s.length > 0) {
- var a = this.tim.sumStatController;
- a.addTotalCount(wr), a.addSuccessCount(wr), a.addCost(wr, Date.now() - o), this.emitOuterEvent(e.MESSAGE_RECEIVED, s);
- }
- }
- }, {
- key: "_onReceiveGroupMessage",
- value: function (t) {
- de.debug("MessageController._onReceiveGroupMessage nums=".concat(t.data.length));
- var n = Date.now(),
- o = this.newGroupMessageStoredAndSummary(t.data),
- r = o.eventDataList,
- i = o.result;
- if (r.length > 0 && this.emitInnerEvent(Oo, {
- eventDataList: r,
- result: i,
- isGroupTip: !1
- }), i.length > 0) {
- var s = this.tim.sumStatController;
- s.addTotalCount(wr), s.addSuccessCount(wr), s.addCost(wr, Date.now() - n), this.emitOuterEvent(e.MESSAGE_RECEIVED, i);
- }
- }
- }, {
- key: "_onReceiveGroupTips",
- value: function (t) {
- var n = Date.now(),
- o = t.data;
- de.debug("MessageController._onReceiveGroupTips nums=".concat(o.length));
- var r = this.newGroupTipsStoredAndSummary(o),
- i = r.eventDataList,
- s = r.result;
- if (i.length > 0 && this.emitInnerEvent(Oo, {
- eventDataList: i,
- result: s,
- isGroupTip: !0
- }), s.length > 0) {
- var a = this.tim.sumStatController;
- a.addTotalCount(wr), a.addSuccessCount(wr), a.addCost(wr, Date.now() - n), this.emitOuterEvent(e.MESSAGE_RECEIVED, s);
- }
- }
- }, {
- key: "_onReceiveSystemNotice",
- value: function (t) {
- var n = Date.now(),
- o = t.data,
- r = o.groupSystemNotices,
- i = o.type;
- de.debug("MessageController._onReceiveSystemNotice nums=".concat(r.length));
- var s = this.newSystemNoticeStoredAndSummary({
- notifiesList: r,
- type: i
- }),
- a = s.eventDataList,
- u = s.result;
- if (a.length > 0 && this.emitInnerEvent(Ro, {
- eventDataList: a,
- result: u,
- type: i
- }), u.length > 0 && "poll" === i) {
- var c = this.tim.sumStatController;
- c.addTotalCount(wr), c.addSuccessCount(wr), c.addCost(wr, Date.now() - n), this.emitOuterEvent(e.MESSAGE_RECEIVED, u);
- }
- }
- }, {
- key: "_onReceiveGroupMessageRevokedNotice",
- value: function (t) {
- var n = this;
- de.debug("MessageController._onReceiveGroupMessageRevokedNotice nums=".concat(t.data.length));
- var o = [],
- r = null;
- t.data.forEach(function (e) {
- e.elements.revokedInfos.forEach(function (e) {
- (r = n.messagesList.revoke("GROUP".concat(e.groupID), e.sequence)) && o.push(r);
- });
- }), 0 !== o.length && (this.emitInnerEvent(No, o), this.emitOuterEvent(e.MESSAGE_REVOKED, o));
- }
- }, {
- key: "_onReceiveC2CMessageRevokedNotice",
- value: function (t) {
- var n = this;
- de.debug("MessageController._onReceiveC2CMessageRevokedNotice nums=".concat(t.data.length));
- var o = [],
- r = null;
- t.data.forEach(function (e) {
- e.c2cMessageRevokedNotify.revokedInfos.forEach(function (e) {
- var t = n.tim.context.identifier === e.from ? "C2C".concat(e.to) : "C2C".concat(e.from);
- (r = n.messagesList.revoke(t, e.sequence, e.random)) && o.push(r);
- });
- }), 0 !== o.length && (this.emitInnerEvent(No, o), this.emitOuterEvent(e.MESSAGE_REVOKED, o));
- }
- }, {
- key: "_onC2CMessageReadReceipt",
- value: function (e) {
- var t = this;
- e.data.forEach(function (e) {
- if (!Xe(e.c2cMessageReadReceipt)) {
- var n = e.c2cMessageReadReceipt.to;
- e.c2cMessageReadReceipt.uinPairReadArray.forEach(function (e) {
- var o = e.peerReadTime;
- de.debug("MessageController._onC2CMessageReadReceipt to=".concat(n, " peerReadTime=").concat(o));
- var r = "C2C".concat(n);
- t.recordPeerReadTime(r, o), t._updateMessageIsPeerReadProperty(r, o);
- });
- }
- });
- }
- }, {
- key: "_updateMessageIsPeerReadProperty",
- value: function (n, o) {
- if (n.startsWith(t.CONV_C2C) && o > 0) {
- var r = this.messagesList.updateMessageIsPeerReadProperty(n, o);
- r.length > 0 && this.emitOuterEvent(e.MESSAGE_READ_BY_PEER, r);
- }
- }
- }, {
- key: "getPeerReadTime",
- value: function (e) {
- var t = this;
- if (!Xe(e)) {
- var n = new qr(ni);
- return de.log("MessageController.getPeerReadTime userIDList:".concat(e)), this.request({
- name: "c2cPeerReadTime",
- action: "get",
- param: {
- userIDList: e
- }
- }).then(function (o) {
- var r = o.data.peerReadTimeList;
- de.log("MessageController.getPeerReadTime ok. peerReadTimeList:".concat(r));
- for (var i = "", s = 0; s < e.length; s++) i += "".concat(e[s], "-").concat(r[s], " "), r[s] > 0 && t.recordPeerReadTime("C2C".concat(e[s]), r[s]);
- n.setNetworkType(t.getNetworkType()).setText(i).setEnd();
- }).catch(function (e) {
- t.probeNetwork().then(function (t) {
- var o = y(t, 2),
- r = o[0],
- i = o[1];
- n.setError(e, r, i).setEnd();
- }), de.warn("MessageController.getPeerReadTime failed. error:", e);
- });
- }
- }
- }, {
- key: "recordPeerReadTime",
- value: function (e, t) {
- this._peerReadTimeMap.has(e) ? this._peerReadTimeMap.get(e) < t && this._peerReadTimeMap.set(e, t) : this._peerReadTimeMap.set(e, t);
- }
- }, {
- key: "_clearConversationMessages",
- value: function (e) {
- var t = e.data;
- this.messagesList.removeByConversationID(t), this.getMessageHandler.deleteCompletedItem(t);
- }
- }, {
- key: "_pushIntoNoticeResult",
- value: function (e, t) {
- return !(!this.messagesList.pushIn(t) || this.singlyLinkedList.has(t.random)) && (e.push(t), !0);
- }
- }, {
- key: "_newC2CMessageStoredAndSummary",
- value: function (e) {
- for (var n = e.notifiesList, o = e.type, r = e.C2CRemainingUnreadList, i = e.isFromSync, s = null, a = [], u = [], c = {}, l = this.tim.bigDataHallwayController, p = 0, g = n.length; p < g; p++) {
- var h = n[p];
- if (h.currentUser = this.tim.context.identifier, h.conversationType = o, h.isSystemMessage = !!h.isSystemMessage, s = new Qn(h), h.elements = l.parseElements(h.elements, h.from), s.setElement(h.elements), !i) if (!this._pushIntoNoticeResult(u, s)) continue;
- 0 !== h.msgLifeTime ? void 0 === c[s.conversationID] ? c[s.conversationID] = a.push({
- conversationID: s.conversationID,
- unreadCount: "out" === s.flow ? 0 : 1,
- type: s.conversationType,
- subType: s.conversationSubType,
- lastMessage: s
- }) - 1 : (a[c[s.conversationID]].type = s.conversationType, a[c[s.conversationID]].subType = s.conversationSubType, a[c[s.conversationID]].lastMessage = s, "in" === s.flow && a[c[s.conversationID]].unreadCount++) : s.setOnlineOnlyFlag(!0);
- }
- if (Ie(r)) for (var d = function (e, n) {
- var o = a.find(function (t) {
- return t.conversationID === "C2C".concat(r[e].from);
- });
- o ? o.unreadCount += r[e].count : a.push({
- conversationID: "C2C".concat(r[e].from),
- unreadCount: r[e].count,
- type: t.CONV_C2C,
- lastMsgTime: r[e].lastMsgTime
- });
- }, m = 0, f = r.length; m < f; m++) d(m);
- return {
- eventDataList: a,
- result: u
- };
- }
- }, {
- key: "newGroupMessageStoredAndSummary",
- value: function (e) {
- var n = null,
- o = [],
- r = {},
- i = [],
- s = t.CONV_GROUP,
- a = this.tim.bigDataHallwayController,
- u = e.length;
- u > 1 && e.sort(function (e, t) {
- return e.sequence - t.sequence;
- });
- for (var c = 0; c < u; c++) {
- var l = e[c];
- if (l.currentUser = this.tim.context.identifier, l.conversationType = s, l.isSystemMessage = !!l.isSystemMessage, n = new Qn(l), l.elements = a.parseElements(l.elements, l.from), n.setElement(l.elements), !this._isMessageFromAVChatroom(n)) this._pushIntoNoticeResult(i, n) && (1 !== l.onlineOnlyFlag ? void 0 === r[n.conversationID] ? r[n.conversationID] = o.push({
- conversationID: n.conversationID,
- unreadCount: "out" === n.flow ? 0 : 1,
- type: n.conversationType,
- subType: n.conversationSubType,
- lastMessage: n
- }) - 1 : (o[r[n.conversationID]].type = n.conversationType, o[r[n.conversationID]].subType = n.conversationSubType, o[r[n.conversationID]].lastMessage = n, "in" === n.flow && o[r[n.conversationID]].unreadCount++) : n.setOnlineOnlyFlag(!0));
- }
- return {
- eventDataList: o,
- result: i
- };
- }
- }, {
- key: "_isMessageFromAVChatroom",
- value: function (e) {
- var t = e.conversationID.slice(5);
- return this.tim.groupController.checkJoinedAVChatRoomByID(t);
- }
- }, {
- key: "newGroupTipsStoredAndSummary",
- value: function (e) {
- for (var n = null, o = [], r = [], i = {}, s = 0, a = e.length; s < a; s++) {
- var c = e[s];
- if (c.currentUser = this.tim.context.identifier, c.conversationType = t.CONV_GROUP, (n = new Qn(c)).setElement({
- type: t.MSG_GRP_TIP,
- content: u(u({}, c.elements), {}, {
- groupProfile: c.groupProfile
- })
- }), n.isSystemMessage = !1, !this._isMessageFromAVChatroom(n)) this._pushIntoNoticeResult(r, n) && (void 0 === i[n.conversationID] ? i[n.conversationID] = o.push({
- conversationID: n.conversationID,
- unreadCount: "out" === n.flow ? 0 : 1,
- type: n.conversationType,
- subType: n.conversationSubType,
- lastMessage: n
- }) - 1 : (o[i[n.conversationID]].type = n.conversationType, o[i[n.conversationID]].subType = n.conversationSubType, o[i[n.conversationID]].lastMessage = n, "in" === n.flow && o[i[n.conversationID]].unreadCount++));
- }
- return {
- eventDataList: o,
- result: r
- };
- }
- }, {
- key: "newSystemNoticeStoredAndSummary",
- value: function (e) {
- var n = e.notifiesList,
- o = e.type,
- r = null,
- i = n.length,
- s = 0,
- a = [],
- c = {
- conversationID: t.CONV_SYSTEM,
- unreadCount: 0,
- type: t.CONV_SYSTEM,
- subType: null,
- lastMessage: null
- };
- for (s = 0; s < i; s++) {
- var l = n[s];
- if (l.elements.operationType !== _t) l.currentUser = this.tim.context.identifier, l.conversationType = t.CONV_SYSTEM, l.conversationID = t.CONV_SYSTEM, (r = new Qn(l)).setElement({
- type: t.MSG_GRP_SYS_NOTICE,
- content: u(u({}, l.elements), {}, {
- groupProfile: l.groupProfile
- })
- }), r.isSystemMessage = !0, (1 === r.sequence && 1 === r.random || 2 === r.sequence && 2 === r.random) && (r.sequence = we(), r.random = we(), r.generateMessageID(l.currentUser), de.log("MessageController.newSystemNoticeStoredAndSummary sequence and random maybe duplicated, regenerate. ID=".concat(r.ID))), this._pushIntoNoticeResult(a, r) && ("poll" === o ? c.unreadCount++ : "sync" === o && r.setIsRead(!0), c.subType = r.conversationSubType);
- }
- return c.lastMessage = a[a.length - 1], {
- eventDataList: a.length > 0 ? [c] : [],
- result: a
- };
- }
- }, {
- key: "_onSyncMessagesProcessing",
- value: function (e) {
- var n = this._newC2CMessageStoredAndSummary({
- notifiesList: e.data,
- type: t.CONV_C2C,
- isFromSync: !0,
- C2CRemainingUnreadList: e.C2CRemainingUnreadList
- }),
- o = n.eventDataList,
- r = n.result;
- this.emitInnerEvent(So, {
- eventDataList: o,
- result: r
- });
- }
- }, {
- key: "_onSyncMessagesFinished",
- value: function (e) {
- this.triggerReady();
- var n = this._newC2CMessageStoredAndSummary({
- notifiesList: e.data.messageList,
- type: t.CONV_C2C,
- isFromSync: !0,
- C2CRemainingUnreadList: e.data.C2CRemainingUnreadList
- }),
- o = n.eventDataList,
- r = n.result;
- this.emitInnerEvent(ko, {
- eventDataList: o,
- result: r
- });
- }
- }, {
- key: "getHistoryMessages",
- value: function (e) {
- if (e.conversationID === t.CONV_SYSTEM) return Mr();
- !e.count && (e.count = 15), e.count > 20 && (e.count = 20);
- var n = this.messagesList.getLocalOldestMessageByConversationID(e.conversationID);
- n || ((n = {}).time = 0, n.sequence = 0, 0 === e.conversationID.indexOf(t.CONV_C2C) ? (n.to = e.conversationID.replace(t.CONV_C2C, ""), n.conversationType = t.CONV_C2C) : 0 === e.conversationID.indexOf(t.CONV_GROUP) && (n.to = e.conversationID.replace(t.CONV_GROUP, ""), n.conversationType = t.CONV_GROUP));
- var o = "";
- switch (n.conversationType) {
- case t.CONV_C2C:
- return o = e.conversationID.replace(t.CONV_C2C, ""), this.getC2CRoamMessages({
- conversationID: e.conversationID,
- peerAccount: o,
- count: e.count,
- lastMessageTime: void 0 === this.currentMessageKey[e.conversationID] ? 0 : n.time
- });
- case t.CONV_GROUP:
- return this.getGroupRoamMessages({
- conversationID: e.conversationID,
- groupID: n.to,
- count: e.count,
- sequence: n.sequence - 1
- });
- default:
- return Mr();
- }
- }
- }, {
- key: "getC2CRoamMessages",
- value: function (e) {
- var n = this,
- o = e.conversationID,
- r = void 0 !== this.currentMessageKey[o] ? this.currentMessageKey[o] : "";
- de.log("MessageController.getC2CRoamMessages toAccount=".concat(e.peerAccount, " count=").concat(e.count || 15, " lastMessageTime=").concat(e.lastMessageTime || 0, " messageKey=").concat(r));
- var i = new qr(Jr);
- return this.request({
- name: "c2cMessage",
- action: "query",
- param: {
- peerAccount: e.peerAccount,
- count: e.count || 15,
- lastMessageTime: e.lastMessageTime || 0,
- messageKey: r
- }
- }).then(function (s) {
- var a = s.data,
- u = a.complete,
- c = a.messageList;
- Me(c) ? de.log("MessageController.getC2CRoamMessages ok. complete=".concat(u, " but messageList is undefined!")) : de.log("MessageController.getC2CRoamMessages ok. complete=".concat(u, " nums=").concat(c.length)), i.setNetworkType(n.getNetworkType()).setText("".concat(e.peerAccount, "-").concat(e.count || 15, "-").concat(e.lastMessageTime || 0, "-").concat(r, "-").concat(u, "-").concat(c ? c.length : "undefined")).setEnd(), 1 === u && n.getMessageHandler.setCompleted(o);
- var l = n._roamMessageStore(c, t.CONV_C2C, o);
- n.readReportHandler.updateIsRead(o), n.currentMessageKey[o] = s.data.messageKey;
- var p = n._peerReadTimeMap.get(o);
- if (de.log("MessageController.getC2CRoamMessages update isPeerRead property. conversationID=".concat(o, " peerReadTime=").concat(p)), p) n._updateMessageIsPeerReadProperty(o, p);else {
- var g = o.replace(t.CONV_C2C, "");
- n.getPeerReadTime([g]).then(function () {
- n._updateMessageIsPeerReadProperty(o, n._peerReadTimeMap.get(o));
- });
- }
- return l;
- }).catch(function (t) {
- return n.probeNetwork().then(function (n) {
- var o = y(n, 2),
- s = o[0],
- a = o[1];
- i.setError(t, s, a).setText("".concat(e.peerAccount, "-").concat(e.count || 15, "-").concat(e.lastMessageTime || 0, "-").concat(r)).setEnd();
- }), de.warn("MessageController.getC2CRoamMessages failed. ".concat(t)), Cr(t);
- });
- }
- }, {
- key: "_computeLastSequence",
- value: function (e) {
- return e.sequence >= 0 ? Promise.resolve(e.sequence) : this.tim.groupController.getGroupLastSequence(e.groupID);
- }
- }, {
- key: "getGroupRoamMessages",
- value: function (e) {
- var n = this,
- o = new qr(Xr),
- r = 0;
- return this._computeLastSequence(e).then(function (t) {
- return r = t, de.log("MessageController.getGroupRoamMessages groupID=".concat(e.groupID, " lastSequence=").concat(r)), n.request({
- name: "groupMessage",
- action: "query",
- param: {
- groupID: e.groupID,
- count: 21,
- sequence: r
- }
- });
- }).then(function (i) {
- var s = i.data,
- a = s.messageList,
- u = s.complete;
- Me(a) ? de.log("MessageController.getGroupRoamMessages ok. complete=".concat(u, " but messageList is undefined!")) : de.log("MessageController.getGroupRoamMessages ok. complete=".concat(u, " nums=").concat(a.length)), o.setNetworkType(n.getNetworkType()).setText("".concat(e.groupID, "-").concat(r, "-").concat(u, "-").concat(a ? a.length : "undefined")).setEnd();
- var c = "GROUP".concat(e.groupID);
- if (2 === u || Xe(a)) return n.getMessageHandler.setCompleted(c), [];
- var l = n._roamMessageStore(a, t.CONV_GROUP, c);
- return n.readReportHandler.updateIsRead(c), n._patchConversationLastMessage(c), l;
- }).catch(function (t) {
- return n.probeNetwork().then(function (n) {
- var i = y(n, 2),
- s = i[0],
- a = i[1];
- o.setError(t, s, a).setText("".concat(e.groupID, "-").concat(r)).setEnd();
- }), de.warn("MessageController.getGroupRoamMessages failed. ".concat(t)), Cr(t);
- });
- }
- }, {
- key: "_patchConversationLastMessage",
- value: function (e) {
- var t = this.tim.conversationController.getLocalConversation(e);
- if (t) {
- var n = t.lastMessage,
- o = n.messageForShow,
- r = n.payload;
- if (Xe(o) || Xe(r)) {
- var i = this.messagesList.getLocalMessageList(e);
- if (0 === i.length) return;
- var s = i[i.length - 1];
- de.log("MessageController._patchConversationLastMessage conversationID:".concat(e, " payload:"), s.payload), t.updateLastMessage(s);
- }
- }
- }
- }, {
- key: "_roamMessageStore",
- value: function () {
- var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [],
- n = arguments.length > 1 ? arguments[1] : void 0,
- o = arguments.length > 2 ? arguments[2] : void 0,
- r = null,
- i = [],
- s = 0,
- a = e.length,
- c = null,
- l = n === t.CONV_GROUP,
- p = this.tim.bigDataHallwayController,
- g = function () {
- s = l ? e.length - 1 : 0, a = l ? 0 : e.length;
- },
- h = function () {
- l ? --s : ++s;
- },
- d = function () {
- return l ? s >= a : s < a;
- };
- for (g(); d(); h()) if (l && 1 === e[s].sequence && this.getMessageHandler.setCompleted(o), 1 !== e[s].isPlaceMessage) if ((r = new Qn(e[s])).to = e[s].to, r.isSystemMessage = !!e[s].isSystemMessage, r.conversationType = n, e[s].event === at.JSON.TYPE.GROUP.TIP ? c = {
- type: t.MSG_GRP_TIP,
- content: u(u({}, e[s].elements), {}, {
- groupProfile: e[s].groupProfile
- })
- } : (e[s].elements = p.parseElements(e[s].elements, e[s].from), c = e[s].elements), Xe(c)) {
- var m = new qr(ti);
- m.setText("from:".concat(r.from, " to:").concat(r.to, " sequence:").concat(r.sequence, " event:").concat(e[s].event)), m.setNetworkType(this.getNetworkType()).setEnd();
- } else r.setElement(c), r.reInitialize(this.tim.context.identifier), i.push(r);
- return this.messagesList.unshift(i), g = h = d = null, i;
- }
- }, {
- key: "getLocalMessageList",
- value: function (e) {
- return this.messagesList.getLocalMessageList(e);
- }
- }, {
- key: "getLocalMessage",
- value: function (e, t) {
- return this.messagesList.getLocalMessage(e, t);
- }
- }, {
- key: "hasLocalMessage",
- value: function (e, t) {
- return this.messagesList.hasLocalMessage(e, t);
- }
- }, {
- key: "deleteLocalMessage",
- value: function (e) {
- e instanceof Qn && this.messagesList.remove(e);
- }
- }, {
- key: "revokeMessage",
- value: function (e) {
- var n,
- o = this;
- e.conversationType === t.CONV_C2C ? n = {
- name: "c2cMessageWillBeRevoked",
- action: "create",
- param: {
- msgInfo: {
- fromAccount: e.from,
- toAccount: e.to,
- msgSeq: e.sequence,
- msgRandom: e.random,
- msgTimeStamp: e.time
- }
- }
- } : e.conversationType === t.CONV_GROUP && (n = {
- name: "groupMessageWillBeRevoked",
- action: "create",
- param: {
- to: e.to,
- msgSeqList: [{
- msgSeq: e.sequence
- }]
- }
- });
- var r = new qr(Qr);
- return r.setMessageType(e.type).setText("".concat(this._generateTjgID(e), "-").concat(e.type, "-").concat(e.from, "-").concat(e.to)), this.request(n).then(function (t) {
- var n = t.data.recallRetList;
- if (!Xe(n) && 0 !== n[0].retCode) {
- var i = new Ut({
- code: n[0].retCode,
- message: bt[n[0].retCode] || Zt,
- data: {
- message: e
- }
- });
- return r.setCode(i.code).setMessage(i.message).setEnd(), Cr(i);
- }
- return de.info("MessageController.revokeMessage ok. ID=".concat(e.ID)), e.isRevoked = !0, r.setEnd(), o.emitInnerEvent(No, [e]), new vr({
- message: e
- });
- }).catch(function (t) {
- o.probeNetwork().then(function (e) {
- var n = y(e, 2),
- o = n[0],
- i = n[1];
- r.setError(t, o, i).setEnd();
- });
- var n = new Ut({
- code: t && t.code ? t.code : qt.MESSAGE_REVOKE_FAIL,
- message: t && t.message ? t.message : Zt,
- data: {
- message: e
- }
- });
- return de.warn("MessageController.revokeMessage failed. ID=".concat(e.ID, " code=").concat(n.code, " message=").concat(n.message)), Cr(n);
- });
- }
- }, {
- key: "setMessageRead",
- value: function (e) {
- var t = this;
- return new Promise(function (n, o) {
- t.ready(function () {
- t.readReportHandler.setMessageRead(e).then(n).catch(o);
- });
- });
- }
- }, {
- key: "getMessageList",
- value: function (e) {
- return this.getMessageHandler.getMessageList(e);
- }
- }, {
- key: "createTextMessage",
- value: function (e) {
- e.currentUser = this.tim.context.identifier;
- var t = new Qn(e),
- n = "string" == typeof e.payload ? e.payload : e.payload.text,
- o = new st({
- text: n
- });
- return t.setElement(o), t;
- }
- }, {
- key: "createCustomMessage",
- value: function (e) {
- e.currentUser = this.tim.context.identifier;
- var t = new Qn(e),
- n = new zn({
- data: e.payload.data,
- description: e.payload.description,
- extension: e.payload.extension
- });
- return t.setElement(n), t;
- }
- }, {
- key: "createImageMessage",
- value: function (e) {
- e.currentUser = this.tim.context.identifier;
- var t = new Qn(e);
- if (V) {
- var n = e.payload.file;
- if (me(n)) return void de.warn("小程序环境下调用 createImageMessage 接口时,payload.file 不支持传入 File 对象");
- var o = n.tempFilePaths[0],
- r = {
- url: o,
- name: o.slice(o.lastIndexOf("/") + 1),
- size: n.tempFiles[0].size,
- type: o.slice(o.lastIndexOf(".") + 1).toLowerCase()
- };
- e.payload.file = r;
- } else if (G && me(e.payload.file)) {
- var i = e.payload.file;
- e.payload.file = {
- files: [i]
- };
- }
- var s = new St({
- imageFormat: at.IMAGE_FORMAT.UNKNOWN,
- uuid: this._generateUUID(),
- file: e.payload.file
- });
- return t.setElement(s), this.messageOptionMap.set(t.messageID, e), t;
- }
- }, {
- key: "createFileMessage",
- value: function (e) {
- if (!V) {
- if (G && me(e.payload.file)) {
- var t = e.payload.file;
- e.payload.file = {
- files: [t]
- };
- }
- e.currentUser = this.tim.context.identifier;
- var n = new Qn(e),
- o = new Yn({
- uuid: this._generateUUID(),
- file: e.payload.file
- });
- return n.setElement(o), this.messageOptionMap.set(n.messageID, e), n;
- }
- de.warn("小程序目前不支持选择文件, createFileMessage 接口不可用!");
- }
- }, {
- key: "createAudioMessage",
- value: function (e) {
- if (V) {
- var t = e.payload.file;
- if (V) {
- var n = {
- url: t.tempFilePath,
- name: t.tempFilePath.slice(t.tempFilePath.lastIndexOf("/") + 1),
- size: t.fileSize,
- second: parseInt(t.duration) / 1e3,
- type: t.tempFilePath.slice(t.tempFilePath.lastIndexOf(".") + 1).toLowerCase()
- };
- e.payload.file = n;
- }
- e.currentUser = this.tim.context.identifier;
- var o = new Qn(e),
- r = new At({
- second: Math.floor(t.duration / 1e3),
- size: t.fileSize,
- url: t.tempFilePath,
- uuid: this._generateUUID()
- });
- return o.setElement(r), this.messageOptionMap.set(o.messageID, e), o;
- }
- de.warn("createAudioMessage 目前只支持小程序环境下发语音消息");
- }
- }, {
- key: "createVideoMessage",
- value: function (e) {
- e.currentUser = this.tim.context.identifier, e.payload.file.thumbUrl = "https://webim-1252463788.cos.ap-shanghai.myqcloud.com/assets/images/transparent.png", e.payload.file.thumbSize = 1668;
- var t = {};
- if (V) {
- if (me(e.payload.file)) return void de.warn("小程序环境下调用 createVideoMessage 接口时,payload.file 不支持传入 File 对象");
- var n = e.payload.file;
- t.url = n.tempFilePath, t.name = n.tempFilePath.slice(n.tempFilePath.lastIndexOf("/") + 1), t.size = n.size, t.second = n.duration, t.type = n.tempFilePath.slice(n.tempFilePath.lastIndexOf(".") + 1).toLowerCase();
- } else if (G) {
- if (me(e.payload.file)) {
- var o = e.payload.file;
- e.payload.file.files = [o];
- }
- var r = e.payload.file;
- t.url = window.URL.createObjectURL(r.files[0]), t.name = r.files[0].name, t.size = r.files[0].size, t.second = r.files[0].duration || 0, t.type = r.files[0].type.split("/")[1];
- }
- e.payload.file.videoFile = t;
- var i = new Qn(e),
- s = new Wn({
- videoFormat: t.type,
- videoSecond: Number(t.second.toFixed(0)),
- videoSize: t.size,
- remoteVideoUrl: "",
- videoUrl: t.url,
- videoUUID: this._generateUUID(),
- thumbUUID: this._generateUUID(),
- thumbWidth: e.payload.file.width || 200,
- thumbHeight: e.payload.file.height || 200,
- thumbUrl: e.payload.file.thumbUrl,
- thumbSize: e.payload.file.thumbSize,
- thumbFormat: e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf(".") + 1).toLowerCase()
- });
- return i.setElement(s), this.messageOptionMap.set(i.messageID, e), i;
- }
- }, {
- key: "createFaceMessage",
- value: function (e) {
- e.currentUser = this.tim.context.identifier;
- var t = new Qn(e),
- n = new kt(e.payload);
- return t.setElement(n), t;
- }
- }, {
- key: "_generateUUID",
- value: function () {
- var e = this.tim.context;
- return "".concat(e.SDKAppID, "-").concat(e.identifier, "-").concat(function () {
- for (var e = "", t = 32; t > 0; --t) e += Pe[Math.floor(Math.random() * Ge)];
- return e;
- }());
- }
- }, {
- key: "_generateTjgID",
- value: function (e) {
- return this.tim.context.tinyID + "-" + e.random;
- }
- }, {
- key: "getMessageOptionByID",
- value: function (e) {
- return this.messageOptionMap.get(e);
- }
- }, {
- key: "isMessageSentByCurrentInstance",
- value: function (e) {
- return !(!this.messagesList.hasLocalMessage(e.conversationID, e.ID) && !this.singlyLinkedList.has(e.random));
- }
- }, {
- key: "pushToMessageList",
- value: function (e) {
- this.messagesList.pushIn(e);
- }
- }]), s;
- }(mr),
- Ms = function () {
- function e(t) {
- o(this, e), this.userID = "", this.avatar = "", this.nick = "", this.role = "", this.joinTime = "", this.lastSendMsgTime = "", this.nameCard = "", this.muteUntil = 0, this.memberCustomField = [], this._initMember(t);
- }
- return i(e, [{
- key: "_initMember",
- value: function (e) {
- this.updateMember(e);
- }
- }, {
- key: "updateMember",
- value: function (e) {
- var t = [null, void 0, "", 0, NaN];
- e.memberCustomField && xe(this.memberCustomField, e.memberCustomField), Oe(this, e, ["memberCustomField"], t);
- }
- }, {
- key: "updateRole",
- value: function (e) {
- ["Owner", "Admin", "Member"].indexOf(e) < 0 || (this.role = e);
- }
- }, {
- key: "updateMuteUntil",
- value: function (e) {
- Me(e) || (this.muteUntil = Math.floor((Date.now() + 1e3 * e) / 1e3));
- }
- }, {
- key: "updateNameCard",
- value: function (e) {
- Me(e) || (this.nameCard = e);
- }
- }, {
- key: "updateMemberCustomField",
- value: function (e) {
- e && xe(this.memberCustomField, e);
- }
- }]), e;
- }(),
- Cs = function () {
- function e(t) {
- o(this, e), this.tim = t.tim, this.groupController = t.groupController, this._initListeners();
- }
- return i(e, [{
- key: "_initListeners",
- value: function () {
- this.tim.innerEmitter.on(Oo, this._onReceivedGroupTips, this);
- }
- }, {
- key: "_onReceivedGroupTips",
- value: function (e) {
- var t = this,
- n = e.data,
- o = n.result;
- n.isGroupTip && o.forEach(function (e) {
- switch (e.payload.operationType) {
- case 1:
- t._onNewMemberComeIn(e);
- break;
- case 2:
- t._onMemberQuit(e);
- break;
- case 3:
- t._onMemberKickedOut(e);
- break;
- case 4:
- t._onMemberSetAdmin(e);
- break;
- case 5:
- t._onMemberCancelledAdmin(e);
- break;
- case 6:
- t._onGroupProfileModified(e);
- break;
- case 7:
- t._onMemberInfoModified(e);
- break;
- default:
- de.warn("GroupTipsHandler._onReceivedGroupTips Unhandled groupTips. operationType=", e.payload.operationType);
- }
- });
- }
- }, {
- key: "_onNewMemberComeIn",
- value: function (e) {
- var t = e.payload,
- n = t.memberNum,
- o = t.groupProfile.groupID,
- r = this.groupController.getLocalGroupProfile(o);
- r && fe(n) && (r.memberNum = n);
- }
- }, {
- key: "_onMemberQuit",
- value: function (e) {
- var t = e.payload,
- n = t.memberNum,
- o = t.groupProfile.groupID,
- r = this.groupController.getLocalGroupProfile(o);
- r && fe(n) && (r.memberNum = n), this.groupController.deleteLocalGroupMembers(o, e.payload.userIDList);
- }
- }, {
- key: "_onMemberKickedOut",
- value: function (e) {
- var t = e.payload,
- n = t.memberNum,
- o = t.groupProfile.groupID,
- r = this.groupController.getLocalGroupProfile(o);
- r && fe(n) && (r.memberNum = n), this.groupController.deleteLocalGroupMembers(o, e.payload.userIDList);
- }
- }, {
- key: "_onMemberSetAdmin",
- value: function (e) {
- var n = this,
- o = e.payload.groupProfile.groupID;
- e.payload.userIDList.forEach(function (e) {
- var r = n.groupController.getLocalGroupMemberInfo(o, e);
- r && r.updateRole(t.GRP_MBR_ROLE_ADMIN);
- });
- }
- }, {
- key: "_onMemberCancelledAdmin",
- value: function (e) {
- var n = this,
- o = e.payload.groupProfile.groupID;
- e.payload.userIDList.forEach(function (e) {
- var r = n.groupController.getLocalGroupMemberInfo(o, e);
- r && r.updateRole(t.GRP_MBR_ROLE_MEMBER);
- });
- }
- }, {
- key: "_onGroupProfileModified",
- value: function (e) {
- var t = this,
- n = e.payload.newGroupProfile,
- o = e.payload.groupProfile.groupID,
- r = this.groupController.getLocalGroupProfile(o);
- Object.keys(n).forEach(function (e) {
- switch (e) {
- case "ownerID":
- t._ownerChaged(r, n);
- break;
- default:
- r[e] = n[e];
- }
- }), this.groupController.emitGroupListUpdate(!0, !0);
- }
- }, {
- key: "_ownerChaged",
- value: function (e, n) {
- var o = e.groupID,
- r = this.groupController.getLocalGroupProfile(o),
- i = this.tim.context.identifier;
- if (i === n.ownerID) {
- r.updateGroup({
- selfInfo: {
- role: t.GRP_MBR_ROLE_OWNER
- }
- });
- var s = this.groupController.getLocalGroupMemberInfo(o, i),
- a = this.groupController.getLocalGroupProfile(o).ownerID,
- u = this.groupController.getLocalGroupMemberInfo(o, a);
- s && s.updateRole(t.GRP_MBR_ROLE_OWNER), u && u.updateRole(t.GRP_MBR_ROLE_MEMBER);
- }
- }
- }, {
- key: "_onMemberInfoModified",
- value: function (e) {
- var t = this,
- n = e.payload.groupProfile.groupID;
- e.payload.memberList.forEach(function (e) {
- var o = t.groupController.getLocalGroupMemberInfo(n, e.userID);
- o && e.muteTime && o.updateMuteUntil(e.muteTime);
- });
- }
- }]), e;
- }(),
- Es = function () {
- function n(e) {
- o(this, n), this.groupController = e.groupController, this.tim = e.tim, this.pendencyMap = new Map(), this._initLiceners();
- }
- return i(n, [{
- key: "_initLiceners",
- value: function () {
- this.tim.innerEmitter.on(Ro, this._onReceivedGroupSystemNotice, this), this.tim.innerEmitter.on(To, this._clearGroupSystemNotice, this);
- }
- }, {
- key: "_clearGroupSystemNotice",
- value: function () {
- var e = this;
- this.getPendencyList().then(function (n) {
- n.forEach(function (t) {
- e.pendencyMap.set("".concat(t.from, "_").concat(t.groupID, "_").concat(t.to), t);
- });
- var o = e.tim.messageController.getLocalMessageList(t.CONV_SYSTEM),
- r = [];
- o.forEach(function (t) {
- var n = t.payload,
- o = n.operatorID,
- i = n.operationType,
- s = n.groupProfile;
- if (i === ut) {
- var a = "".concat(o, "_").concat(s.groupID, "_").concat(s.to),
- u = e.pendencyMap.get(a);
- u && fe(u.handled) && 0 !== u.handled && r.push(t);
- }
- }), e.groupController.deleteGroupSystemNotice({
- messageList: r
- });
- });
- }
- }, {
- key: "getPendencyList",
- value: function (e) {
- var t = this;
- return this.groupController.request({
- name: "group",
- action: "getGroupPendency",
- param: {
- startTime: e && e.startTime ? e.startTime : 0,
- limit: e && e.limit ? e.limit : 10,
- handleAccount: this.tim.context.identifier
- }
- }).then(function (e) {
- var n = e.data,
- o = n.pendencyList;
- return 0 !== n.nextStartTime ? t.getPendencyList({
- startTime: n.nextStartTime
- }).then(function (e) {
- return [].concat(I(o), I(e));
- }) : o;
- });
- }
- }, {
- key: "_onReceivedGroupSystemNotice",
- value: function (t) {
- var n = this,
- o = t.data,
- r = o.result;
- "sync" !== o.type && r.forEach(function (t) {
- switch (t.payload.operationType) {
- case 1:
- n._onApplyGroupRequest(t);
- break;
- case 2:
- n._onApplyGroupRequestAgreed(t);
- break;
- case 3:
- n._onApplyGroupRequestRefused(t);
- break;
- case 4:
- n._onMemberKicked(t);
- break;
- case 5:
- n._onGroupDismissed(t);
- break;
- case 6:
- break;
- case 7:
- n._onInviteGroup(t);
- break;
- case 8:
- n._onQuitGroup(t);
- break;
- case 9:
- n._onSetManager(t);
- break;
- case 10:
- n._onDeleteManager(t);
- break;
- case 11:
- case 12:
- case 15:
- break;
- case 255:
- n.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED, {
- message: t,
- type: vt
- });
- }
- });
- }
- }, {
- key: "_onApplyGroupRequest",
- value: function (t) {
- this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED, {
- message: t,
- type: ut
- });
- }
- }, {
- key: "_onApplyGroupRequestAgreed",
- value: function (t) {
- var n = this,
- o = t.payload.groupProfile.groupID;
- this.groupController.hasLocalGroup(o) || this.groupController.getGroupProfile({
- groupID: o
- }).then(function (e) {
- var t = e.data.group;
- t && (n.groupController.updateGroupMap([t]), n.groupController.emitGroupListUpdate());
- }), this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED, {
- message: t,
- type: ct
- });
- }
- }, {
- key: "_onApplyGroupRequestRefused",
- value: function (t) {
- this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED, {
- message: t,
- type: lt
- });
- }
- }, {
- key: "_onMemberKicked",
- value: function (t) {
- var n = t.payload.groupProfile.groupID;
- this.groupController.hasLocalGroup(n) && this.groupController.deleteLocalGroupAndConversation(n), this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED, {
- message: t,
- type: pt
- });
- }
- }, {
- key: "_onGroupDismissed",
- value: function (t) {
- var n = t.payload.groupProfile.groupID,
- o = this.groupController.hasLocalGroup(n),
- r = this.groupController.AVChatRoomHandler;
- o && this.groupController.deleteLocalGroupAndConversation(n), r.checkJoinedAVChatRoomByID(n) && r.reset(n), this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED, {
- message: t,
- type: gt
- });
- }
- }, {
- key: "_onInviteGroup",
- value: function (t) {
- var n = this,
- o = t.payload.groupProfile.groupID;
- this.groupController.hasLocalGroup(o) || this.groupController.getGroupProfile({
- groupID: o
- }).then(function (e) {
- var t = e.data.group;
- t && (n.groupController.updateGroupMap([t]), n.groupController.emitGroupListUpdate());
- }), this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED, {
- message: t,
- type: ht
- });
- }
- }, {
- key: "_onQuitGroup",
- value: function (t) {
- var n = t.payload.groupProfile.groupID;
- this.groupController.hasLocalGroup(n) && this.groupController.deleteLocalGroupAndConversation(n), this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED, {
- message: t,
- type: dt
- });
- }
- }, {
- key: "_onSetManager",
- value: function (n) {
- var o = n.payload.groupProfile,
- r = o.to,
- i = o.groupID,
- s = this.groupController.getLocalGroupMemberInfo(i, r);
- s && s.updateRole(t.GRP_MBR_ROLE_ADMIN), this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED, {
- message: n,
- type: mt
- });
- }
- }, {
- key: "_onDeleteManager",
- value: function (n) {
- var o = n.payload.groupProfile,
- r = o.to,
- i = o.groupID,
- s = this.groupController.getLocalGroupMemberInfo(i, r);
- s && s.updateRole(t.GRP_MBR_ROLE_MEMBER), this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED, {
- message: n,
- type: ft
- });
- }
- }, {
- key: "reset",
- value: function () {
- this.pendencyMap.clear();
- }
- }]), n;
- }(),
- Ts = {
- 3: !0,
- 4: !0,
- 5: !0,
- 6: !0
- },
- Ds = function () {
- function n(e) {
- var t = e.tim,
- r = e.groupController;
- o(this, n), this.tim = t, this.groupController = r, this.sequencesLinkedList = new vs(100), this.receivedMessageCount = 0, this._pollingRequestInfoMap = new Map(), this._pollingInstanceMap = new Map(), this._joinedGroupMap = new Map(), this._reportMessageStackedCount = 0, this._onlineMemberCountMap = new Map(), this.DEFAULT_EXPIRE_TIME = 60;
- }
- return i(n, [{
- key: "hasJoinedAVChatRoom",
- value: function () {
- return this._joinedGroupMap.size > 0;
- }
- }, {
- key: "checkJoinedAVChatRoomByID",
- value: function (e) {
- return this._joinedGroupMap.has(e);
- }
- }, {
- key: "getJoinedAVChatRoom",
- value: function () {
- return this._joinedGroupMap.size > 0 ? I(this._joinedGroupMap.keys()) : null;
- }
- }, {
- key: "start",
- value: function (e) {
- var t = this._pollingRequestInfoMap.get(e),
- n = {
- key: t.key,
- startSeq: t.startSeq
- };
- if (this._pollingInstanceMap.has(e)) {
- var o = this._pollingInstanceMap.get(e);
- o.isRunning() || o.start();
- } else {
- var r = this.groupController.createTransportCapsule({
- name: "AVChatRoom",
- action: "startLongPoll",
- param: n
- }),
- i = this.tim.connectionController.createRunLoop({
- pack: r,
- before: this._updateRequestData.bind(this, e),
- success: this._handleSuccess.bind(this, e),
- fail: this._handleFailure.bind(this),
- isAVChatRoomLoop: !0
- });
- i.start(), this._pollingInstanceMap.set(e, i), de.log("AVChatRoomHandler.start message channel started. groupID=".concat(e));
- }
- }
- }, {
- key: "stop",
- value: function (e) {
- var t = this._pollingInstanceMap.get(e);
- t && t.isRunning() && (t.abort(), t.stop(), de.log("AVChatRoomHandler.stop message channel stopped. groupID=".concat(e)));
- }
- }, {
- key: "startRunLoop",
- value: function (e) {
- var t = this;
- return this._precheck().then(function () {
- var n = e.longPollingKey,
- o = e.group,
- r = o.groupID;
- return t._pollingRequestInfoMap.set(r, {
- key: n,
- startSeq: 0
- }), t._joinedGroupMap.set(r, o), t._addAVChatRoomID(r), t.groupController.updateGroupMap([o]), t.groupController.emitGroupListUpdate(!0, !1), t.start(r), t.groupController.isLoggedIn() ? Mr({
- status: et.SUCCESS,
- group: o
- }) : Mr({
- status: et.SUCCESS
- });
- });
- }
- }, {
- key: "joinWithoutAuth",
- value: function (e) {
- var t = this;
- return this.groupController.request({
- name: "group",
- action: "applyJoinAVChatRoom",
- param: e
- }).then(function (n) {
- var o = n.data.longPollingKey;
- if (Me(o)) return Cr(new Ut({
- code: qt.CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN,
- message: En
- }));
- de.log("AVChatRoomHandler.joinWithoutAuth ok. groupID:".concat(e.groupID)), t.groupController.emitInnerEvent(sr), t.groupController.emitInnerEvent(ir, e.groupID);
- var r = new cs({
- groupID: e.groupID
- });
- return t.startRunLoop({
- group: r,
- longPollingKey: o
- }), new vr({
- status: et.SUCCESS
- });
- }).catch(function (t) {
- return de.error("AVChatRoomHandler.joinWithoutAuth error:".concat(Re(t), ". groupID:").concat(e.groupID)), Cr(t);
- });
- }
- }, {
- key: "_precheck",
- value: function () {
- if (this.tim.context.unlimitedAVChatRoom) return Promise.resolve();
- if (!this.hasJoinedAVChatRoom()) return Promise.resolve();
- var e = y(this._joinedGroupMap.entries().next().value, 2),
- n = e[0],
- o = e[1];
- if (this.groupController.isLoggedIn()) {
- if (!(o.selfInfo.role === t.GRP_MBR_ROLE_OWNER || o.ownerID === this.tim.loginInfo.identifier)) return this.groupController.quitGroup(n);
- this.groupController.deleteLocalGroupAndConversation(n);
- } else this.groupController.deleteLocalGroupAndConversation(n);
- return this.reset(n), Promise.resolve();
- }
- }, {
- key: "_updateRequestData",
- value: function (e, t) {
- var n = this._pollingRequestInfoMap.get(e),
- o = n.key,
- r = n.startSeq;
- t.StartSeq = r, t.Key = o, this.tim.sumStatController.addTotalCount(Sr);
- }
- }, {
- key: "_handleSuccess",
- value: function (e, t) {
- this.tim.sumStatController.addSuccessCount(Sr), this.tim.sumStatController.addCost(Sr, t.data.timecost);
- var n = t.data,
- o = n.errorCode,
- r = n.errorInfo,
- i = n.key,
- s = n.nextSeq,
- a = n.rspMsgList;
- if (o !== nt.SUCCESS) {
- var u = this._pollingRequestInfoMap.get(e),
- c = new qr(Li),
- l = u ? "".concat(u.key, "-").concat(u.startSeq) : "requestInfo is undefined";
- c.setMessage("".concat(e, "-").concat(l, "-").concat(r || JSON.stringify(t.data))).setCode(o).setNetworkType(this.groupController.getNetworkType()).setEnd(!0);
- } else _e(i) && fe(s) && this._pollingRequestInfoMap.set(e, {
- key: i,
- startSeq: s
- }), Ie(a) && a.length > 0 && (a.forEach(function (e) {
- e.to = e.groupID;
- }), this._dispatchNotice(a));
- this.groupController.emitInnerEvent(zo);
- }
- }, {
- key: "_handleFailure",
- value: function (e) {
- if (e.error) if ("ECONNABORTED" === e.error.code || e.error.code === qt.NETWORK_TIMEOUT) {
- if (e.error.config) {
- var t = e.error.config.url,
- n = e.error.config.data;
- de.log("AVChatRoomHandler._handleFailure request timed out. url=".concat(t, " data=").concat(n));
- } else de.log("AVChatRoomHandler._handleFailure request timed out");
- } else de.log("AVChatRoomHandler._handleFailure request failed due to network error");
- this.groupController.emitInnerEvent(Yo);
- }
- }, {
- key: "_dispatchNotice",
- value: function (n) {
- if (Ie(n) && 0 !== n.length) {
- var o = Date.now(),
- r = null,
- i = [],
- s = [],
- a = n.length;
- a > 1 && n.sort(function (e, t) {
- return e.sequence - t.sequence;
- });
- for (var u = 0; u < a; u++) if (Ts[n[u].event]) {
- if (this.receivedMessageCount += 1, r = this.packMessage(n[u], n[u].event), this.tim.context.unlimitedAVChatRoom || !this.sequencesLinkedList.has(r.sequence)) {
- var c = r.conversationID;
- if (this.receivedMessageCount % 40 == 0 && this.tim.messageLossController.detectMessageLoss(c, this.sequencesLinkedList.data()), null !== this.sequencesLinkedList.tail()) {
- var l = this.sequencesLinkedList.tail().value,
- p = r.sequence - l;
- p > 1 && p <= 20 ? this.tim.messageLossController.onMessageMaybeLost(c, l + 1, p - 1) : p < -1 && p >= -20 && this.tim.messageLossController.onMessageMaybeLost(c, r.sequence + 1, Math.abs(p) - 1);
- }
- this.sequencesLinkedList.pushIn(r.sequence), this._isMessageSentByCurrentInstance(r) || (r.conversationType === t.CONV_SYSTEM && s.push(r), i.push(r));
- }
- } else de.warn("AVChatRoomHandler._dispatchMessage 未处理的 event 类型: ".concat(n[u].event));
- if (s.length > 0 && this.groupController.emitInnerEvent(Ro, {
- result: s,
- eventDataList: [],
- type: "poll"
- }), 0 !== i.length) {
- var g = this.packConversationOption(i);
- g.length > 0 && this.groupController.emitInnerEvent(Oo, {
- eventDataList: g,
- type: "poll"
- }), de.debug("AVChatRoomHandler._dispatchNotice nums=".concat(i.length));
- var h = this.tim.sumStatController;
- h.addTotalCount(Pr), h.addSuccessCount(Pr), h.addCost(Pr, Date.now() - o), this._checkMessageStacked(i), this.groupController.emitOuterEvent(e.MESSAGE_RECEIVED, i);
- }
- }
- }
- }, {
- key: "_checkMessageStacked",
- value: function (e) {
- var t = e.length;
- t >= 100 && (de.warn("AVChatRoomHandler.checkMessageStacked 直播群消息堆积数:".concat(e.length, '!可能会导致微信小程序渲染时遇到 "Dom limit exceeded" 的错误,建议接入侧此时只渲染最近的10条消息')), this._reportMessageStackedCount < 5 && (new qr(bi).setNetworkType(this.groupController.getNetworkType()).setText("nums=".concat(t, " groupID=").concat(I(this._joinedGroupMap.keys()))).setEnd(), this._reportMessageStackedCount += 1));
- }
- }, {
- key: "_isMessageSentByCurrentInstance",
- value: function (e) {
- return !!this.tim.messageController.isMessageSentByCurrentInstance(e);
- }
- }, {
- key: "packMessage",
- value: function (e, n) {
- e.currentUser = this.tim.context.identifier, e.conversationType = 5 === n ? t.CONV_SYSTEM : t.CONV_GROUP, e.isSystemMessage = !!e.isSystemMessage;
- var o = new Qn(e),
- r = this.packElements(e, n);
- return o.setElement(r), o;
- }
- }, {
- key: "packElements",
- value: function (e, n) {
- return 4 === n || 6 === n ? (this._updateMemberCountByGroupTips(e), {
- type: t.MSG_GRP_TIP,
- content: u(u({}, e.elements), {}, {
- groupProfile: e.groupProfile
- })
- }) : 5 === n ? {
- type: t.MSG_GRP_SYS_NOTICE,
- content: u(u({}, e.elements), {}, {
- groupProfile: e.groupProfile
- })
- } : this.tim.bigDataHallwayController.parseElements(e.elements, e.from);
- }
- }, {
- key: "packConversationOption",
- value: function (e) {
- for (var t = new Map(), n = 0; n < e.length; n++) {
- var o = e[n],
- r = o.conversationID;
- if (t.has(r)) {
- var i = t.get(r);
- i.lastMessage = o, "in" === o.flow && i.unreadCount++;
- } else t.set(r, {
- conversationID: o.conversationID,
- unreadCount: "out" === o.flow ? 0 : 1,
- type: o.conversationType,
- subType: o.conversationSubType,
- lastMessage: o
- });
- }
- return I(t.values());
- }
- }, {
- key: "_addAVChatRoomID",
- value: function (e) {
- var t = this.tim.loginInfo.avchatroomIDList || [];
- t.includes(e) || (this.tim.context.unlimitedAVChatRoom ? t.push(e) : t.splice(0, 1, e), this.tim.loginInfo.avchatroomIDList = t);
- }
- }, {
- key: "_deleteAVChatRoomID",
- value: function (e) {
- var t = this.tim.loginInfo.avchatroomIDList || [],
- n = t.indexOf(e);
- -1 !== n && (t.splice(n, 1), this.tim.loginInfo.avchatroomIDList = t);
- }
- }, {
- key: "joinAVChatRoomSilently",
- value: function () {
- var e = this,
- t = this.tim.loginInfo.avchatroomIDList || [];
- if (0 !== t.length) {
- var n = new qr(li);
- t.forEach(function (t) {
- e.groupController.joinGroup({
- groupID: t
- }).then(function (o) {
- de.warn("AVChatRoomHandler.joinAVChatRoomSilently silently join group ok:".concat(t)), n.setCode(o.code).setText("groupID=".concat(t)).setNetworkType(e.groupController.getNetworkType()).setEnd(!0);
- }).catch(function (o) {
- de.warn("AVChatRoomHandler.joinAVChatRoomSilently silently join group failed:".concat(Re(o))), n.setMessage("".concat(t, "-").concat(JSON.stringify(o))).setCode(o.code).setNetworkType(e.groupController.getNetworkType()).setEnd(!0);
- });
- });
- }
- }
- }, {
- key: "getGroupOnlineMemberCount",
- value: function (e) {
- var t = this._onlineMemberCountMap.get(e) || {},
- n = Date.now();
- return Xe(t) || n - t.lastSyncTime > 1e3 * t.expireTime && n - t.latestUpdateTime > 1e4 && n - t.lastReqTime > 3e3 ? (t.lastReqTime = n, this._onlineMemberCountMap.set(e, t), this._getGroupOnlineMemberCount(e).then(function (e) {
- return new vr({
- memberCount: e.memberCount
- });
- }).catch(function (e) {
- return Cr(e);
- })) : Mr({
- memberCount: t.memberCount
- });
- }
- }, {
- key: "_getGroupOnlineMemberCount",
- value: function (e) {
- var t = this;
- return this.groupController.request({
- name: "group",
- action: "getOnlineMemberNum",
- param: {
- groupID: e
- }
- }).then(function (n) {
- var o = t._onlineMemberCountMap.get(e) || {},
- r = n.data,
- i = r.onlineMemberNum,
- s = void 0 === i ? 0 : i,
- a = r.expireTime,
- u = void 0 === a ? t.DEFAULT_EXPIRE_TIME : a;
- de.log("AVChatRoomHandler._getGroupOnlineMemberCount ok. groupID=".concat(e, " memberCount=").concat(s, " expireTime=").concat(u));
- var c = Date.now();
- return Xe(o) && (o.lastReqTime = c), t._onlineMemberCountMap.set(e, Object.assign(o, {
- lastSyncTime: c,
- latestUpdateTime: c,
- memberCount: s,
- expireTime: u
- })), {
- memberCount: s
- };
- }).catch(function (n) {
- return de.warn("AVChatRoomHandler._getGroupOnlineMemberCount failed. error:".concat(Re(n))), new qr(Ri).setCode(n.code).setMessage("".concat(e, "-").concat(JSON.stringify(n))).setNetworkType(t.groupController.getNetworkType()).setEnd(), Promise.reject(n);
- });
- }
- }, {
- key: "_updateMemberCountByGroupTips",
- value: function (e) {
- var t = e.groupProfile.groupID,
- n = e.elements.onlineMemberInfo,
- o = void 0 === n ? void 0 : n;
- if (void 0 !== o) {
- var r = o.onlineMemberNum,
- i = void 0 === r ? 0 : r,
- s = o.expireTime,
- a = void 0 === s ? this.DEFAULT_EXPIRE_TIME : s,
- u = this._onlineMemberCountMap.get(t) || {},
- c = Date.now();
- Xe(u) ? Object.assign(u, {
- lastReqTime: 0,
- lastSyncTime: 0,
- latestUpdateTime: c,
- memberCount: i,
- expireTime: a
- }) : (u.latestUpdateTime = c, u.memberCount = i), de.debug("AVChatRoomHandler._updateMemberCountByGroupTips info:", u), this._onlineMemberCountMap.set(t, u);
- }
- }
- }, {
- key: "reset",
- value: function (e) {
- if (0 !== this._pollingInstanceMap.size) {
- if (e) de.log("AVChatRoomHandler.reset groupID=".concat(e)), this.stop(e), this._pollingInstanceMap.delete(e), this._joinedGroupMap.delete(e), this._pollingRequestInfoMap.delete(e), this._onlineMemberCountMap.delete(e);else {
- de.log("AVChatRoomHandler.reset all");
- var t,
- n = S(this._pollingInstanceMap.keys());
- try {
- for (n.s(); !(t = n.n()).done;) {
- var o = t.value;
- this.stop(o);
- }
- } catch (r) {
- n.e(r);
- } finally {
- n.f();
- }
- this._pollingInstanceMap.clear(), this._joinedGroupMap.clear(), this._pollingRequestInfoMap.clear(), this._onlineMemberCountMap.clear();
- }
- this.sequencesLinkedList.reset(), this.receivedMessageCount = 0, this._reportMessageStackedCount = 0, this._deleteAVChatRoomID(e);
- }
- }
- }]), n;
- }(),
- Ss = "GroupController",
- ks = function (n) {
- c(s, n);
- var r = v(s);
- function s(e) {
- var t;
- return o(this, s), (t = r.call(this, e)).groupMap = new Map(), t.groupMemberListMap = new Map(), t.groupNoticeHandler = new Es({
- tim: e,
- groupController: f(t)
- }), t.groupTipsHandler = new Cs({
- tim: e,
- groupController: f(t)
- }), t.AVChatRoomHandler = new Ds({
- tim: e,
- groupController: f(t)
- }), t._initListeners(), t;
- }
- return i(s, [{
- key: "createGroup",
- value: function (e) {
- var n = this,
- o = "".concat(Ss, ".createGroup");
- if (!["Public", "Private", "ChatRoom", "AVChatRoom"].includes(e.type)) {
- var r = new Ut({
- code: qt.ILLEGAL_GROUP_TYPE,
- message: fn
- });
- return Cr(r);
- }
- Be(e.type) && !Me(e.memberList) && e.memberList.length > 0 && (de.warn("".concat(o, "创建AVChatRoom时不能添加群成员,自动忽略该字段")), e.memberList = void 0), Ke(e.type) || Me(e.joinOption) || (de.warn("".concat(o, " 创建Work/Meeting/AVChatRoom群时不能设置字段:joinOption,自动忽略该字段")), e.joinOption = void 0);
- var i = new qr(ui);
- return de.log("".concat(o)), this.request({
- name: "group",
- action: "create",
- param: e
- }).then(function (r) {
- if (i.setNetworkType(n.getNetworkType()).setText("groupType=".concat(e.type, " groupID=").concat(r.data.groupID)).setEnd(), de.log("".concat(o, " ok. groupID:"), r.data.groupID), e.type === t.GRP_AVCHATROOM) return n.getGroupProfile({
- groupID: r.data.groupID
- });
- n.updateGroupMap([u(u({}, e), {}, {
- groupID: r.data.groupID
- })]);
- var s = n.tim.createCustomMessage({
- to: r.data.groupID,
- conversationType: t.CONV_GROUP,
- payload: {
- data: "group_create",
- extension: "".concat(n.tim.context.identifier, "创建群组")
- }
- });
- return n.tim.sendMessage(s), n.emitGroupListUpdate(), n.getGroupProfile({
- groupID: r.data.groupID
- });
- }).then(function (e) {
- var n = e.data.group;
- return n.selfInfo.messageRemindType = t.MSG_REMIND_ACPT_AND_NOTE, n.selfInfo.role = t.GRP_MBR_ROLE_OWNER, e;
- }).catch(function (t) {
- return i.setText("groupType=".concat(e.type)), n.probeNetwork().then(function (e) {
- var n = y(e, 2),
- o = n[0],
- r = n[1];
- i.setError(t, o, r).setEnd();
- }), de.error("".concat(o, " error:"), t), Cr(t);
- });
- }
- }, {
- key: "joinGroup",
- value: function (e) {
- var n = this,
- o = e.groupID,
- r = e.type,
- i = "".concat(Ss, ".joinGroup");
- if (r === t.GRP_WORK) {
- var s = new Ut({
- code: qt.CANNOT_JOIN_WORK,
- message: _n
- });
- return Cr(s);
- }
- if (this.hasLocalGroup(o)) {
- if (!this.isLoggedIn()) return Mr({
- status: t.JOIN_STATUS_ALREADY_IN_GROUP
- });
- var a = new qr(ci);
- return this.getGroupProfile({
- groupID: o
- }).then(function (e) {
- return a.setNetworkType(n.getNetworkType()).setText("groupID=".concat(o, " joinedStatus=").concat(t.JOIN_STATUS_ALREADY_IN_GROUP)).setEnd(), Mr({
- status: t.JOIN_STATUS_ALREADY_IN_GROUP
- });
- }).catch(function (t) {
- return a.setNetworkType(n.getNetworkType()).setText("groupID=".concat(o, " unjoined")).setEnd(), de.warn("".concat(i, " ").concat(o, " was unjoined, now join!")), n.groupMap.delete(o), n.applyJoinGroup(e);
- });
- }
- return de.log("".concat(i, " groupID:"), o), this.isLoggedIn() ? this.applyJoinGroup(e) : this.AVChatRoomHandler.joinWithoutAuth(e);
- }
- }, {
- key: "quitGroup",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".quitGroup");
- de.log("".concat(n, " groupID:"), e);
- var o = this.AVChatRoomHandler.checkJoinedAVChatRoomByID(e);
- if (o && !this.isLoggedIn()) return de.log("".concat(n, " anonymously ok. groupID:"), e), this.deleteLocalGroupAndConversation(e), this.AVChatRoomHandler.reset(e), Mr({
- groupID: e
- });
- var r = new qr(pi);
- return this.request({
- name: "group",
- action: "quitGroup",
- param: {
- groupID: e
- }
- }).then(function () {
- return r.setNetworkType(t.getNetworkType()).setText("groupID=".concat(e)).setEnd(), de.log("".concat(n, " ok. groupID:"), e), o && t.AVChatRoomHandler.reset(e), t.deleteLocalGroupAndConversation(e), new vr({
- groupID: e
- });
- }).catch(function (o) {
- return r.setText("groupID=".concat(e)), t.probeNetwork().then(function (e) {
- var t = y(e, 2),
- n = t[0],
- i = t[1];
- r.setError(o, n, i).setEnd();
- }), de.error("".concat(n, " error. error:").concat(Re(o), " groupID:").concat(e)), Cr(o);
- });
- }
- }, {
- key: "changeGroupOwner",
- value: function (e) {
- var n = this,
- o = "".concat(Ss, ".changeGroupOwner");
- if (this.hasLocalGroup(e.groupID) && this.getLocalGroupProfile(e.groupID).type === t.GRP_AVCHATROOM) return Cr(new Ut({
- code: qt.CANNOT_CHANGE_OWNER_IN_AVCHATROOM,
- message: vn
- }));
- if (e.newOwnerID === this.tim.loginInfo.identifier) return Cr(new Ut({
- code: qt.CANNOT_CHANGE_OWNER_TO_SELF,
- message: yn
- }));
- var r = new qr(hi);
- return de.log("".concat(o, " groupID:"), e.groupID), this.request({
- name: "group",
- action: "changeGroupOwner",
- param: e
- }).then(function () {
- r.setNetworkType(n.getNetworkType()).setText("groupID=".concat(e.groupID)).setEnd(), de.log("".concat(o, " ok. groupID:"), e.groupID);
- var t = e.groupID,
- i = e.newOwnerID;
- n.groupMap.get(t).ownerID = i;
- var s = n.groupMemberListMap.get(t);
- if (s instanceof Map) {
- var a = s.get(n.tim.loginInfo.identifier);
- Me(a) || (a.updateRole("Member"), n.groupMap.get(t).selfInfo.role = "Member");
- var u = s.get(i);
- Me(u) || u.updateRole("Owner");
- }
- return n.emitGroupListUpdate(!0, !1), new vr({
- group: n.groupMap.get(t)
- });
- }).catch(function (t) {
- return r.setText("groupID=".concat(e.groupID)), n.probeNetwork().then(function (e) {
- var n = y(e, 2),
- o = n[0],
- i = n[1];
- r.setError(t, o, i).setEnd();
- }), de.error("".concat(o, " error:").concat(Re(t), " groupID:").concat(e.groupID)), Cr(t);
- });
- }
- }, {
- key: "dismissGroup",
- value: function (e) {
- var n = this,
- o = "".concat(Ss, ".dismissGroup");
- if (this.hasLocalGroup(e) && this.getLocalGroupProfile(e).type === t.GRP_WORK) return Cr(new Ut({
- code: qt.CANNOT_DISMISS_WORK,
- message: In
- }));
- var r = new qr(fi);
- return de.log("".concat(o, " groupID:").concat(e)), this.request({
- name: "group",
- action: "destroyGroup",
- param: {
- groupID: e
- }
- }).then(function () {
- return r.setNetworkType(n.getNetworkType()).setText("groupID=".concat(e)).setEnd(), de.log("".concat(o, " ok. groupID:").concat(e)), n.deleteLocalGroupAndConversation(e), n.checkJoinedAVChatRoomByID(e) && n.AVChatRoomHandler.reset(e), new vr({
- groupID: e
- });
- }).catch(function (t) {
- return r.setText("groupID=".concat(e)), n.probeNetwork().then(function (e) {
- var n = y(e, 2),
- o = n[0],
- i = n[1];
- r.setError(t, o, i).setEnd();
- }), de.error("".concat(o, " error:").concat(Re(t), " groupID:").concat(e)), Cr(t);
- });
- }
- }, {
- key: "updateGroupProfile",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".updateGroupProfile");
- !this.hasLocalGroup(e.groupID) || Ke(this.getLocalGroupProfile(e.groupID).type) || Me(e.joinOption) || (de.warn("".concat(n, " Work/Meeting/AVChatRoom群不能设置字段:joinOption,自动忽略该字段")), e.joinOption = void 0), Me(e.muteAllMembers) || (e.muteAllMembers ? e.muteAllMembers = "On" : e.muteAllMembers = "Off");
- var o = new qr(_i);
- return o.setText(JSON.stringify(e)), de.log("".concat(n, " groupID:"), e.groupID), this.request({
- name: "group",
- action: "updateGroupProfile",
- param: e
- }).then(function () {
- (o.setNetworkType(t.getNetworkType()).setEnd(), de.log("".concat(n, " ok. groupID:"), e.groupID), t.hasLocalGroup(e.groupID)) && (t.groupMap.get(e.groupID).updateGroup(e), t._setStorageGroupList());
- return new vr({
- group: t.groupMap.get(e.groupID)
- });
- }).catch(function (r) {
- return t.probeNetwork().then(function (e) {
- var t = y(e, 2),
- n = t[0],
- i = t[1];
- o.setError(r, n, i).setEnd();
- }), de.log("".concat(n, " failed. error:").concat(Re(r), " groupID:").concat(e.groupID)), Cr(r);
- });
- }
- }, {
- key: "setGroupMemberRole",
- value: function (e) {
- var n = this,
- o = "".concat(Ss, ".setGroupMemberRole"),
- r = e.groupID,
- i = e.userID,
- s = e.role,
- a = this.groupMap.get(r);
- if (a.selfInfo.role !== t.GRP_MBR_ROLE_OWNER) return Cr(new Ut({
- code: qt.NOT_OWNER,
- message: Dn
- }));
- if ([t.GRP_WORK, t.GRP_AVCHATROOM].includes(a.type)) return Cr(new Ut({
- code: qt.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM,
- message: Sn
- }));
- if ([t.GRP_MBR_ROLE_ADMIN, t.GRP_MBR_ROLE_MEMBER].indexOf(s) < 0) return Cr(new Ut({
- code: qt.INVALID_MEMBER_ROLE,
- message: kn
- }));
- if (i === this.tim.loginInfo.identifier) return Cr(new Ut({
- code: qt.CANNOT_SET_SELF_MEMBER_ROLE,
- message: An
- }));
- var u = new qr(Ai);
- return u.setText("groupID=".concat(r, " userID=").concat(i, " role=").concat(s)), de.log("".concat(o, " groupID:").concat(r, ". userID: ").concat(i)), this._modifyGroupMemberInfo({
- groupID: r,
- userID: i,
- role: s
- }).then(function (e) {
- return u.setNetworkType(n.getNetworkType()).setEnd(), de.log("".concat(o, " ok. groupID:").concat(r, ". userID: ").concat(i)), new vr({
- group: a,
- member: e
- });
- }).catch(function (e) {
- return n.probeNetwork().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- r = n[1];
- u.setError(e, o, r).setEnd();
- }), de.error("".concat(o, " error:").concat(Re(e), " groupID:").concat(r, " userID:").concat(i)), Cr(e);
- });
- }
- }, {
- key: "setGroupMemberMuteTime",
- value: function (e) {
- var t = this,
- n = e.groupID,
- o = e.userID,
- r = e.muteTime,
- i = "".concat(Ss, ".setGroupMemberMuteTime");
- if (o === this.tim.loginInfo.identifier) return Cr(new Ut({
- code: qt.CANNOT_MUTE_SELF,
- message: On
- }));
- de.log("".concat(i, " groupID:").concat(n, ". userID: ").concat(o));
- var s = new qr(Si);
- return s.setText("groupID=".concat(n, " userID=").concat(o, " muteTime=").concat(r)), this._modifyGroupMemberInfo({
- groupID: n,
- userID: o,
- muteTime: r
- }).then(function (e) {
- return s.setNetworkType(t.getNetworkType()).setEnd(), de.log("".concat(i, " ok. groupID:").concat(n, ". userID: ").concat(o)), new vr({
- group: t.getLocalGroupProfile(n),
- member: e
- });
- }).catch(function (e) {
- return t.probeNetwork().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- r = n[1];
- s.setError(e, o, r).setEnd();
- }), de.error("".concat(i, " error:").concat(Re(e), " groupID:").concat(n, " userID:").concat(o)), Cr(e);
- });
- }
- }, {
- key: "setMessageRemindType",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".setMessageRemindType"),
- o = new qr(mi);
- o.setText("groupID=".concat(e.groupID, " userID=").concat(e.userID || this.tim.loginInfo.identifier)), de.log("".concat(n, " groupID:").concat(e.groupID, ". userID: ").concat(e.userID || this.tim.loginInfo.identifier));
- var r = e.groupID,
- i = e.messageRemindType;
- return this._modifyGroupMemberInfo({
- groupID: r,
- messageRemindType: i,
- userID: this.tim.loginInfo.identifier
- }).then(function () {
- o.setNetworkType(t.getNetworkType()).setEnd(), de.log("".concat(n, " ok. groupID:").concat(e.groupID, " userID:").concat(e.userID || t.tim.loginInfo.identifier));
- var r = t.getLocalGroupProfile(e.groupID);
- return r && (r.selfInfo.messageRemindType = i), new vr({
- group: r
- });
- }).catch(function (r) {
- return t.probeNetwork().then(function (e) {
- var t = y(e, 2),
- n = t[0],
- i = t[1];
- o.setError(r, n, i).setEnd();
- }), de.error("".concat(n, " error:").concat(Re(r), " groupID:").concat(e.groupID, " userID:").concat(e.userID || t.tim.loginInfo.identifier)), Cr(r);
- });
- }
- }, {
- key: "setGroupMemberNameCard",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".setGroupMemberNameCard"),
- o = e.groupID,
- r = e.userID,
- i = void 0 === r ? this.tim.loginInfo.identifier : r,
- s = e.nameCard;
- de.log("".concat(n, " groupID:").concat(o, ". userID: ").concat(i));
- var a = new qr(ki);
- return a.setText("groupID=".concat(o, " userID=").concat(i, " nameCard=").concat(s)), this._modifyGroupMemberInfo({
- groupID: o,
- userID: i,
- nameCard: s
- }).then(function (e) {
- de.log("".concat(n, " ok. groupID:").concat(o, ". userID: ").concat(i)), a.setNetworkType(t.getNetworkType()).setEnd();
- var r = t.getLocalGroupProfile(o);
- return i === t.tim.loginInfo.identifier && r && r.setSelfNameCard(s), new vr({
- group: r,
- member: e
- });
- }).catch(function (e) {
- return t.probeNetwork().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- r = n[1];
- a.setError(e, o, r).setEnd();
- }), de.error("".concat(n, " error:").concat(Re(e), " groupID:").concat(o, " userID:").concat(i)), Cr(e);
- });
- }
- }, {
- key: "setGroupMemberCustomField",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".setGroupMemberCustomField"),
- o = e.groupID,
- r = e.userID,
- i = void 0 === r ? this.tim.loginInfo.identifier : r,
- s = e.memberCustomField;
- de.log("".concat(n, " groupID:").concat(o, ". userID: ").concat(i));
- var a = new qr(Oi);
- return a.setText("groupID=".concat(o, " userID=").concat(i, " memberCustomField=").concat(s)), this._modifyGroupMemberInfo({
- groupID: o,
- userID: i,
- memberCustomField: s
- }).then(function (e) {
- return a.setNetworkType(t.getNetworkType()).setEnd(), de.log("".concat(n, " ok. groupID:").concat(o, ". userID: ").concat(i)), new vr({
- group: t.groupMap.get(o),
- member: e
- });
- }).catch(function (e) {
- return t.probeNetwork().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- r = n[1];
- a.setError(e, o, r).setEnd();
- }), de.error("".concat(n, " error:").concat(Re(e), " groupID:").concat(o, " userID:").concat(i)), Cr(e);
- });
- }
- }, {
- key: "getGroupList",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".getGroupList"),
- o = new qr(vi);
- de.log("".concat(n));
- var r = {
- introduction: "Introduction",
- notification: "Notification",
- createTime: "CreateTime",
- ownerID: "Owner_Account",
- lastInfoTime: "LastInfoTime",
- memberNum: "MemberNum",
- maxMemberNum: "MaxMemberNum",
- joinOption: "ApplyJoinOption",
- muteAllMembers: "ShutUpAllMember"
- },
- i = ["Type", "Name", "FaceUrl", "NextMsgSeq", "LastMsgTime"];
- return e && e.groupProfileFilter && e.groupProfileFilter.forEach(function (e) {
- r[e] && i.push(r[e]);
- }), this.request({
- name: "group",
- action: "list",
- param: {
- responseFilter: {
- groupBaseInfoFilter: i,
- selfInfoFilter: ["Role", "JoinTime", "MsgFlag"]
- }
- }
- }).then(function (e) {
- var r = e.data.groups;
- return de.log("".concat(n, " ok. nums=").concat(r.length)), t._groupListTreeShaking(r), t.updateGroupMap(r), o.setNetworkType(t.getNetworkType()).setText("".concat(r.length, "-afterTreeshaking-").concat(t.groupMap.size)).setEnd(), t.tempConversationList && (de.log("".concat(n, " update last message with tempConversationList, nums=").concat(t.tempConversationList.length)), t._handleUpdateGroupLastMessage({
- data: t.tempConversationList
- }), t.tempConversationList = null), t.emitGroupListUpdate(), new vr({
- groupList: t.getLocalGroups()
- });
- }).catch(function (e) {
- return t.probeNetwork().then(function (t) {
- var n = y(t, 2),
- r = n[0],
- i = n[1];
- o.setError(e, r, i).setEnd();
- }), de.error("".concat(n, " error:"), e), Cr(e);
- });
- }
- }, {
- key: "getGroupMemberList",
- value: function (e) {
- var t = this,
- n = e.groupID,
- o = e.offset,
- r = void 0 === o ? 0 : o,
- i = e.count,
- s = void 0 === i ? 15 : i,
- a = "".concat(Ss, ".getGroupMemberList"),
- u = new qr(Ci);
- de.log("".concat(a, " groupID: ").concat(n, " offset: ").concat(r, " count: ").concat(s));
- var c = [];
- return this.request({
- name: "group",
- action: "getGroupMemberList",
- param: {
- groupID: n,
- offset: r,
- limit: s > 100 ? 100 : s,
- memberInfoFilter: ["Role", "NameCard", "ShutUpUntil"]
- }
- }).then(function (e) {
- var o = e.data,
- r = o.members,
- i = o.memberNum;
- return Ie(r) && 0 !== r.length ? (t.hasLocalGroup(n) && (t.getLocalGroupProfile(n).memberNum = i), c = t._updateLocalGroupMemberMap(n, r), t.tim.getUserProfile({
- userIDList: r.map(function (e) {
- return e.userID;
- }),
- tagList: [Ct.NICK, Ct.AVATAR]
- })) : Promise.resolve([]);
- }).then(function (e) {
- var o = e.data;
- if (!Ie(o) || 0 === o.length) return Mr({
- memberList: []
- });
- var i = o.map(function (e) {
- return {
- userID: e.userID,
- nick: e.nick,
- avatar: e.avatar
- };
- });
- return t._updateLocalGroupMemberMap(n, i), u.setNetworkType(t.getNetworkType()).setText("groupID=".concat(n, " offset=").concat(r, " count=").concat(s)).setEnd(), de.log("".concat(a, " ok.")), new vr({
- memberList: c
- });
- }).catch(function (e) {
- return t.probeNetwork().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- r = n[1];
- u.setError(e, o, r).setEnd();
- }), de.error("".concat(a, " error:"), e), Cr(e);
- });
- }
- }, {
- key: "getLocalGroups",
- value: function () {
- return I(this.groupMap.values());
- }
- }, {
- key: "getLocalGroupProfile",
- value: function (e) {
- return this.groupMap.get(e);
- }
- }, {
- key: "hasLocalGroup",
- value: function (e) {
- return this.groupMap.has(e);
- }
- }, {
- key: "getLocalGroupMemberInfo",
- value: function (e, t) {
- return this.groupMemberListMap.has(e) ? this.groupMemberListMap.get(e).get(t) : null;
- }
- }, {
- key: "setLocalGroupMember",
- value: function (e, t) {
- if (this.groupMemberListMap.has(e)) this.groupMemberListMap.get(e).set(t.userID, t);else {
- var n = new Map().set(t.userID, t);
- this.groupMemberListMap.set(e, n);
- }
- }
- }, {
- key: "hasLocalGroupMember",
- value: function (e, t) {
- return this.groupMemberListMap.has(e) && this.groupMemberListMap.get(e).has(t);
- }
- }, {
- key: "hasLocalGroupMemberMap",
- value: function (e) {
- return this.groupMemberListMap.has(e);
- }
- }, {
- key: "getGroupProfile",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".getGroupProfile"),
- o = new qr(yi);
- de.log("".concat(n, " groupID:"), e.groupID);
- var r = e.groupID,
- i = e.groupCustomFieldFilter,
- s = {
- groupIDList: [r],
- responseFilter: {
- groupBaseInfoFilter: ["Type", "Name", "Introduction", "Notification", "FaceUrl", "Owner_Account", "CreateTime", "InfoSeq", "LastInfoTime", "LastMsgTime", "MemberNum", "MaxMemberNum", "ApplyJoinOption", "NextMsgSeq", "ShutUpAllMember"],
- groupCustomFieldFilter: i
- }
- };
- return this.getGroupProfileAdvance(s).then(function (i) {
- var s,
- a = i.data,
- u = a.successGroupList,
- c = a.failureGroupList;
- return de.log("".concat(n, " ok. groupID:").concat(e.groupID)), c.length > 0 ? Cr(c[0]) : (Be(u[0].type) && !t.hasLocalGroup(r) ? s = new cs(u[0]) : (t.updateGroupMap(u), s = t.getLocalGroupProfile(r)), o.setNetworkType(t.getNetworkType()).setText("groupID=".concat(s.groupID, " type=").concat(s.type, " muteAllMembers=").concat(s.muteAllMembers, " ownerID=").concat(s.ownerID)).setEnd(), s && s.selfInfo && !s.selfInfo.nameCard ? t.updateSelfInfo(s).then(function (e) {
- return new vr({
- group: e
- });
- }) : new vr({
- group: s
- }));
- }).catch(function (r) {
- return t.probeNetwork().then(function (t) {
- var n = y(t, 2),
- i = n[0],
- s = n[1];
- o.setError(r, i, s).setText("groupID=".concat(e.groupID)).setEnd();
- }), de.error("".concat(n, " error:").concat(Re(r), " groupID:").concat(e.groupID)), Cr(r);
- });
- }
- }, {
- key: "getGroupMemberProfile",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".getGroupMemberProfile"),
- o = new qr(Ei);
- o.setText(e.userIDList.length > 5 ? "userIDList.length=".concat(e.userIDList.length) : "userIDList=".concat(e.userIDList)), de.log("".concat(n, " groupID:").concat(e.groupID, " userIDList:").concat(e.userIDList.join(","))), e.userIDList.length > 50 && (e.userIDList = e.userIDList.slice(0, 50));
- var r = e.groupID,
- i = e.userIDList;
- return this._getGroupMemberProfileAdvance(u(u({}, e), {}, {
- userIDList: i
- })).then(function (e) {
- var n = e.data.members;
- return Ie(n) && 0 !== n.length ? (t._updateLocalGroupMemberMap(r, n), t.tim.getUserProfile({
- userIDList: n.map(function (e) {
- return e.userID;
- }),
- tagList: [Ct.NICK, Ct.AVATAR]
- })) : Mr([]);
- }).then(function (e) {
- var n = e.data.map(function (e) {
- return {
- userID: e.userID,
- nick: e.nick,
- avatar: e.avatar
- };
- });
- t._updateLocalGroupMemberMap(r, n);
- var s = i.filter(function (e) {
- return t.hasLocalGroupMember(r, e);
- }).map(function (e) {
- return t.getLocalGroupMemberInfo(r, e);
- });
- return o.setNetworkType(t.getNetworkType()).setEnd(), new vr({
- memberList: s
- });
- });
- }
- }, {
- key: "_getGroupMemberProfileAdvance",
- value: function (e) {
- return this.request({
- name: "group",
- action: "getGroupMemberProfile",
- param: u(u({}, e), {}, {
- memberInfoFilter: e.memberInfoFilter ? e.memberInfoFilter : ["Role", "JoinTime", "NameCard", "ShutUpUntil"]
- })
- });
- }
- }, {
- key: "updateSelfInfo",
- value: function (e) {
- var t = "".concat(Ss, ".updateSelfInfo"),
- n = e.groupID;
- de.log("".concat(t, " groupID:"), n);
- var o = {
- groupID: n,
- userIDList: [this.tim.loginInfo.identifier]
- };
- return this.getGroupMemberProfile(o).then(function (o) {
- var r = o.data.memberList;
- return de.log("".concat(t, " ok. groupID:"), n), e && 0 !== r.length && e.updateSelfInfo(r[0]), e;
- });
- }
- }, {
- key: "addGroupMember",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".addGroupMember"),
- o = new qr(Ti);
- o.setText("groupID=".concat(e.groupID));
- var r = this.getLocalGroupProfile(e.groupID);
- if (Be(r.type)) {
- var i = new Ut({
- code: qt.CANNOT_ADD_MEMBER_IN_AVCHATROOM,
- message: Cn
- });
- return o.setCode(qt.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setMessage(Cn).setNetworkType(this.getNetworkType()).setText("groupID=".concat(e.groupID, " groupType=").concat(r.type)).setEnd(), Cr(i);
- }
- return e.userIDList = e.userIDList.map(function (e) {
- return {
- userID: e
- };
- }), de.log("".concat(n, " groupID:"), e.groupID), this.request({
- name: "group",
- action: "addGroupMember",
- param: e
- }).then(function (i) {
- var s = i.data.members;
- o.setNetworkType(t.getNetworkType()).setText("groupID=".concat(e.groupID)).setEnd(), de.log("".concat(n, " ok. groupID:"), e.groupID);
- var a = s.filter(function (e) {
- return 1 === e.result;
- }).map(function (e) {
- return e.userID;
- }),
- u = s.filter(function (e) {
- return 0 === e.result;
- }).map(function (e) {
- return e.userID;
- }),
- c = s.filter(function (e) {
- return 2 === e.result;
- }).map(function (e) {
- return e.userID;
- });
- return 0 === a.length ? new vr({
- successUserIDList: a,
- failureUserIDList: u,
- existedUserIDList: c
- }) : (r.memberNum += a.length, new vr({
- successUserIDList: a,
- failureUserIDList: u,
- existedUserIDList: c,
- group: r
- }));
- }).catch(function (r) {
- return t.probeNetwork().then(function (t) {
- var n = y(t, 2),
- i = n[0],
- s = n[1];
- o.setError(r, i, s).setText("groupID=".concat(e.groupID)).setEnd();
- }), de.error("".concat(n, " error:").concat(Re(r), " groupID:").concat(e.groupID)), Cr(r);
- });
- }
- }, {
- key: "deleteGroupMember",
- value: function (e) {
- var n = this,
- o = "".concat(Ss, ".deleteGroupMember"),
- r = new qr(Di);
- r.setText(e.userIDList.length > 5 ? "userIDList.length=".concat(e.userIDList.length) : "userIDList=".concat(e.userIDList)), de.log("".concat(o, " groupID:").concat(e.groupID, " userIDList:").concat(e.userIDList));
- var i = this.getLocalGroupProfile(e.groupID);
- return i.type === t.GRP_AVCHATROOM ? Cr(new Ut({
- code: qt.CANNOT_KICK_MEMBER_IN_AVCHATROOM,
- message: Tn
- })) : this.request({
- name: "group",
- action: "deleteGroupMember",
- param: e
- }).then(function () {
- return r.setNetworkType(n.getNetworkType()).setEnd(), de.log("".concat(o, " ok")), i.memberNum--, n.deleteLocalGroupMembers(e.groupID, e.userIDList), new vr({
- group: i,
- userIDList: e.userIDList
- });
- }).catch(function (t) {
- return n.probeNetwork().then(function (n) {
- var o = y(n, 2),
- i = o[0],
- s = o[1];
- r.setError(t, i, s).setText("groupID=".concat(e.groupID)).setEnd();
- }), de.error("".concat(o, " error:").concat(Re(t), " groupID:").concat(e.groupID)), Cr(t);
- });
- }
- }, {
- key: "searchGroupByID",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".searchGroupByID"),
- o = {
- groupIDList: [e]
- },
- r = new qr(gi);
- return r.setText("groupID=".concat(e)), de.log("".concat(n, " groupID:").concat(e)), this.request({
- name: "group",
- action: "searchGroupByID",
- param: o
- }).then(function (o) {
- var i = o.data.groupProfile;
- if (i[0].errorCode !== nt.SUCCESS) throw new Ut({
- code: i[0].errorCode,
- message: i[0].errorInfo
- });
- return r.setNetworkType(t.getNetworkType()).setEnd(), de.log("".concat(n, " ok. groupID:").concat(e)), new vr({
- group: new cs(i[0])
- });
- }).catch(function (o) {
- return t.probeNetwork().then(function (e) {
- var t = y(e, 2),
- n = t[0],
- i = t[1];
- r.setError(o, n, i).setEnd();
- }), de.warn("".concat(n, " error:").concat(Re(o), " groupID:").concat(e)), Cr(o);
- });
- }
- }, {
- key: "applyJoinGroup",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".applyJoinGroup"),
- o = new qr(ci);
- return this.request({
- name: "group",
- action: "applyJoinGroup",
- param: e
- }).then(function (r) {
- var i = r.data,
- s = i.joinedStatus,
- a = i.longPollingKey;
- switch (o.setNetworkType(t.getNetworkType()).setText("groupID=".concat(e.groupID, " joinedStatus=").concat(s)).setEnd(), de.log("".concat(n, " ok. groupID:").concat(e.groupID, " joinedStatus:").concat(s, " longPollingKey:").concat(a)), s) {
- case et.WAIT_APPROVAL:
- return new vr({
- status: et.WAIT_APPROVAL
- });
- case et.SUCCESS:
- return t.getGroupProfile({
- groupID: e.groupID
- }).then(function (n) {
- var o = n.data.group,
- r = {
- status: et.SUCCESS,
- group: o
- };
- return Me(a) ? (t.emitGroupListUpdate(!0, !1), new vr(r)) : (t.emitInnerEvent(ir, e.groupID), t.AVChatRoomHandler.startRunLoop({
- longPollingKey: a,
- group: o
- }));
- });
- default:
- var u = new Ut({
- code: qt.JOIN_GROUP_FAIL,
- message: Mn
- });
- return de.error("".concat(n, " error:").concat(Re(u), " groupID:").concat(e.groupID)), Cr(u);
- }
- }).catch(function (r) {
- return o.setText("groupID=".concat(e.groupID)), t.probeNetwork().then(function (e) {
- var t = y(e, 2),
- n = t[0],
- i = t[1];
- o.setError(r, n, i).setEnd();
- }), de.error("".concat(n, " error:").concat(Re(r), " groupID:").concat(e.groupID)), Cr(r);
- });
- }
- }, {
- key: "applyJoinAVChatRoom",
- value: function (e) {
- return this.AVChatRoomHandler.applyJoinAVChatRoom(e);
- }
- }, {
- key: "handleGroupApplication",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".handleGroupApplication"),
- o = e.message.payload,
- r = o.groupProfile.groupID,
- i = o.authentication,
- s = o.messageKey,
- a = o.operatorID,
- c = new qr(di);
- return c.setText("groupID=".concat(r)), de.log("".concat(n, " groupID:"), r), this.request({
- name: "group",
- action: "handleApplyJoinGroup",
- param: u(u({}, e), {}, {
- applicant: a,
- groupID: r,
- authentication: i,
- messageKey: s
- })
- }).then(function () {
- return c.setNetworkType(t.getNetworkType()).setEnd(), de.log("".concat(n, " ok. groupID:"), r), t.deleteGroupSystemNotice({
- messageList: [e.message]
- }), new vr({
- group: t.getLocalGroupProfile(r)
- });
- }).catch(function (e) {
- return t.probeNetwork().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- r = n[1];
- c.setError(e, o, r).setEnd();
- }), de.error("".concat(n, " error. error:").concat(Re(e), " groupID:").concat(r)), Cr(e);
- });
- }
- }, {
- key: "deleteGroupSystemNotice",
- value: function (e) {
- var n = this,
- o = "".concat(Ss, ".deleteGroupSystemNotice");
- return Ie(e.messageList) && 0 !== e.messageList.length ? (de.log("".concat(o) + e.messageList.map(function (e) {
- return e.ID;
- })), this.request({
- name: "group",
- action: "deleteGroupSystemNotice",
- param: {
- messageListToDelete: e.messageList.map(function (e) {
- return {
- from: t.CONV_SYSTEM,
- messageSeq: e.clientSequence,
- messageRandom: e.random
- };
- })
- }
- }).then(function () {
- return de.log("".concat(o, " ok")), e.messageList.forEach(function (e) {
- n.tim.messageController.deleteLocalMessage(e);
- }), new vr();
- }).catch(function (e) {
- return de.error("".concat(o, " error:"), e), Cr(e);
- })) : Mr();
- }
- }, {
- key: "getGroupProfileAdvance",
- value: function (e) {
- var t = "".concat(Ss, ".getGroupProfileAdvance");
- return Ie(e.groupIDList) && e.groupIDList.length > 50 && (de.warn("".concat(t, " 获取群资料的数量不能超过50个")), e.groupIDList.length = 50), de.log("".concat(t, " groupIDList:"), e.groupIDList), this.request({
- name: "group",
- action: "query",
- param: e
- }).then(function (e) {
- de.log("".concat(t, " ok."));
- var n = e.data.groups,
- o = n.filter(function (e) {
- return Me(e.errorCode) || e.errorCode === nt.SUCCESS;
- }),
- r = n.filter(function (e) {
- return e.errorCode && e.errorCode !== nt.SUCCESS;
- }).map(function (e) {
- return new Ut({
- code: e.errorCode,
- message: e.errorInfo,
- data: {
- groupID: e.groupID
- }
- });
- });
- return new vr({
- successGroupList: o,
- failureGroupList: r
- });
- }).catch(function (n) {
- return de.error("".concat(t, " error:").concat(Re(n), " groupIDList:").concat(e.groupIDList)), Cr(n);
- });
- }
- }, {
- key: "_deleteLocalGroup",
- value: function (e) {
- return this.groupMap.delete(e), this.groupMemberListMap.delete(e), this._setStorageGroupList(), this.groupMap.has(e) && this.groupMemberListMap.has(e);
- }
- }, {
- key: "_initGroupList",
- value: function () {
- var e = this,
- t = "".concat(Ss, "._initGroupList"),
- n = new qr(Ii);
- de.time(br), de.log("".concat(t));
- var o = this._getStorageGroupList();
- Ie(o) && o.length > 0 ? (o.forEach(function (t) {
- e.groupMap.set(t.groupID, new cs(t));
- }), this.emitGroupListUpdate(!0, !1), n.setNetworkType(this.getNetworkType()).setText(this.groupMap.size).setEnd()) : n.setNetworkType(this.getNetworkType()).setText(0).setEnd(), this.triggerReady(), de.log("".concat(t, " ok. initCost=").concat(de.timeEnd(br), "ms")), this.getGroupList();
- }
- }, {
- key: "_initListeners",
- value: function () {
- var e = this.tim.innerEmitter;
- e.once(Mo, this._initGroupList, this), e.on(tr, this._handleUpdateGroupLastMessage, this), e.on(Oo, this._handleReceivedGroupMessage, this), e.on(rr, this._handleProfileUpdated, this);
- }
- }, {
- key: "emitGroupListUpdate",
- value: function () {
- var t = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0],
- n = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1],
- o = this.getLocalGroups(),
- r = JSON.parse(JSON.stringify(o));
- n && this.emitInnerEvent(Wo, r), t && this.emitOuterEvent(e.GROUP_LIST_UPDATED, o);
- }
- }, {
- key: "_handleReceivedGroupMessage",
- value: function (e) {
- var n = this,
- o = e.data.eventDataList;
- Array.isArray(o) && o.forEach(function (e) {
- var o = e.conversationID.replace(t.CONV_GROUP, "");
- n.groupMap.has(o) && (n.groupMap.get(o).nextMessageSeq = e.lastMessage.sequence + 1);
- });
- }
- }, {
- key: "_onReceivedGroupSystemNotice",
- value: function (e) {
- var t = e.data;
- this.groupNoticeHandler._onReceivedGroupNotice(t);
- }
- }, {
- key: "_handleUpdateGroupLastMessage",
- value: function (e) {
- var n = "".concat(Ss, "._handleUpdateGroupLastMessage"),
- o = e.data;
- if (de.log("".concat(n, " convNums=").concat(o.length, " groupNums=").concat(this.groupMap.size)), 0 !== this.groupMap.size) {
- for (var r, i, s, a = !1, u = 0, c = o.length; u < c; u++) (r = o[u]).conversationID && r.type !== t.CONV_GROUP && (i = r.conversationID.split(/^GROUP/)[1], (s = this.getLocalGroupProfile(i)) && (s.lastMessage = r.lastMessage, a = !0));
- a && (this.groupMap = this._sortLocalGroupList(this.groupMap), this.emitGroupListUpdate(!0, !1));
- } else this.tempConversationList = o;
- }
- }, {
- key: "_sortLocalGroupList",
- value: function (e) {
- var t = I(e).filter(function (e) {
- var t = y(e, 2);
- t[0];
- return !Xe(t[1].lastMessage);
- });
- return t.sort(function (e, t) {
- return t[1].lastMessage.lastTime - e[1].lastMessage.lastTime;
- }), new Map([].concat(I(t), I(e)));
- }
- }, {
- key: "_getStorageGroupList",
- value: function () {
- return this.tim.storage.getItem("groupMap");
- }
- }, {
- key: "_setStorageGroupList",
- value: function () {
- var e = this.getLocalGroups().filter(function (e) {
- var t = e.type;
- return !Be(t);
- }).slice(0, 20).map(function (e) {
- return {
- groupID: e.groupID,
- name: e.name,
- avatar: e.avatar,
- type: e.type
- };
- });
- this.tim.storage.setItem("groupMap", e);
- }
- }, {
- key: "updateGroupMap",
- value: function (e) {
- var t = this;
- e.forEach(function (e) {
- t.groupMap.has(e.groupID) ? t.groupMap.get(e.groupID).updateGroup(e) : t.groupMap.set(e.groupID, new cs(e));
- }), this._setStorageGroupList();
- }
- }, {
- key: "_updateLocalGroupMemberMap",
- value: function (e, t) {
- var n = this;
- return Ie(t) && 0 !== t.length ? t.map(function (t) {
- return n.hasLocalGroupMember(e, t.userID) ? n.getLocalGroupMemberInfo(e, t.userID).updateMember(t) : n.setLocalGroupMember(e, new Ms(t)), n.getLocalGroupMemberInfo(e, t.userID);
- }) : [];
- }
- }, {
- key: "deleteLocalGroupMembers",
- value: function (e, t) {
- var n = this.groupMemberListMap.get(e);
- n && t.forEach(function (e) {
- n.delete(e);
- });
- }
- }, {
- key: "_modifyGroupMemberInfo",
- value: function (e) {
- var t = this,
- n = e.groupID,
- o = e.userID;
- return this.request({
- name: "group",
- action: "modifyGroupMemberInfo",
- param: e
- }).then(function () {
- if (t.hasLocalGroupMember(n, o)) {
- var r = t.getLocalGroupMemberInfo(n, o);
- return Me(e.muteTime) || r.updateMuteUntil(e.muteTime), Me(e.role) || r.updateRole(e.role), Me(e.nameCard) || r.updateNameCard(e.nameCard), Me(e.memberCustomField) || r.updateMemberCustomField(e.memberCustomField), r;
- }
- return t.getGroupMemberProfile({
- groupID: n,
- userIDList: [o]
- }).then(function (e) {
- return y(e.data.memberList, 1)[0];
- });
- });
- }
- }, {
- key: "_groupListTreeShaking",
- value: function (e) {
- for (var t = new Map(I(this.groupMap)), n = 0, o = e.length; n < o; n++) t.delete(e[n].groupID);
- this.AVChatRoomHandler.hasJoinedAVChatRoom() && this.AVChatRoomHandler.getJoinedAVChatRoom().forEach(function (e) {
- t.delete(e);
- });
- for (var r = I(t.keys()), i = 0, s = r.length; i < s; i++) this.groupMap.delete(r[i]);
- }
- }, {
- key: "_handleProfileUpdated",
- value: function (e) {
- for (var t = this, n = e.data, o = function (e) {
- var o = n[e];
- t.groupMemberListMap.forEach(function (e) {
- e.has(o.userID) && e.get(o.userID).updateMember({
- nick: o.nick,
- avatar: o.avatar
- });
- });
- }, r = 0; r < n.length; r++) o(r);
- }
- }, {
- key: "getJoinedAVChatRoom",
- value: function () {
- return this.AVChatRoomHandler.getJoinedAVChatRoom();
- }
- }, {
- key: "deleteLocalGroupAndConversation",
- value: function (e) {
- this._deleteLocalGroup(e), this.tim.conversationController.deleteLocalConversation("GROUP".concat(e)), this.emitGroupListUpdate(!0, !1);
- }
- }, {
- key: "checkJoinedAVChatRoomByID",
- value: function (e) {
- return this.AVChatRoomHandler.checkJoinedAVChatRoomByID(e);
- }
- }, {
- key: "getGroupLastSequence",
- value: function (e) {
- var t = this,
- n = "".concat(Ss, ".getGroupLastSequence"),
- o = new qr(Mi),
- r = 0;
- if (this.hasLocalGroup(e)) {
- var i = this.getLocalGroupProfile(e);
- if (i.lastMessage.lastSequence > 0) return r = i.lastMessage.lastSequence, de.log("".concat(n, " got lastSequence=").concat(r, " from local group profile[lastMessage.lastSequence]. groupID=").concat(e)), o.setNetworkType(this.getNetworkType()).setText("got lastSequence=".concat(r, " from local group profile[lastMessage.lastSequence]. groupID=").concat(e)).setEnd(), Promise.resolve(r);
- if (i.nextMessageSeq > 1) return r = i.nextMessageSeq - 1, de.log("".concat(n, " got lastSequence=").concat(r, " from local group profile[nextMessageSeq]. groupID=").concat(e)), o.setNetworkType(this.getNetworkType()).setText("got lastSequence=".concat(r, " from local group profile[nextMessageSeq]. groupID=").concat(e)).setEnd(), Promise.resolve(r);
- }
- var s = "GROUP".concat(e),
- a = this.tim.conversationController.getLocalConversation(s);
- if (a && a.lastMessage.lastSequence) return r = a.lastMessage.lastSequence, de.log("".concat(n, " got lastSequence=").concat(r, " from local conversation profile[lastMessage.lastSequence]. groupID=").concat(e)), o.setNetworkType(this.getNetworkType()).setText("got lastSequence=".concat(r, " from local conversation profile[lastMessage.lastSequence]. groupID=").concat(e)).setEnd(), Promise.resolve(r);
- var u = {
- groupIDList: [e],
- responseFilter: {
- groupBaseInfoFilter: ["NextMsgSeq"]
- }
- };
- return this.getGroupProfileAdvance(u).then(function (i) {
- var s = i.data.successGroupList;
- return Xe(s) ? de.log("".concat(n, " successGroupList is empty. groupID=").concat(e)) : (r = s[0].nextMessageSeq - 1, de.log("".concat(n, " got lastSequence=").concat(r, " from getGroupProfileAdvance. groupID=").concat(e))), o.setNetworkType(t.getNetworkType()).setText("got lastSequence=".concat(r, " from getGroupProfileAdvance. groupID=").concat(e)).setEnd(), r;
- }).catch(function (r) {
- return t.probeNetwork().then(function (t) {
- var n = y(t, 2),
- i = n[0],
- s = n[1];
- o.setError(r, i, s).setText("get lastSequence failed from getGroupProfileAdvance. groupID=".concat(e)).setEnd();
- }), de.warn("".concat(n, " failed. ").concat(r)), Cr(r);
- });
- }
- }, {
- key: "getGroupOnlineMemberCount",
- value: function (e) {
- return this.AVChatRoomHandler.checkJoinedAVChatRoomByID(e) ? this.AVChatRoomHandler.getGroupOnlineMemberCount(e) : Mr({
- memberCount: 0
- });
- }
- }, {
- key: "reset",
- value: function () {
- this.groupMap.clear(), this.groupMemberListMap.clear(), this.resetReady(), this.groupNoticeHandler.reset(), this.AVChatRoomHandler.reset(), this.tim.innerEmitter.once(Mo, this._initGroupList, this);
- }
- }]), s;
- }(mr),
- As = function (n) {
- c(s, n);
- var r = v(s);
- function s(e) {
- var n;
- o(this, s), (n = r.call(this, e)).REALTIME_MESSAGE_TIMEOUT = 3e5, n.LONGPOLLING_ID_TIMEOUT = 3e5, n._currentState = t.NET_STATE_CONNECTED, n._status = {
- OPENIM: {
- lastResponseReceivedTime: 0,
- jitterCount: 0,
- failedCount: 0
- },
- AVCHATROOM: {
- lastResponseReceivedTime: 0,
- jitterCount: 0,
- failedCount: 0
- }
- };
- var i = n.tim.innerEmitter;
- return i.on(Lo, n._onGetLongPollIDFailed, f(n)), i.on(Po, n._onOpenIMResponseOK, f(n)), i.on(wo, n._onOpenIMRequestFailed, f(n)), i.on(zo, n._onAVChatroomResponseOK, f(n)), i.on(Yo, n._onAVChatroomRequestFailed, f(n)), n;
- }
- return i(s, [{
- key: "_onGetLongPollIDFailed",
- value: function () {
- this._currentState !== t.NET_STATE_DISCONNECTED && this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED);
- }
- }, {
- key: "_onOpenIMResponseOK",
- value: function () {
- this._onResponseOK("OPENIM");
- }
- }, {
- key: "_onOpenIMRequestFailed",
- value: function () {
- this._onRequestFailed("OPENIM");
- }
- }, {
- key: "_onAVChatroomResponseOK",
- value: function () {
- this.isLoggedIn() || this._onResponseOK("AVCHATROOM");
- }
- }, {
- key: "_onAVChatroomRequestFailed",
- value: function () {
- this.isLoggedIn() || this._onRequestFailed("AVCHATROOM");
- }
- }, {
- key: "_onResponseOK",
- value: function (e) {
- var n = this._status[e],
- o = Date.now();
- if (0 !== n.lastResponseReceivedTime) {
- var r = o - n.lastResponseReceivedTime;
- de.debug("StatusController._onResponseOK key=".concat(e, " currentState=").concat(this._currentState, " interval=").concat(r, " failedCount=").concat(n.failedCount, " jitterCount=").concat(n.jitterCount)), n.failedCount > 0 && (n.failedCount = 0, n.jitterCount += 1, this._currentState !== t.NET_STATE_CONNECTED && this._emitNetStateChangeEvent(t.NET_STATE_CONNECTED));
- r <= this.LONGPOLLING_ID_TIMEOUT ? n.jitterCount >= 3 && (new qr(wi).setText("".concat(e, "-").concat(r, "-").concat(n.jitterCount)).setNetworkType(this.getNetworkType()).setEnd(), n.jitterCount = 0) : (new qr(Pi).setText("".concat(e, "-").concat(r)).setNetworkType(this.getNetworkType()).setEnd(), de.warn("StatusController._onResponseOK, sdk reload. key=".concat(e, " interval=").concat(r, "ms. https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/module-EVENT.html#.SDK_RELOAD")), this.emitInnerEvent(ur)), n.lastResponseReceivedTime = o;
- } else n.lastResponseReceivedTime = o;
- }
- }, {
- key: "_onRequestFailed",
- value: function (e) {
- var n = this,
- o = this._status[e];
- Date.now() - o.lastResponseReceivedTime >= this.LONGPOLLING_ID_TIMEOUT ? this._currentState !== t.NET_STATE_DISCONNECTED && (de.warn("StatusController._onRequestFailed, disconnected, longpolling unavailable more than 5min. key=".concat(e, " networkType=").concat(this.getNetworkType())), this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)) : (o.failedCount += 1, o.failedCount > 5 ? this.probeNetwork().then(function (r) {
- var i = y(r, 2),
- s = i[0],
- a = i[1];
- s ? (n._currentState !== t.NET_STATE_CONNECTING && n._emitNetStateChangeEvent(t.NET_STATE_CONNECTING), de.warn("StatusController._onRequestFailed, connecting, network jitter. key=".concat(e, " networkType=").concat(a))) : (n._currentState !== t.NET_STATE_DISCONNECTED && n._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED), de.warn("StatusController._onRequestFailed, disconnected, longpolling unavailable. key=".concat(e, " networkType=").concat(a))), o.failedCount = 0, o.jitterCount = 0;
- }) : this._currentState === t.NET_STATE_CONNECTED && this._emitNetStateChangeEvent(t.NET_STATE_CONNECTING));
- }
- }, {
- key: "_emitNetStateChangeEvent",
- value: function (t) {
- de.log("StatusController._emitNetStateChangeEvent net state changed from ".concat(this._currentState, " to ").concat(t)), this._currentState = t, this.emitOuterEvent(e.NET_STATE_CHANGE, {
- state: t
- });
- }
- }, {
- key: "reset",
- value: function () {
- de.log("StatusController.reset"), this._currentState = t.NET_STATE_CONNECTED, this._status = {
- OPENIM: {
- lastResponseReceivedTime: 0,
- jitterCount: 0,
- failedCount: 0
- },
- AVCHATROOM: {
- lastResponseReceivedTime: 0,
- jitterCount: 0,
- failedCount: 0
- }
- };
- }
- }]), s;
- }(mr);
- function Os() {
- return null;
- }
- var Rs = function () {
- function e(t) {
- o(this, e), this.tim = t, this.storageQueue = new Map(), this.checkTimes = 0, this.checkTimer = setInterval(this._onCheckTimer.bind(this), 1e3), this._errorTolerantHandle();
- }
- return i(e, [{
- key: "_errorTolerantHandle",
- value: function () {
- !V && Me(window.localStorage) && (this.getItem = Os, this.setItem = Os, this.removeItem = Os, this.clear = Os);
- }
- }, {
- key: "_onCheckTimer",
- value: function () {
- if (this.checkTimes++, this.checkTimes % 20 == 0) {
- if (0 === this.storageQueue.size) return;
- this._doFlush();
- }
- }
- }, {
- key: "_doFlush",
- value: function () {
- try {
- var e,
- t = S(this.storageQueue);
- try {
- for (t.s(); !(e = t.n()).done;) {
- var n = y(e.value, 2),
- o = n[0],
- r = n[1];
- this._setStorageSync(this._getKey(o), r);
- }
- } catch (i) {
- t.e(i);
- } finally {
- t.f();
- }
- this.storageQueue.clear();
- } catch (s) {
- de.warn("Storage._doFlush error", s);
- }
- }
- }, {
- key: "_getPrefix",
- value: function () {
- var e = this.tim.loginInfo,
- t = e.SDKAppID,
- n = e.identifier;
- return "TIM_".concat(t, "_").concat(n, "_");
- }
- }, {
- key: "getItem",
- value: function (e) {
- var t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];
- try {
- var n = t ? this._getKey(e) : e;
- return this._getStorageSync(n);
- } catch (o) {
- return de.warn("Storage.getItem error:", o), {};
- }
- }
- }, {
- key: "setItem",
- value: function (e, t) {
- var n = arguments.length > 2 && void 0 !== arguments[2] && arguments[2],
- o = !(arguments.length > 3 && void 0 !== arguments[3]) || arguments[3];
- if (n) {
- var r = o ? this._getKey(e) : e;
- this._setStorageSync(r, t);
- } else this.storageQueue.set(e, t);
- }
- }, {
- key: "clear",
- value: function () {
- try {
- V ? K.clearStorageSync() : localStorage.clear();
- } catch (e) {
- de.warn("Storage.clear error:", e);
- }
- }
- }, {
- key: "removeItem",
- value: function (e) {
- var t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];
- try {
- var n = t ? this._getKey(e) : e;
- this._removeStorageSync(n);
- } catch (o) {
- de.warn("Storage.removeItem error:", o);
- }
- }
- }, {
- key: "getSize",
- value: function (e) {
- var t = this,
- n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "b";
- try {
- var o = {
- size: 0,
- limitSize: 5242880,
- unit: n
- };
- if (Object.defineProperty(o, "leftSize", {
- enumerable: !0,
- get: function () {
- return o.limitSize - o.size;
- }
- }), V && (o.limitSize = 1024 * K.getStorageInfoSync().limitSize), e) o.size = JSON.stringify(this.getItem(e)).length + this._getKey(e).length;else if (V) {
- var r = K.getStorageInfoSync(),
- i = r.keys;
- i.forEach(function (e) {
- o.size += JSON.stringify(t._getStorageSync(e)).length + t._getKey(e).length;
- });
- } else for (var s in localStorage) localStorage.hasOwnProperty(s) && (o.size += localStorage.getItem(s).length + s.length);
- return this._convertUnit(o);
- } catch (a) {
- de.warn("Storage.getSize error:", a);
- }
- }
- }, {
- key: "_convertUnit",
- value: function (e) {
- var t = {},
- n = e.unit;
- for (var o in t.unit = n, e) "number" == typeof e[o] && ("kb" === n.toLowerCase() ? t[o] = Math.round(e[o] / 1024) : "mb" === n.toLowerCase() ? t[o] = Math.round(e[o] / 1024 / 1024) : t[o] = e[o]);
- return t;
- }
- }, {
- key: "_getKey",
- value: function (e) {
- return "".concat(this._getPrefix()).concat(e);
- }
- }, {
- key: "_setStorageSync",
- value: function (e, t) {
- V ? x ? my.setStorageSync({
- key: e,
- data: t
- }) : K.setStorageSync(e, t) : localStorage.setItem(e, JSON.stringify(t));
- }
- }, {
- key: "_getStorageSync",
- value: function (e) {
- return V ? x ? my.getStorageSync({
- key: e
- }).data : K.getStorageSync(e) : JSON.parse(localStorage.getItem(e));
- }
- }, {
- key: "_removeStorageSync",
- value: function (e) {
- V ? x ? my.removeStorageSync({
- key: e
- }) : K.removeStorageSync(e) : localStorage.removeItem(e);
- }
- }, {
- key: "reset",
- value: function () {
- this._doFlush(), this.checkTimes = 0;
- }
- }]), e;
- }(),
- Ns = O(function (e) {
- var t = Object.prototype.hasOwnProperty,
- n = "~";
- function o() {}
- function r(e, t, n) {
- this.fn = e, this.context = t, this.once = n || !1;
- }
- function i(e, t, o, i, s) {
- if ("function" != typeof o) throw new TypeError("The listener must be a function");
- var a = new r(o, i || e, s),
- u = n ? n + t : t;
- return e._events[u] ? e._events[u].fn ? e._events[u] = [e._events[u], a] : e._events[u].push(a) : (e._events[u] = a, e._eventsCount++), e;
- }
- function s(e, t) {
- 0 == --e._eventsCount ? e._events = new o() : delete e._events[t];
- }
- function a() {
- this._events = new o(), this._eventsCount = 0;
- }
- Object.create && (o.prototype = Object.create(null), new o().__proto__ || (n = !1)), a.prototype.eventNames = function () {
- var e,
- o,
- r = [];
- if (0 === this._eventsCount) return r;
- for (o in e = this._events) t.call(e, o) && r.push(n ? o.slice(1) : o);
- return Object.getOwnPropertySymbols ? r.concat(Object.getOwnPropertySymbols(e)) : r;
- }, a.prototype.listeners = function (e) {
- var t = n ? n + e : e,
- o = this._events[t];
- if (!o) return [];
- if (o.fn) return [o.fn];
- for (var r = 0, i = o.length, s = new Array(i); r < i; r++) s[r] = o[r].fn;
- return s;
- }, a.prototype.listenerCount = function (e) {
- var t = n ? n + e : e,
- o = this._events[t];
- return o ? o.fn ? 1 : o.length : 0;
- }, a.prototype.emit = function (e, t, o, r, i, s) {
- var a = n ? n + e : e;
- if (!this._events[a]) return !1;
- var u,
- c,
- l = this._events[a],
- p = arguments.length;
- if (l.fn) {
- switch (l.once && this.removeListener(e, l.fn, void 0, !0), p) {
- case 1:
- return l.fn.call(l.context), !0;
- case 2:
- return l.fn.call(l.context, t), !0;
- case 3:
- return l.fn.call(l.context, t, o), !0;
- case 4:
- return l.fn.call(l.context, t, o, r), !0;
- case 5:
- return l.fn.call(l.context, t, o, r, i), !0;
- case 6:
- return l.fn.call(l.context, t, o, r, i, s), !0;
- }
- for (c = 1, u = new Array(p - 1); c < p; c++) u[c - 1] = arguments[c];
- l.fn.apply(l.context, u);
- } else {
- var g,
- h = l.length;
- for (c = 0; c < h; c++) switch (l[c].once && this.removeListener(e, l[c].fn, void 0, !0), p) {
- case 1:
- l[c].fn.call(l[c].context);
- break;
- case 2:
- l[c].fn.call(l[c].context, t);
- break;
- case 3:
- l[c].fn.call(l[c].context, t, o);
- break;
- case 4:
- l[c].fn.call(l[c].context, t, o, r);
- break;
- default:
- if (!u) for (g = 1, u = new Array(p - 1); g < p; g++) u[g - 1] = arguments[g];
- l[c].fn.apply(l[c].context, u);
- }
- }
- return !0;
- }, a.prototype.on = function (e, t, n) {
- return i(this, e, t, n, !1);
- }, a.prototype.once = function (e, t, n) {
- return i(this, e, t, n, !0);
- }, a.prototype.removeListener = function (e, t, o, r) {
- var i = n ? n + e : e;
- if (!this._events[i]) return this;
- if (!t) return s(this, i), this;
- var a = this._events[i];
- if (a.fn) a.fn !== t || r && !a.once || o && a.context !== o || s(this, i);else {
- for (var u = 0, c = [], l = a.length; u < l; u++) (a[u].fn !== t || r && !a[u].once || o && a[u].context !== o) && c.push(a[u]);
- c.length ? this._events[i] = 1 === c.length ? c[0] : c : s(this, i);
- }
- return this;
- }, a.prototype.removeAllListeners = function (e) {
- var t;
- return e ? (t = n ? n + e : e, this._events[t] && s(this, t)) : (this._events = new o(), this._eventsCount = 0), this;
- }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = n, a.EventEmitter = a, e.exports = a;
- });
- function Ls(e) {
- var t = e.context || null;
- return {
- platform: co,
- websdkappid: uo,
- v: ao,
- a2: t && t.a2Key || void 0,
- tinyid: t && t.tinyID || void 0,
- sdkappid: t && t.SDKAppID || 0,
- contentType: t && t.contentType || 0,
- apn: t && t.apn || 1,
- accounttype: t && t.accountType || 0
- };
- }
- var ws = function () {
- function e(t) {
- o(this, e), this.tim = t, this.tim.innerEmitter.on(yo, this._update, this), this.tim.innerEmitter.on(Io, this._update, this), this.tim.innerEmitter.on(Co, this._updateSpecifiedConfig, this), this._initConfig();
- }
- return i(e, [{
- key: "_update",
- value: function (e) {
- this._initConfig();
- }
- }, {
- key: "_updateSpecifiedConfig",
- value: function (e) {
- var t = this;
- e.data.forEach(function (e) {
- t._set(e);
- });
- }
- }, {
- key: "get",
- value: function (e) {
- var t = e.name,
- o = e.action,
- r = e.param,
- i = e.tjgID;
- if (Me(this.config[t]) || Me(this.config[t][o])) throw new Ut({
- code: qt.NETWORK_PACKAGE_UNDEFINED,
- message: "".concat(qn, ": PackageConfig.").concat(t)
- });
- var s = function e(t) {
- if (0 === Object.getOwnPropertyNames(t).length) return Object.create(null);
- var o = Array.isArray(t) ? [] : Object.create(null),
- r = "";
- for (var i in t) null !== t[i] ? void 0 !== t[i] ? (r = n(t[i]), ["string", "number", "function", "boolean"].indexOf(r) >= 0 ? o[i] = t[i] : o[i] = e(t[i])) : o[i] = void 0 : o[i] = null;
- return o;
- }(this.config[t][o]);
- return s.requestData = this._initRequestData(r, s), s.encode = this._initEncoder(s), s.decode = this._initDecoder(s), i && (s.queryString.tjg_id = i), s;
- }
- }, {
- key: "_set",
- value: function (e) {
- var t = e.key,
- o = e.value;
- if (!1 != !!t) {
- var r = t.split(".");
- if (!(r.length <= 0)) {
- !function e(t, o, r, i) {
- var s = o[r];
- "object" === n(t[s]) ? e(t[s], o, r + 1, i) : t[s] = i;
- }(this.config, r, 0, o);
- }
- }
- }
- }, {
- key: "_initConfig",
- value: function () {
- var e;
- this.config = {}, this.config.accessLayer = (e = this.tim, {
- create: null,
- query: {
- serverName: _o.NAME.WEB_IM,
- cmd: _o.CMD.ACCESS_LAYER,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: u(u({}, Ls(e)), {}, {
- identifier: e.context.identifier,
- usersig: e.context.userSig
- }),
- requestData: {}
- },
- update: null,
- delete: null
- }), this.config.login = function (e) {
- return {
- create: null,
- query: {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.LOGIN,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: u(u({}, Ls(e)), {}, {
- identifier: e.loginInfo.identifier,
- usersig: e.loginInfo.userSig,
- sdkappid: e.loginInfo.SDKAppID,
- accounttype: e.loginInfo.accountType,
- reqtime: +new Date() / 1e3
- }),
- requestData: {
- state: "Online"
- },
- keyMaps: {
- request: {
- tinyID: "tinyId"
- },
- response: {
- TinyId: "tinyID"
- }
- }
- },
- update: null,
- delete: null
- };
- }(this.tim), this.config.logout = function (e) {
- return {
- create: null,
- query: {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.LOGOUT_ALL,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: u(u({}, Ls(e)), {}, {
- reqtime: +new Date() / 1e3
- }),
- requestData: {}
- },
- update: null,
- delete: null
- };
- }(this.tim), this.config.longPollLogout = function (e) {
- return {
- create: null,
- query: {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.LOGOUT_LONG_POLL,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: u(u({}, Ls(e)), {}, {
- reqtime: +new Date()
- }),
- requestData: {
- longPollID: ""
- },
- keyMaps: {
- request: {
- longPollID: "LongPollingId"
- }
- }
- },
- update: null,
- delete: null
- };
- }(this.tim), this.config.profile = function (e) {
- var t = Ls(e),
- n = {
- serverName: _o.NAME.PROFILE,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t
- };
- return {
- query: u(u({}, n), {}, {
- cmd: _o.CMD.PORTRAIT_GET,
- requestData: {
- fromAccount: "",
- userItem: []
- },
- keyMaps: {
- request: {
- toAccount: "To_Account",
- standardSequence: "StandardSequence",
- customSequence: "CustomSequence"
- }
- }
- }),
- update: u(u({}, n), {}, {
- cmd: _o.CMD.PORTRAIT_SET,
- requestData: {
- fromAccount: "",
- profileItem: [{
- tag: Ct.NICK,
- value: ""
- }, {
- tag: Ct.GENDER,
- value: ""
- }, {
- tag: Ct.ALLOWTYPE,
- value: ""
- }, {
- tag: Ct.AVATAR,
- value: ""
- }]
- }
- })
- };
- }(this.tim), this.config.group = function (e) {
- var n = _o.NAME.GROUP,
- o = Ls(e);
- if (e.context.login !== ot.IS_LOGIN || !e.context.a2Key) {
- n = _o.NAME.BIG_GROUP_NO_AUTH;
- var r = Ls(e);
- r.a2, r.tinyid;
- o = m(r, ["a2", "tinyid"]);
- }
- var i = {
- request: {
- ownerID: "Owner_Account",
- userID: "Member_Account",
- newOwnerID: "NewOwner_Account",
- maxMemberNum: "MaxMemberCount",
- groupCustomField: "AppDefinedData",
- memberCustomField: "AppMemberDefinedData",
- groupCustomFieldFilter: "AppDefinedDataFilter_Group",
- memberCustomFieldFilter: "AppDefinedDataFilter_GroupMember",
- messageRemindType: "MsgFlag",
- userIDList: "MemberList",
- groupIDList: "GroupIdList",
- applyMessage: "ApplyMsg",
- muteTime: "ShutUpTime",
- muteAllMembers: "ShutUpAllMember",
- joinOption: "ApplyJoinOption"
- },
- response: {
- GroupIdList: "groups",
- MsgFlag: "messageRemindType",
- AppDefinedData: "groupCustomField",
- AppMemberDefinedData: "memberCustomField",
- AppDefinedDataFilter_Group: "groupCustomFieldFilter",
- AppDefinedDataFilter_GroupMember: "memberCustomFieldFilter",
- InfoSeq: "infoSequence",
- MemberList: "members",
- GroupInfo: "groups",
- ShutUpUntil: "muteUntil",
- ShutUpAllMember: "muteAllMembers",
- ApplyJoinOption: "joinOption"
- }
- },
- s = {
- serverName: _o.NAME.GROUP,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- queryString: o
- };
- return {
- create: u(u({}, s), {}, {
- cmd: _o.CMD.CREATE_GROUP,
- requestData: {
- type: t.GRP_WORK,
- name: void 0,
- groupID: void 0,
- ownerID: e.loginInfo.identifier,
- introduction: void 0,
- notification: void 0,
- avatar: void 0,
- maxMemberNum: void 0,
- joinOption: void 0,
- memberList: void 0,
- groupCustomField: void 0
- },
- keyMaps: i
- }),
- list: u(u({}, s), {}, {
- cmd: _o.CMD.GET_JOINED_GROUPS,
- requestData: {
- userID: e.loginInfo.identifier,
- limit: void 0,
- offset: void 0,
- groupType: void 0,
- responseFilter: void 0
- },
- keyMaps: i
- }),
- query: u(u({}, s), {}, {
- cmd: _o.CMD.GET_GROUP_INFO,
- requestData: {
- groupIDList: void 0,
- responseFilter: void 0
- },
- keyMaps: i
- }),
- getGroupMemberProfile: u(u({}, s), {}, {
- cmd: _o.CMD.GET_GROUP_MEMBER_INFO,
- requestData: {
- groupID: void 0,
- userIDList: void 0,
- memberInfoFilter: void 0,
- memberCustomFieldFilter: void 0
- },
- keyMaps: {
- request: u(u({}, i.request), {}, {
- userIDList: "Member_List_Account"
- }),
- response: i.response
- }
- }),
- getGroupMemberList: u(u({}, s), {}, {
- cmd: _o.CMD.GET_GROUP_MEMBER_LIST,
- requestData: {
- groupID: void 0,
- limit: 0,
- offset: 0,
- memberRoleFilter: void 0,
- memberInfoFilter: void 0
- },
- keyMaps: i
- }),
- quitGroup: u(u({}, s), {}, {
- cmd: _o.CMD.QUIT_GROUP,
- requestData: {
- groupID: void 0
- }
- }),
- changeGroupOwner: u(u({}, s), {}, {
- cmd: _o.CMD.CHANGE_GROUP_OWNER,
- queryString: o,
- requestData: {
- groupID: void 0,
- newOwnerID: void 0
- },
- keyMaps: i
- }),
- destroyGroup: u(u({}, s), {}, {
- cmd: _o.CMD.DESTROY_GROUP,
- requestData: {
- groupID: void 0
- }
- }),
- updateGroupProfile: u(u({}, s), {}, {
- cmd: _o.CMD.MODIFY_GROUP_INFO,
- requestData: {
- groupID: void 0,
- name: void 0,
- introduction: void 0,
- notification: void 0,
- avatar: void 0,
- maxMemberNum: void 0,
- joinOption: void 0,
- groupCustomField: void 0,
- muteAllMembers: void 0
- },
- keyMaps: {
- request: u(u({}, i.request), {}, {
- groupCustomField: "AppDefinedData"
- }),
- response: i.response
- }
- }),
- modifyGroupMemberInfo: u(u({}, s), {}, {
- cmd: _o.CMD.MODIFY_GROUP_MEMBER_INFO,
- requestData: {
- groupID: void 0,
- userID: void 0,
- messageRemindType: void 0,
- nameCard: void 0,
- role: void 0,
- memberCustomField: void 0,
- muteTime: void 0
- },
- keyMaps: i
- }),
- addGroupMember: u(u({}, s), {}, {
- cmd: _o.CMD.ADD_GROUP_MEMBER,
- requestData: {
- groupID: void 0,
- silence: void 0,
- userIDList: void 0
- },
- keyMaps: i
- }),
- deleteGroupMember: u(u({}, s), {}, {
- cmd: _o.CMD.DELETE_GROUP_MEMBER,
- requestData: {
- groupID: void 0,
- userIDList: void 0,
- reason: void 0
- },
- keyMaps: {
- request: {
- userIDList: "MemberToDel_Account"
- }
- }
- }),
- searchGroupByID: u(u({}, s), {}, {
- cmd: _o.CMD.SEARCH_GROUP_BY_ID,
- requestData: {
- groupIDList: void 0,
- responseFilter: {
- groupBasePublicInfoFilter: ["Type", "Name", "Introduction", "Notification", "FaceUrl", "CreateTime", "Owner_Account", "LastInfoTime", "LastMsgTime", "NextMsgSeq", "MemberNum", "MaxMemberNum", "ApplyJoinOption"]
- }
- },
- keyMaps: {
- request: {
- groupIDList: "GroupIdList"
- }
- }
- }),
- applyJoinGroup: u(u({}, s), {}, {
- cmd: _o.CMD.APPLY_JOIN_GROUP,
- requestData: {
- groupID: void 0,
- applyMessage: void 0,
- userDefinedField: void 0
- },
- keyMaps: i
- }),
- applyJoinAVChatRoom: u(u({}, s), {}, {
- serverName: _o.NAME.BIG_GROUP_NO_AUTH,
- cmd: _o.CMD.APPLY_JOIN_GROUP,
- requestData: {
- groupID: void 0,
- applyMessage: void 0,
- userDefinedField: void 0
- },
- keyMaps: i
- }),
- handleApplyJoinGroup: u(u({}, s), {}, {
- cmd: _o.CMD.HANDLE_APPLY_JOIN_GROUP,
- requestData: {
- groupID: void 0,
- applicant: void 0,
- handleAction: void 0,
- handleMessage: void 0,
- authentication: void 0,
- messageKey: void 0,
- userDefinedField: void 0
- },
- keyMaps: {
- request: {
- applicant: "Applicant_Account",
- handleAction: "HandleMsg",
- handleMessage: "ApprovalMsg",
- messageKey: "MsgKey"
- },
- response: {
- MsgKey: "messageKey"
- }
- }
- }),
- deleteGroupSystemNotice: u(u({}, s), {}, {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.DELETE_GROUP_SYSTEM_MESSAGE,
- requestData: {
- messageListToDelete: void 0
- },
- keyMaps: {
- request: {
- messageListToDelete: "DelMsgList",
- messageSeq: "MsgSeq",
- messageRandom: "MsgRandom"
- }
- }
- }),
- getGroupPendency: u(u({}, s), {}, {
- cmd: _o.CMD.GET_GROUP_PENDENCY,
- requestData: {
- startTime: void 0,
- limit: void 0,
- handleAccount: void 0
- },
- keyMaps: {
- request: {
- handleAccount: "Handle_Account"
- }
- }
- }),
- getOnlineMemberNum: {
- serverName: n,
- cmd: _o.CMD.GET_ONLINE_MEMBER_NUM,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- queryString: o,
- requestData: {
- groupID: void 0
- }
- }
- };
- }(this.tim), this.config.longPollID = function (e) {
- return {
- create: {},
- query: {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.GET_LONG_POLL_ID,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- queryString: u(u({}, Ls(e)), {}, {
- instanceid: e.context.instanceID,
- reqtime: +new Date() / 1e3
- }),
- requestData: {},
- keyMaps: {
- response: {
- LongPollingId: "longPollingID"
- }
- }
- },
- update: {},
- delete: {}
- };
- }(this.tim), this.config.longPoll = function (e) {
- var t = u(u({}, Ls(e)), {}, {
- instanceid: e.context.instanceID,
- reqtime: Math.ceil(+new Date() / 1e3)
- });
- return {
- create: {},
- query: {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.LONG_POLL,
- channel: _o.CHANNEL.AUTO,
- protocol: po,
- queryString: t,
- requestData: {
- timeout: null,
- cookie: {
- notifySeq: 0,
- noticeSeq: 0,
- longPollingID: 0
- }
- },
- keyMaps: {
- response: {
- C2cMsgArray: "C2CMessageArray",
- GroupMsgArray: "groupMessageArray",
- GroupTips: "groupTips",
- C2cNotifyMsgArray: "C2CNotifyMessageArray",
- ClientSeq: "clientSequence",
- MsgPriority: "priority",
- NoticeSeq: "noticeSequence",
- MsgContent: "content",
- MsgType: "type",
- MsgBody: "elements",
- ToGroupId: "to",
- Desc: "description",
- Ext: "extension"
- }
- }
- },
- update: {},
- delete: {}
- };
- }(this.tim), this.config.applyC2C = function (e) {
- var t = Ls(e),
- n = {
- serverName: _o.NAME.FRIEND,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- queryString: t
- };
- return {
- create: u(u({}, n), {}, {
- cmd: _o.CMD.FRIEND_ADD,
- requestData: {
- fromAccount: "",
- addFriendItem: []
- }
- }),
- get: u(u({}, n), {}, {
- cmd: _o.CMD.GET_PENDENCY,
- requestData: {
- fromAccount: "",
- pendencyType: "Pendency_Type_ComeIn"
- }
- }),
- update: u(u({}, n), {}, {
- cmd: _o.CMD.RESPONSE_PENDENCY,
- requestData: {
- fromAccount: "",
- responseFriendItem: []
- }
- }),
- delete: u(u({}, n), {}, {
- cmd: _o.CMD.DELETE_PENDENCY,
- requestData: {
- fromAccount: "",
- toAccount: [],
- pendencyType: "Pendency_Type_ComeIn"
- }
- })
- };
- }(this.tim), this.config.friend = function (e) {
- var t = u(u({}, Ls(e)), {}, {
- reqtime: function () {
- return +new Date();
- }
- }),
- n = {
- serverName: _o.NAME.FRIEND,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t
- };
- return {
- get: u(u({}, n), {}, {
- cmd: _o.CMD.FRIEND_GET_ALL,
- requestData: {
- fromAccount: "",
- timeStamp: 0,
- tagList: [Ct.NICK, "Tag_SNS_IM_Remark", Ct.AVATAR]
- },
- keyMaps: {
- request: {},
- response: {}
- }
- }),
- delete: u(u({}, n), {}, {
- cmd: _o.CMD.FRIEND_DELETE,
- requestData: {
- fromAccount: "",
- toAccount: [],
- deleteType: "Delete_Type_Single"
- }
- })
- };
- }(this.tim), this.config.blacklist = function (e) {
- var t = Ls(e),
- n = {
- serverName: _o.NAME.FRIEND,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t
- };
- return {
- create: u(u({}, n), {}, {
- cmd: _o.CMD.ADD_BLACKLIST,
- requestData: {
- fromAccount: "",
- toAccount: []
- }
- }),
- get: u(u({}, n), {}, {
- cmd: _o.CMD.GET_BLACKLIST,
- requestData: {
- fromAccount: "",
- startIndex: 0,
- maxLimited: 30,
- lastSequence: 0
- }
- }),
- delete: u(u({}, n), {}, {
- cmd: _o.CMD.DELETE_BLACKLIST,
- requestData: {
- fromAccount: "",
- toAccount: []
- }
- }),
- update: {}
- };
- }(this.tim), this.config.c2cMessage = function (e) {
- var t = u(u({}, Ls(e)), {}, {
- reqtime: function () {
- return +new Date();
- }
- }),
- n = {
- request: {
- fromAccount: "From_Account",
- toAccount: "To_Account",
- msgTimeStamp: "MsgTimeStamp",
- msgSeq: "MsgSeq",
- msgRandom: "MsgRandom",
- msgBody: "MsgBody",
- count: "MaxCnt",
- lastMessageTime: "LastMsgTime",
- messageKey: "MsgKey",
- peerAccount: "Peer_Account",
- data: "Data",
- description: "Desc",
- extension: "Ext",
- type: "MsgType",
- content: "MsgContent",
- sizeType: "Type",
- uuid: "UUID",
- imageUrl: "URL",
- fileUrl: "Url",
- remoteAudioUrl: "Url",
- remoteVideoUrl: "VideoUrl",
- thumbUUID: "ThumbUUID",
- videoUUID: "VideoUUID",
- videoUrl: "",
- downloadFlag: "Download_Flag"
- },
- response: {
- MsgContent: "content",
- MsgTime: "time",
- Data: "data",
- Desc: "description",
- Ext: "extension",
- MsgKey: "messageKey",
- MsgType: "type",
- MsgBody: "elements",
- Download_Flag: "downloadFlag",
- ThumbUUID: "thumbUUID",
- VideoUUID: "videoUUID"
- }
- },
- o = {
- serverName: _o.NAME.OPEN_IM,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t
- };
- return {
- create: u(u({}, o), {}, {
- cmd: _o.CMD.SEND_MESSAGE,
- requestData: {
- fromAccount: e.loginInfo.identifier,
- toAccount: "",
- msgTimeStamp: Math.ceil(+new Date() / 1e3),
- msgSeq: 0,
- msgRandom: 0,
- msgBody: [],
- msgLifeTime: void 0,
- offlinePushInfo: {
- pushFlag: 0,
- title: "",
- desc: "",
- ext: "",
- apnsInfo: {
- badgeMode: 0
- },
- androidInfo: {
- OPPOChannelID: ""
- }
- }
- },
- keyMaps: n
- }),
- query: u(u({}, o), {}, {
- cmd: _o.CMD.GET_C2C_ROAM_MESSAGES,
- requestData: {
- peerAccount: "",
- count: 15,
- lastMessageTime: 0,
- messageKey: "",
- withRecalledMsg: 1
- },
- keyMaps: n
- })
- };
- }(this.tim), this.config.c2cMessageWillBeRevoked = function (e) {
- var t = u(u({}, Ls(e)), {}, {
- reqtime: function () {
- return +new Date();
- }
- });
- return {
- create: {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.REVOKE_C2C_MESSAGE,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t,
- requestData: {
- msgInfo: {
- fromAccount: "",
- toAccount: "",
- msgTimeStamp: Math.ceil(+new Date() / 1e3),
- msgSeq: 0,
- msgRandom: 0
- }
- },
- keyMaps: {
- request: {
- msgInfo: "MsgInfo",
- fromAccount: "From_Account",
- toAccount: "To_Account",
- msgTimeStamp: "MsgTimeStamp",
- msgSeq: "MsgSeq",
- msgRandom: "MsgRandom",
- msgBody: "MsgBody"
- }
- }
- }
- };
- }(this.tim), this.config.c2cPeerReadTime = function (e) {
- var t = u(u({}, Ls(e)), {}, {
- reqtime: function () {
- return +new Date();
- }
- });
- return {
- get: {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.GET_PEER_READ_TIME,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t,
- requestData: {
- userIDList: void 0
- },
- keyMaps: {
- request: {
- userIDList: "To_Account"
- },
- response: {
- ReadTime: "peerReadTimeList"
- }
- }
- }
- };
- }(this.tim), this.config.groupMessage = function (e) {
- var t = u(u({}, Ls(e)), {}, {
- reqtime: function () {
- return +new Date();
- }
- }),
- n = {
- request: {
- to: "GroupId",
- extension: "Ext",
- data: "Data",
- description: "Desc",
- random: "Random",
- sequence: "ReqMsgSeq",
- count: "ReqMsgNumber",
- type: "MsgType",
- priority: "MsgPriority",
- content: "MsgContent",
- elements: "MsgBody",
- sizeType: "Type",
- uuid: "UUID",
- imageUrl: "URL",
- fileUrl: "Url",
- remoteAudioUrl: "Url",
- remoteVideoUrl: "VideoUrl",
- thumbUUID: "ThumbUUID",
- videoUUID: "VideoUUID",
- videoUrl: "",
- downloadFlag: "Download_Flag",
- clientSequence: "ClientSeq"
- },
- response: {
- Random: "random",
- MsgTime: "time",
- MsgSeq: "sequence",
- ReqMsgSeq: "sequence",
- RspMsgList: "messageList",
- IsPlaceMsg: "isPlaceMessage",
- IsSystemMsg: "isSystemMessage",
- ToGroupId: "to",
- EnumFrom_AccountType: "fromAccountType",
- EnumTo_AccountType: "toAccountType",
- GroupCode: "groupCode",
- MsgPriority: "priority",
- MsgBody: "elements",
- MsgType: "type",
- MsgContent: "content",
- IsFinished: "complete",
- Download_Flag: "downloadFlag",
- ClientSeq: "clientSequence",
- ThumbUUID: "thumbUUID",
- VideoUUID: "videoUUID"
- }
- },
- o = {
- serverName: _o.NAME.GROUP,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t
- };
- return {
- create: u(u({}, o), {}, {
- cmd: _o.CMD.SEND_GROUP_MESSAGE,
- requestData: {
- groupID: "",
- fromAccount: e.loginInfo.identifier,
- random: 0,
- clientSequence: 0,
- priority: "",
- msgBody: [],
- onlineOnlyFlag: 0,
- offlinePushInfo: {
- pushFlag: 0,
- title: "",
- desc: "",
- ext: "",
- apnsInfo: {
- badgeMode: 0
- },
- androidInfo: {
- OPPOChannelID: ""
- }
- },
- groupAtInfo: []
- },
- keyMaps: n
- }),
- query: u(u({}, o), {}, {
- cmd: _o.CMD.GET_GROUP_ROAM_MESSAGES,
- requestData: {
- withRecalledMsg: 1,
- groupID: "",
- count: 15,
- sequence: ""
- },
- keyMaps: n
- }),
- update: null,
- delete: null
- };
- }(this.tim), this.config.groupMessageWillBeRevoked = function (e) {
- var t = u(u({}, Ls(e)), {}, {
- reqtime: function () {
- return +new Date();
- }
- });
- return {
- create: {
- serverName: _o.NAME.GROUP,
- cmd: _o.CMD.REVOKE_GROUP_MESSAGE,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t,
- requestData: {
- to: "",
- msgSeqList: []
- },
- keyMaps: {
- request: {
- to: "GroupId",
- msgSeqList: "MsgSeqList",
- msgSeq: "MsgSeq"
- }
- }
- }
- };
- }(this.tim), this.config.conversation = function (e) {
- var t = Ls(e),
- n = {
- serverName: _o.NAME.RECENT_CONTACT,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t
- };
- return {
- query: u(u({}, n), {}, {
- cmd: _o.CMD.GET_CONVERSATION_LIST,
- requestData: {
- fromAccount: e.loginInfo.identifier,
- count: 0
- },
- keyMaps: {
- request: {},
- response: {
- SessionItem: "conversations",
- ToAccount: "groupID",
- To_Account: "userID",
- UnreadMsgCount: "unreadCount",
- MsgGroupReadedSeq: "messageReadSeq"
- }
- }
- }),
- pagingQuery: u(u({}, n), {}, {
- cmd: _o.CMD.PAGING_GET_CONVERSATION_LIST,
- requestData: {
- fromAccount: void 0,
- timeStamp: void 0,
- orderType: void 0
- },
- keyMaps: {
- request: {},
- response: {
- SessionItem: "conversations",
- ToAccount: "groupID",
- To_Account: "userID",
- UnreadMsgCount: "unreadCount",
- MsgGroupReadedSeq: "messageReadSeq",
- C2cPeerReadTime: "c2cPeerReadTime"
- }
- }
- }),
- delete: u(u({}, n), {}, {
- cmd: _o.CMD.DELETE_CONVERSATION,
- requestData: {
- fromAccount: e.loginInfo.identifier,
- toAccount: void 0,
- type: 1,
- toGroupID: void 0
- },
- keyMaps: {
- request: {
- toGroupID: "ToGroupid"
- }
- }
- }),
- setC2CMessageRead: u(u({}, n), {}, {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.SET_C2C_MESSAGE_READ,
- requestData: {
- C2CMsgReaded: void 0
- },
- keyMaps: {
- request: {
- lastMessageTime: "LastedMsgTime"
- }
- }
- }),
- setGroupMessageRead: u(u({}, n), {}, {
- serverName: _o.NAME.GROUP,
- cmd: _o.CMD.SET_GROUP_MESSAGE_READ,
- requestData: {
- groupID: void 0,
- messageReadSeq: void 0
- },
- keyMaps: {
- request: {
- messageReadSeq: "MsgReadedSeq"
- }
- }
- }),
- deleteGroupAtTips: u(u({}, n), {}, {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.DELETE_GROUP_AT_TIPS,
- requestData: {
- messageListToDelete: void 0
- },
- keyMaps: {
- request: {
- messageListToDelete: "DelMsgList",
- messageSeq: "MsgSeq",
- messageRandom: "MsgRandom"
- }
- }
- })
- };
- }(this.tim), this.config.syncMessage = function (e) {
- var t = u(u({}, Ls(e)), {}, {
- reqtime: function () {
- return [Math.ceil(+new Date()), Math.random()].join("");
- }
- });
- return {
- create: null,
- query: {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.GET_MESSAGES,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t,
- requestData: {
- cookie: "",
- syncFlag: 0,
- needAbstract: 1
- },
- keyMaps: {
- request: {
- fromAccount: "From_Account",
- toAccount: "To_Account",
- from: "From_Account",
- to: "To_Account",
- time: "MsgTimeStamp",
- sequence: "MsgSeq",
- random: "MsgRandom",
- elements: "MsgBody"
- },
- response: {
- MsgList: "messageList",
- SyncFlag: "syncFlag",
- To_Account: "to",
- From_Account: "from",
- ClientSeq: "clientSequence",
- MsgSeq: "sequence",
- NoticeSeq: "noticeSequence",
- NotifySeq: "notifySequence",
- MsgRandom: "random",
- MsgTimeStamp: "time",
- MsgContent: "content",
- ToGroupId: "groupID",
- MsgKey: "messageKey",
- GroupTips: "groupTips",
- MsgBody: "elements",
- MsgType: "type",
- C2CRemainingUnreadCount: "C2CRemainingUnreadList"
- }
- }
- },
- update: null,
- delete: null
- };
- }(this.tim), this.config.AVChatRoom = function (e) {
- var t = _o.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH,
- n = u(u({}, Ls(e)), {}, {
- accounttype: "792",
- reqtime: function () {
- return +new Date();
- }
- });
- return (e.context.login === ot.IS_LOGIN || e.context.a2Key) && (t = _o.NAME.BIG_GROUP_LONG_POLLING), {
- startLongPoll: {
- serverName: t,
- cmd: _o.CMD.AVCHATROOM_LONG_POLL,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: n,
- requestData: {
- USP: 1,
- startSeq: 1,
- holdTime: 90,
- key: void 0
- },
- keyMaps: {
- request: {
- USP: "USP"
- },
- response: {
- ToGroupId: "groupID",
- MsgPriority: "priority"
- }
- }
- }
- };
- }(this.tim), this.config.cosUpload = function (e) {
- var t = u(u({}, Ls(e)), {}, {
- reqtime: function () {
- return +new Date();
- }
- });
- return {
- create: {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.FILE_UPLOAD,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t,
- requestData: {
- appVersion: "2.1",
- fromAccount: "",
- toAccount: "",
- sequence: 0,
- time: function () {
- return Math.ceil(Date.now() / 1e3);
- },
- random: function () {
- return we();
- },
- fileStrMd5: "",
- fileSize: "",
- serverVer: 1,
- authKey: "",
- busiId: 1,
- pkgFlag: 1,
- sliceOffset: 0,
- sliceSize: 0,
- sliceData: "",
- contentType: "application/x-www-form-urlencoded"
- },
- keyMaps: {
- request: {},
- response: {}
- }
- },
- update: null,
- delete: null
- };
- }(this.tim), this.config.cosSig = function (e) {
- var t = {
- sdkappid: e.loginInfo.SDKAppID,
- identifier: e.loginInfo.identifier,
- userSig: e.context.userSig
- };
- return {
- create: null,
- query: {
- serverName: _o.NAME.IM_COS_SIGN,
- cmd: _o.CMD.COS_SIGN,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: t,
- requestData: {
- cmd: "open_im_cos_svc",
- subCmd: "get_cos_token",
- duration: 300,
- version: 2
- },
- keyMaps: {
- request: {
- userSig: "usersig",
- subCmd: "sub_cmd",
- cmd: "cmd",
- duration: "duration",
- version: "version"
- },
- response: {
- expired_time: "expiredTime",
- bucket_name: "bucketName",
- session_token: "sessionToken",
- tmp_secret_id: "secretId",
- tmp_secret_key: "secretKey"
- }
- }
- },
- update: null,
- delete: null
- };
- }(this.tim), this.config.bigDataHallwayAuthKey = function (e) {
- return {
- create: null,
- query: {
- serverName: _o.NAME.OPEN_IM,
- cmd: _o.CMD.BIG_DATA_HALLWAY_AUTH_KEY,
- channel: _o.CHANNEL.XHR,
- protocol: po,
- method: "POST",
- queryString: u(u({}, Ls(e)), {}, {
- accounttype: "792",
- reqtime: function () {
- return +new Date();
- }
- }),
- requestData: {}
- }
- };
- }(this.tim), this.config.ssoEventStat = function (e) {
- var t = {
- sdkappid: e.loginInfo.SDKAppID,
- reqtime: Math.ceil(+new Date() / 1e3)
- };
- return {
- create: {
- serverName: _o.NAME.IM_OPEN_STAT,
- cmd: _o.CMD.TIM_WEB_REPORT,
- channel: _o.CHANNEL.AUTO,
- protocol: po,
- queryString: t,
- requestData: {
- table: "",
- report: []
- },
- keyMaps: {
- request: {
- table: "table",
- report: "report",
- SDKAppID: "sdkappid",
- version: "version",
- tinyID: "tinyid",
- userID: "userid",
- platform: "platform",
- method: "method",
- time: "time",
- start: "start",
- end: "end",
- cost: "cost",
- status: "status",
- codeint: "codeint",
- message: "message",
- pointer: "pointer",
- text: "text",
- msgType: "msgtype",
- networkType: "networktype",
- startts: "startts",
- endts: "endts",
- timespan: "timespan"
- }
- }
- },
- query: {},
- update: {},
- delete: {}
- };
- }(this.tim), this.config.ssoSumStat = function (e) {
- var t = null;
- null !== e.context && (t = {
- sdkappid: e.context.SDKAppID,
- reqtime: Math.ceil(+new Date() / 1e3)
- });
- return {
- create: {
- serverName: _o.NAME.IM_OPEN_STAT,
- cmd: _o.CMD.TIM_WEB_REPORT,
- channel: _o.CHANNEL.AUTO,
- protocol: po,
- queryString: t,
- requestData: {
- table: "",
- report: []
- },
- keyMaps: {
- request: {
- table: "table",
- report: "report",
- SDKAppID: "sdkappid",
- version: "version",
- tinyID: "tinyid",
- userID: "userid",
- item: "item",
- lpID: "lpid",
- platform: "platform",
- scene: "scene",
- networkType: "networktype",
- total: "total",
- successRate: "successrate",
- avg: "avg",
- timespan: "timespan",
- time: "time"
- }
- }
- },
- query: {},
- update: {},
- delete: {}
- };
- }(this.tim);
- }
- }, {
- key: "_initRequestData",
- value: function (e, t) {
- if (void 0 === e) return pr(t.requestData, this._getRequestMap(t), this.tim);
- var n = t.requestData,
- o = Object.create(null);
- for (var r in n) if (Object.prototype.hasOwnProperty.call(n, r)) {
- if (o[r] = "function" == typeof n[r] ? n[r]() : n[r], void 0 === e[r]) continue;
- o[r] = e[r];
- }
- return o = pr(o, this._getRequestMap(t), this.tim);
- }
- }, {
- key: "_getRequestMap",
- value: function (e) {
- if (e.keyMaps && e.keyMaps.request && Object.keys(e.keyMaps.request).length > 0) return e.keyMaps.request;
- }
- }, {
- key: "_initEncoder",
- value: function (e) {
- switch (e.protocol) {
- case po:
- return function (e) {
- if ("string" === n(e)) try {
- return JSON.parse(e);
- } catch (t) {
- return e;
- }
- return e;
- };
- case lo:
- return function (e) {
- return e;
- };
- default:
- return function (e) {
- return de.warn("PackageConfig._initEncoder(), unknow response type, data: ", JSON.stringify(e)), e;
- };
- }
- }
- }, {
- key: "_initDecoder",
- value: function (e) {
- switch (e.protocol) {
- case po:
- return function (e) {
- if ("string" === n(e)) try {
- return JSON.parse(e);
- } catch (t) {
- return e;
- }
- return e;
- };
- case lo:
- return function (e) {
- return e;
- };
- default:
- return function (e) {
- return de.warn("PackageConfig._initDecoder(), unknow response type, data: ", e), e;
- };
- }
- }
- }]), e;
- }(),
- Ps = function () {
- for (var e = [], t = Gs(arguments), n = 0; n < arguments.length; n++) Number.isInteger(arguments[n]) ? e.push(arguments[n]) : e.push(!0 == !!arguments[n] ? "1" : "0");
- return e.join(t);
- },
- Gs = function (e) {
- var t = e.length,
- n = e[t - 1];
- if ("string" != typeof n) return "";
- if (n.length > 1) return "";
- var o = e[t - 1];
- return delete e[t - 1], e.length -= t === e.length ? 1 : 0, o;
- },
- bs = {
- C2CMessageArray: 1,
- groupMessageArray: 1,
- groupTips: 1,
- C2CNotifyMessageArray: 1,
- profileModify: 1,
- friendListMod: 1
- },
- Us = function (e) {
- c(n, e);
- var t = v(n);
- function n(e) {
- var r;
- return o(this, n), (r = t.call(this, e))._initialization(), r;
- }
- return i(n, [{
- key: "_initialization",
- value: function () {
- this._syncOffset = "", this._syncNoticeList = [], this._syncEventArray = [], this._syncMessagesIsRunning = !1, this._syncMessagesFinished = !1, this._isLongPoll = !1, this._longPollID = "0", this._noticeSequence = 0, this._initializeListener(), this._runLoop = null, this._initShuntChannels();
- }
- }, {
- key: "_initShuntChannels",
- value: function () {
- this._shuntChannels = Object.create(null), this._shuntChannels.C2CMessageArray = this._C2CMessageArrayChannel.bind(this), this._shuntChannels.groupMessageArray = this._groupMessageArrayChannel.bind(this), this._shuntChannels.groupTips = this._groupTipsChannel.bind(this), this._shuntChannels.C2CNotifyMessageArray = this._C2CNotifyMessageArrayChannel.bind(this), this._shuntChannels.profileModify = this._profileModifyChannel.bind(this), this._shuntChannels.friendListMod = this._friendListModChannel.bind(this);
- }
- }, {
- key: "_C2CMessageArrayChannel",
- value: function (e, t, n) {
- this.emitInnerEvent(Uo, t);
- }
- }, {
- key: "_groupMessageArrayChannel",
- value: function (e, t, n) {
- this.emitInnerEvent(qo, t);
- }
- }, {
- key: "_groupTipsChannel",
- value: function (e, t, n) {
- var o = this;
- switch (e) {
- case 4:
- case 6:
- this.emitInnerEvent(Fo, t);
- break;
- case 5:
- t.forEach(function (e) {
- Ie(e.elements.revokedInfos) ? o.emitInnerEvent(Bo, t) : o.emitInnerEvent(Vo, {
- groupSystemNotices: t,
- type: n
- });
- });
- break;
- case 12:
- this.emitInnerEvent(xo, t);
- break;
- default:
- de.log("NotificationController._groupTipsChannel unknown event=".concat(e, " type=").concat(n), t);
- }
- }
- }, {
- key: "_C2CNotifyMessageArrayChannel",
- value: function (e, t, n) {
- if (t[0]) {
- var o = t[0];
- o.hasOwnProperty("kickoutMsgNotify") ? this.emitInnerEvent(bo) : o.hasOwnProperty("c2cMessageRevokedNotify") ? this.emitInnerEvent(jo, t) : o.hasOwnProperty("c2cMessageReadReceipt") && this.emitInnerEvent($o, t);
- }
- }
- }, {
- key: "_profileModifyChannel",
- value: function (e, t, n) {
- this.emitInnerEvent(Ho, t);
- }
- }, {
- key: "_friendListModChannel",
- value: function (e, t, n) {
- this.emitInnerEvent(Ko, t);
- }
- }, {
- key: "_dispatchNotice",
- value: function (e) {
- var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "poll";
- if (Ie(e)) for (var n = null, o = null, r = "", i = 0, s = 0, a = e.length; s < a; s++) i = (n = e[s]).event, r = Object.keys(n).find(function (e) {
- return void 0 !== bs[e];
- }), Ee(this._shuntChannels[r]) ? (o = n[r], "poll" === t && this._updatenoticeSequence(o), this._shuntChannels[r](i, o, t)) : ("poll" === t && this._updatenoticeSequence(), de.log("NotificationController._dispatchNotice unknown eventItem=", n));
- }
- }, {
- key: "getLongPollID",
- value: function () {
- return this._longPollID;
- }
- }, {
- key: "_IAmReady",
- value: function () {
- this.triggerReady();
- }
- }, {
- key: "reset",
- value: function () {
- this._noticeSequence = 0, this._resetSync(), this.closeNoticeChannel();
- }
- }, {
- key: "_resetSync",
- value: function () {
- this._syncOffset = "", this._syncNoticeList = [], this._syncEventArray = [], this._syncMessagesIsRunning = !1, this._syncMessagesFinished = !1;
- }
- }, {
- key: "_setNoticeSeqInRequestData",
- value: function (e) {
- e.Cookie.NoticeSeq = this._noticeSequence, this.tim.sumStatController.addTotalCount(Dr);
- }
- }, {
- key: "_updatenoticeSequence",
- value: function (e) {
- if (e) {
- var t = e[e.length - 1].noticeSequence;
- t && "number" == typeof t ? t <= this._noticeSequence || (this._noticeSequence = t) : this._noticeSequence++;
- } else this._noticeSequence++;
- }
- }, {
- key: "_initializeListener",
- value: function () {
- var e = this.tim.innerEmitter;
- e.on(Mo, this._startSyncMessages, this), e.on(Qo, this.closeNoticeChannel, this);
- }
- }, {
- key: "openNoticeChannel",
- value: function () {
- de.log("NotificationController.openNoticeChannel"), this._getLongPollID();
- }
- }, {
- key: "closeNoticeChannel",
- value: function () {
- de.log("NotificationController.closeNoticeChannel"), (this._runLoop instanceof zi || this._runLoop instanceof Ji) && (this._runLoop.abort(), this._runLoop.stop()), this._longPollID = "0", this._isLongPoll = !1;
- }
- }, {
- key: "_getLongPollID",
- value: function () {
- var e = this;
- if ("0" === this._longPollID) {
- var t = new qr(Ni);
- this.request({
- name: "longPollID",
- action: "query"
- }).then(function (n) {
- var o = n.data.longPollingID;
- e._onGetLongPollIDSuccess(o), t.setText("longPollingID=".concat(o)).setNetworkType(e.getNetworkType()).setEnd();
- }).catch(function (n) {
- var o = new Ut({
- code: n.code || qt.GET_LONGPOLL_ID_FAILED,
- message: n.message || Kn
- });
- e.emitInnerEvent(Lo), e.emitInnerEvent(er, o), e.probeNetwork().then(function (e) {
- var n = y(e, 2),
- r = n[0],
- i = n[1];
- t.setError(o, r, i).setEnd();
- });
- });
- } else this._onGetLongPollIDSuccess(this._longPollID);
- }
- }, {
- key: "_onGetLongPollIDSuccess",
- value: function (e) {
- this.emitInnerEvent(Co, [{
- key: "long_poll_logout.query.requestData.longPollingID",
- value: e
- }, {
- key: "longPoll.query.requestData.cookie.longPollingID",
- value: e
- }]), this._longPollID = e, this._startLongPoll(), this._IAmReady(), this.tim.sumStatController.recordLongPollingID(this._longPollID);
- }
- }, {
- key: "_startLongPoll",
- value: function () {
- if (!0 !== this._isLongPoll) {
- de.log("NotificationController._startLongPoll...");
- var e = this.tim.connectionController,
- t = this.createTransportCapsule({
- name: "longPoll",
- action: "query"
- });
- this._isLongPoll = !0, this._runLoop = e.createRunLoop({
- pack: t,
- before: this._setNoticeSeqInRequestData.bind(this),
- success: this._onNoticeReceived.bind(this),
- fail: this._onNoticeFail.bind(this)
- }), this._runLoop.start();
- } else de.log("NotificationController._startLongPoll is running...");
- }
- }, {
- key: "_onNoticeReceived",
- value: function (e) {
- var t = e.data;
- t.errorCode !== nt.SUCCESS ? (new qr(Li).setMessage(t.errorInfo || JSON.stringify(t)).setCode(t.errorCode).setNetworkType(this.getNetworkType()).setEnd(!0), this._onResponseError(t)) : this.emitInnerEvent(Po);
- this.tim.sumStatController.addSuccessCount(Dr), this.tim.sumStatController.addCost(Dr, t.timecost), e.data.eventArray && this._dispatchNotice(e.data.eventArray);
- }
- }, {
- key: "_onResponseError",
- value: function (e) {
- switch (e.errorCode) {
- case qt.LONG_POLL_KICK_OUT:
- de.warn("NotificationController._onResponseError, longPollingID=".concat(this._longPollID, " was kicked out")), this.emitInnerEvent(Go), this.closeNoticeChannel();
- break;
- case qt.MESSAGE_A2KEY_EXPIRED:
- case qt.ACCOUNT_A2KEY_EXPIRED:
- this.emitInnerEvent(Zo);
- break;
- default:
- Me(e.errorCode) || Me(e.errorInfo) ? de.log("NotificationController._onResponseError, errorCode or errorInfo undefined!", e) : this.emitInnerEvent(er, new Ut({
- code: e.errorCode,
- message: e.errorInfo
- }));
- }
- }
- }, {
- key: "_onNoticeFail",
- value: function (e) {
- if (e.error) if ("ECONNABORTED" === e.error.code || e.error.code === qt.NETWORK_TIMEOUT) {
- if (e.error.config) {
- var t = e.error.config.url,
- n = e.error.config.data;
- de.log("NotificationController._onNoticeFail request timed out. url=".concat(t, " data=").concat(n));
- } else de.log("NotificationController._onNoticeFail request timed out.");
- } else de.log("NotificationController._onNoticeFail request failed due to network error");
- this.emitInnerEvent(wo);
- }
- }, {
- key: "_startSyncMessages",
- value: function (e) {
- !0 !== this._syncMessagesFinished && this.syncMessage();
- }
- }, {
- key: "syncMessage",
- value: function () {
- var e = this,
- t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "",
- n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0;
- this._syncMessagesIsRunning = !0, this.request({
- name: "syncMessage",
- action: "query",
- param: {
- cookie: t,
- syncFlag: n
- }
- }).then(function (t) {
- var n = t.data;
- switch (Ps(n.cookie, n.syncFlag)) {
- case "00":
- case "01":
- e.emitInnerEvent(er, {
- code: qt.NOTICE_RUNLOOP_OFFSET_LOST,
- message: Vn
- });
- break;
- case "10":
- case "11":
- n.eventArray && e._dispatchNotice(n.eventArray, "sync"), e._syncNoticeList = e._syncNoticeList.concat(n.messageList), e.emitInnerEvent(Eo, {
- data: n.messageList,
- C2CRemainingUnreadList: n.C2CRemainingUnreadList
- }), e._syncOffset = n.cookie, e.syncMessage(n.cookie, n.syncFlag);
- break;
- case "12":
- n.eventArray && e._dispatchNotice(n.eventArray, "sync"), e.openNoticeChannel(), e._syncNoticeList = e._syncNoticeList.concat(n.messageList), e.emitInnerEvent(To, {
- messageList: n.messageList,
- C2CRemainingUnreadList: n.C2CRemainingUnreadList
- }), e._syncOffset = n.cookie, e._syncNoticeList = [], e._syncMessagesIsRunning = !1, e._syncMessagesFinished = !0;
- }
- }).catch(function (t) {
- e._syncMessagesIsRunning = !1, de.error("NotificationController.syncMessage failed. error:", t);
- });
- }
- }]), n;
- }(mr),
- qs = function (e) {
- c(n, e);
- var t = v(n);
- function n(e) {
- var r;
- return o(this, n), (r = t.call(this, e)).COSSDK = null, r._cosUploadMethod = null, r.expiredTimeLimit = 600, r.appid = 0, r.bucketName = "", r.ciUrl = "", r.directory = "", r.downloadUrl = "", r.uploadUrl = "", r.expiredTimeOut = r.expiredTimeLimit, r.region = "ap-shanghai", r.cos = null, r.cosOptions = {
- secretId: "",
- secretKey: "",
- sessionToken: "",
- expiredTime: 0
- }, r._timer = 0, r.tim.innerEmitter.on(Mo, r._init, f(r)), r.triggerReady(), r;
- }
- return i(n, [{
- key: "_expiredTimer",
- value: function () {
- var e = this;
- this._timer = setInterval(function () {
- Math.ceil(Date.now() / 1e3) >= e.cosOptions.expiredTime - 120 && (e._getAuthorizationKey(), clearInterval(e._timer));
- }, 6e4);
- }
- }, {
- key: "_init",
- value: function () {
- var e = V ? "cos-wx-sdk" : "cos-js-sdk";
- this.COSSDK = this.tim.getPlugin(e), this.COSSDK ? this._getAuthorizationKey() : de.warn("UploadController._init 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#registerPlugin");
- }
- }, {
- key: "_getAuthorizationKey",
- value: function () {
- var e = this,
- t = Math.ceil(Date.now() / 1e3),
- n = new qr($r);
- this.request({
- name: "cosSig",
- action: "query",
- param: {
- duration: this.expiredTimeLimit
- }
- }).then(function (o) {
- de.log("UploadController._getAuthorizationKey ok. data:", o.data);
- var r = o.data,
- i = r.expiredTime - t;
- n.setText("requestId=".concat(r.requestId, " requestTime=").concat(t, " expiredTime=").concat(r.expiredTime, " timeout=").concat(i, "s")).setNetworkType(e.getNetworkType()).setEnd(), !V && r.region && (e.region = r.region), e.appid = r.appid, e.bucketName = r.bucketName, e.ciUrl = r.ciUrl, e.directory = r.directory, e.downloadUrl = r.downloadUrl, e.uploadUrl = r.uploadUrl, e.expiredTimeOut = i, e.cosOptions = {
- secretId: r.secretId,
- secretKey: r.secretKey,
- sessionToken: r.sessionToken,
- expiredTime: r.expiredTime
- }, de.log("UploadController._getAuthorizationKey cos.config:", "region=".concat(e.region, ",bucketName=").concat(e.bucketName)), e._initUploaderMethod(), e._expiredTimer();
- }).catch(function (t) {
- e.probeNetwork().then(function (e) {
- var o = y(e, 2),
- r = o[0],
- i = o[1];
- n.setError(t, r, i).setEnd();
- }), de.warn("UploadController._getAuthorizationKey failed. error:", t);
- });
- }
- }, {
- key: "_initUploaderMethod",
- value: function () {
- var e = this;
- this.appid && (this.cos = V ? new this.COSSDK({
- ForcePathStyle: !0,
- getAuthorization: this._getAuthorization.bind(this)
- }) : new this.COSSDK({
- getAuthorization: this._getAuthorization.bind(this)
- }), this._cosUploadMethod = V ? function (t, n) {
- e.cos.postObject(t, n);
- } : function (t, n) {
- e.cos.uploadFiles(t, n);
- });
- }
- }, {
- key: "_getAuthorization",
- value: function (e, t) {
- t({
- TmpSecretId: this.cosOptions.secretId,
- TmpSecretKey: this.cosOptions.secretKey,
- XCosSecurityToken: this.cosOptions.sessionToken,
- ExpiredTime: this.cosOptions.expiredTime
- });
- }
- }, {
- key: "uploadImage",
- value: function (e) {
- if (!e.file) return Cr(new Ut({
- code: qt.MESSAGE_IMAGE_SELECT_FILE_FIRST,
- message: en
- }));
- var t = this._checkImageType(e.file);
- if (!0 !== t) return t;
- var n = this._checkImageMime(e.file);
- if (!0 !== n) return n;
- var o = this._checkImageSize(e.file);
- if (!0 !== o) return o;
- var r = null;
- return this.upload(e).then(function (e) {
- return r = e, t = "https://".concat(e.location), V ? new Promise(function (e, n) {
- K.getImageInfo({
- src: t,
- success: function (t) {
- e({
- width: t.width,
- height: t.height
- });
- },
- fail: function () {
- e({
- width: 0,
- height: 0
- });
- }
- });
- }) : ee && 9 === te ? Promise.resolve({
- width: 0,
- height: 0
- }) : new Promise(function (e, n) {
- var o = new Image();
- o.onload = function () {
- e({
- width: this.width,
- height: this.height
- }), o = null;
- }, o.onerror = function () {
- e({
- width: 0,
- height: 0
- }), o = null;
- }, o.src = t;
- });
- var t;
- }).then(function (e) {
- return r.width = e.width, r.height = e.height, Promise.resolve(r);
- });
- }
- }, {
- key: "_checkImageType",
- value: function (e) {
- var t = "";
- return t = V ? e.url.slice(e.url.lastIndexOf(".") + 1) : e.files[0].name.slice(e.files[0].name.lastIndexOf(".") + 1), jn.indexOf(t.toLowerCase()) >= 0 || Cr(new Ut({
- coe: qt.MESSAGE_IMAGE_TYPES_LIMIT,
- message: tn
- }));
- }
- }, {
- key: "_checkImageMime",
- value: function (e) {
- return !0;
- }
- }, {
- key: "_checkImageSize",
- value: function (e) {
- var t = 0;
- return 0 === (t = V ? e.size : e.files[0].size) ? Cr(new Ut({
- code: qt.MESSAGE_FILE_IS_EMPTY,
- message: "".concat(Xt)
- })) : t < 20971520 || Cr(new Ut({
- coe: qt.MESSAGE_IMAGE_SIZE_LIMIT,
- message: "".concat(nn)
- }));
- }
- }, {
- key: "uploadFile",
- value: function (e) {
- var t = null;
- return e.file ? e.file.files[0].size > 104857600 ? (t = new Ut({
- code: qt.MESSAGE_FILE_SIZE_LIMIT,
- message: pn
- }), Cr(t)) : 0 === e.file.files[0].size ? (t = new Ut({
- code: qt.MESSAGE_FILE_IS_EMPTY,
- message: "".concat(Xt)
- }), Cr(t)) : this.upload(e) : (t = new Ut({
- code: qt.MESSAGE_FILE_SELECT_FILE_FIRST,
- message: ln
- }), Cr(t));
- }
- }, {
- key: "uploadVideo",
- value: function (e) {
- return e.file.videoFile.size > 104857600 ? Cr(new Ut({
- code: qt.MESSAGE_VIDEO_SIZE_LIMIT,
- message: "".concat(an)
- })) : 0 === e.file.videoFile.size ? Cr(new Ut({
- code: qt.MESSAGE_FILE_IS_EMPTY,
- message: "".concat(Xt)
- })) : -1 === $n.indexOf(e.file.videoFile.type) ? Cr(new Ut({
- code: qt.MESSAGE_VIDEO_TYPES_LIMIT,
- message: "".concat(un)
- })) : V ? this.handleVideoUpload({
- file: e.file.videoFile
- }) : G ? this.handleVideoUpload(e) : void 0;
- }
- }, {
- key: "handleVideoUpload",
- value: function (e) {
- var t = this;
- return new Promise(function (n, o) {
- t.upload(e).then(function (e) {
- n(e);
- }).catch(function () {
- t.upload(e).then(function (e) {
- n(e);
- }).catch(function () {
- o(new Ut({
- code: qt.MESSAGE_VIDEO_UPLOAD_FAIL,
- message: sn
- }));
- });
- });
- });
- }
- }, {
- key: "uploadAudio",
- value: function (e) {
- return e.file ? e.file.size > 20971520 ? Cr(new Ut({
- code: qt.MESSAGE_AUDIO_SIZE_LIMIT,
- message: "".concat(rn)
- })) : 0 === e.file.size ? Cr(new Ut({
- code: qt.MESSAGE_FILE_IS_EMPTY,
- message: "".concat(Xt)
- })) : this.upload(e) : Cr(new Ut({
- code: qt.MESSAGE_AUDIO_UPLOAD_FAIL,
- message: on
- }));
- }
- }, {
- key: "upload",
- value: function (e) {
- var t = this;
- if (!Ee(this._cosUploadMethod)) return de.warn("UploadController.upload 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#registerPlugin"), Cr(new Ut({
- code: qt.COS_UNDETECTED,
- message: $t
- }));
- var n = new qr(Yr);
- de.time(Ur);
- var o = V ? e.file : e.file.files[0];
- return new Promise(function (r, i) {
- var s = V ? t._createCosOptionsWXMiniApp(e) : t._createCosOptionsWeb(e),
- a = t;
- t._cosUploadMethod(s, function (e, s) {
- var u = Object.create(null);
- if (s) {
- if (e || Ie(s.files) && s.files[0].error) {
- var c = new Ut({
- code: qt.MESSAGE_FILE_UPLOAD_FAIL,
- message: cn
- });
- return n.setError(c, !0, t.getNetworkType()).setEnd(), de.log("UploadController.upload failed, error:", s.files[0].error), 403 === s.files[0].error.statusCode && (de.warn("UploadController.upload failed. cos AccessKeyId was invalid, regain auth key!"), t._getAuthorizationKey()), void i(c);
- }
- u.fileName = o.name, u.fileSize = o.size, u.fileType = o.type.slice(o.type.indexOf("/") + 1).toLowerCase(), u.location = V ? s.Location : s.files[0].data.Location;
- var l = de.timeEnd(Ur),
- p = a._formatFileSize(o.size),
- g = a._formatSpeed(1e3 * o.size / l),
- h = "size=".concat(p, ",time=").concat(l, "ms,speed=").concat(g);
- return de.log("UploadController.upload success name=".concat(o.name, ",").concat(h)), r(u), void n.setNetworkType(t.getNetworkType()).setText(h).setEnd();
- }
- var d = new Ut({
- code: qt.MESSAGE_FILE_UPLOAD_FAIL,
- message: cn
- });
- n.setError(d, !0, a.getNetworkType()).setEnd(), de.warn("UploadController.upload failed, error:", e), 403 === e.statusCode && (de.warn("UploadController.upload failed. cos AccessKeyId was invalid, regain auth key!"), t._getAuthorizationKey()), i(d);
- });
- });
- }
- }, {
- key: "_formatFileSize",
- value: function (e) {
- return e < 1024 ? e + "B" : e < 1048576 ? Math.floor(e / 1024) + "KB" : Math.floor(e / 1048576) + "MB";
- }
- }, {
- key: "_formatSpeed",
- value: function (e) {
- return e <= 1048576 ? (e / 1024).toFixed(1) + "KB/s" : (e / 1048576).toFixed(1) + "MB/s";
- }
- }, {
- key: "_createCosOptionsWeb",
- value: function (e) {
- var t = this.tim.context.identifier,
- n = this._genFileName(t, e.to, e.file.files[0].name);
- return {
- files: [{
- Bucket: "".concat(this.bucketName, "-").concat(this.appid),
- Region: this.region,
- Key: "".concat(this.directory, "/").concat(n),
- Body: e.file.files[0]
- }],
- SliceSize: 1048576,
- onProgress: function (t) {
- if ("function" == typeof e.onProgress) try {
- e.onProgress(t.percent);
- } catch (n) {
- de.warn("onProgress callback error:", n), de.error(n);
- }
- },
- onFileFinish: function (e, t, n) {}
- };
- }
- }, {
- key: "_createCosOptionsWXMiniApp",
- value: function (e) {
- var t = this.tim.context.identifier,
- n = this._genFileName(t, e.to, e.file.name),
- o = e.file.url;
- return {
- Bucket: "".concat(this.bucketName, "-").concat(this.appid),
- Region: this.region,
- Key: "".concat(this.directory, "/").concat(n),
- FilePath: o,
- onProgress: function (t) {
- if (de.log(JSON.stringify(t)), "function" == typeof e.onProgress) try {
- e.onProgress(t.percent);
- } catch (n) {
- de.warn("onProgress callback error:", n), de.error(n);
- }
- }
- };
- }
- }, {
- key: "_genFileName",
- value: function (e, t, n) {
- return "".concat(e, "-").concat(t, "-").concat(we(99999), "-").concat(n);
- }
- }, {
- key: "reset",
- value: function () {
- this._timer && (clearInterval(this._timer), this._timer = 0);
- }
- }]), n;
- }(mr),
- Fs = function (e) {
- c(r, e);
- var n = v(r);
- function r(e) {
- var t;
- return o(this, r), (t = n.call(this, e)).FILETYPE = {
- SOUND: 2106,
- FILE: 2107,
- VIDEO: 2113
- }, t._bdh_download_server = "grouptalk.c2c.qq.com", t._BDHBizID = 10001, t._authKey = "", t._expireTime = 0, t.tim.innerEmitter.on(Mo, t._getAuthKey, f(t)), t;
- }
- return i(r, [{
- key: "_getAuthKey",
- value: function () {
- var e = this;
- this.request({
- name: "bigDataHallwayAuthKey",
- action: "query"
- }).then(function (t) {
- t.data.authKey && (e._authKey = t.data.authKey, e._expireTime = parseInt(t.data.expireTime));
- });
- }
- }, {
- key: "_isFromOlderVersion",
- value: function (e) {
- return 2 !== e.content.downloadFlag;
- }
- }, {
- key: "parseElements",
- value: function (e, t) {
- if (!Ie(e) || !t) return [];
- for (var n = [], o = null, r = 0; r < e.length; r++) o = e[r], this._needParse(o) ? n.push(this._parseElement(o, t)) : n.push(e[r]);
- return n;
- }
- }, {
- key: "_needParse",
- value: function (e) {
- return !(!this._isFromOlderVersion(e) || e.type !== t.MSG_AUDIO && e.type !== t.MSG_FILE && e.type !== t.MSG_VIDEO);
- }
- }, {
- key: "_parseElement",
- value: function (e, n) {
- switch (e.type) {
- case t.MSG_AUDIO:
- return this._parseAudioElement(e, n);
- case t.MSG_FILE:
- return this._parseFileElement(e, n);
- case t.MSG_VIDEO:
- return this._parseVideoElement(e, n);
- }
- }
- }, {
- key: "_parseAudioElement",
- value: function (e, t) {
- return e.content.url = this._genAudioUrl(e.content.uuid, t), e;
- }
- }, {
- key: "_parseFileElement",
- value: function (e, t) {
- return e.content.url = this._genFileUrl(e.content.uuid, t, e.content.fileName), e;
- }
- }, {
- key: "_parseVideoElement",
- value: function (e, t) {
- return e.content.url = this._genVideoUrl(e.content.uuid, t), e;
- }
- }, {
- key: "_genAudioUrl",
- value: function (e, t) {
- return "" === this._authKey ? (de.warn("BigDataHallwayController._genAudioUrl no authKey!"), "") : "https://".concat(this._bdh_download_server, "/asn.com/stddownload_common_file?authkey=").concat(this._authKey, "&bid=").concat(this._BDHBizID, "&subbid=").concat(this.tim.context.SDKAppID, "&fileid=").concat(e, "&filetype=").concat(this.FILETYPE.SOUND, "&openid=").concat(t, "&ver=0");
- }
- }, {
- key: "_genFileUrl",
- value: function (e, t, n) {
- return "" === this._authKey ? (de.warn("BigDataHallwayController._genFileUrl no authKey!"), "") : (n || (n = "".concat(Math.floor(1e5 * Math.random()), "-").concat(Date.now())), "https://".concat(this._bdh_download_server, "/asn.com/stddownload_common_file?authkey=").concat(this._authKey, "&bid=").concat(this._BDHBizID, "&subbid=").concat(this.tim.context.SDKAppID, "&fileid=").concat(e, "&filetype=").concat(this.FILETYPE.FILE, "&openid=").concat(t, "&ver=0&filename=").concat(encodeURIComponent(n)));
- }
- }, {
- key: "_genVideoUrl",
- value: function (e, t) {
- return "" === this._authKey ? (de.warn("BigDataHallwayController._genVideoUrl no authKey!"), "") : "https://".concat(this._bdh_download_server, "/asn.com/stddownload_common_file?authkey=").concat(this._authKey, "&bid=").concat(this._BDHBizID, "&subbid=").concat(this.tim.context.SDKAppID, "&fileid=").concat(e, "&filetype=").concat(this.FILETYPE.VIDEO, "&openid=").concat(t, "&ver=0");
- }
- }, {
- key: "reset",
- value: function () {
- this._authKey = "", this.expireTime = 0;
- }
- }]), r;
- }(mr);
- var xs = {
- app_id: "",
- event_id: "",
- api_base: "https://pingtas.qq.com/pingd",
- prefix: "_mta_",
- version: "1.3.9",
- stat_share_app: !1,
- stat_pull_down_fresh: !1,
- stat_reach_bottom: !1,
- stat_param: !0
- };
- function Vs() {
- try {
- var e = "s" + Ks();
- return uni.setStorageSync(xs.prefix + "ssid", e), e;
- } catch (t) {}
- }
- function Ks(e) {
- for (var t = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], n = 10; 1 < n; n--) {
- var o = Math.floor(10 * Math.random()),
- r = t[o];
- t[o] = t[n - 1], t[n - 1] = r;
- }
- for (n = o = 0; 5 > n; n++) o = 10 * o + t[n];
- return (e || "") + (o + "") + +new Date();
- }
- function Hs() {
- try {
- var e = getCurrentPages(),
- t = "/";
- return 0 < e.length && (t = e.pop().__route__), t;
- } catch (n) {
- console.log("get current page path error:" + n);
- }
- }
- function Bs() {
- var e,
- t = {
- dm: "wechat.apps.xx",
- url: encodeURIComponent(Hs() + Ys(zs.Data.pageQuery)),
- pvi: "",
- si: "",
- ty: 0
- };
- return t.pvi = ((e = function () {
- try {
- return uni.getStorageSync(xs.prefix + "auid");
- } catch (t) {}
- }()) || (e = function () {
- try {
- var t = Ks();
- return uni.setStorageSync(xs.prefix + "auid", t), t;
- } catch (e) {}
- }(), t.ty = 1), e), t.si = function () {
- var e = function () {
- try {
- return uni.getStorageSync(xs.prefix + "ssid");
- } catch (e) {}
- }();
- return e || (e = Vs()), e;
- }(), t;
- }
- function js() {
- var e = function () {
- var e = uni.getSystemInfoSync();
- return {
- adt: encodeURIComponent(e.model),
- scl: e.pixelRatio,
- scr: e.windowWidth + "x" + e.windowHeight,
- lg: e.language,
- fl: e.version,
- jv: encodeURIComponent(e.system),
- tz: encodeURIComponent(e.platform)
- };
- }();
- return function (e) {
- uni.getNetworkType({
- success: function (t) {
- e(t.networkType);
- }
- });
- }(function (e) {
- try {
- uni.setStorageSync(xs.prefix + "ntdata", e);
- } catch (t) {}
- }), e.ct = uni.getStorageSync(xs.prefix + "ntdata") || "4g", e;
- }
- function $s() {
- var e,
- t = zs.Data.userInfo,
- n = [];
- for (e in t) t.hasOwnProperty(e) && n.push(e + "=" + t[e]);
- return t = n.join(";"), {
- r2: xs.app_id,
- r4: "wx",
- ext: "v=" + xs.version + (null !== t && "" !== t ? ";ui=" + encodeURIComponent(t) : "")
- };
- }
- function Ys(e) {
- if (!xs.stat_param || !e) return "";
- e = function (e) {
- if (1 > xs.ignore_params.length) return e;
- var t,
- n = {};
- for (t in e) 0 <= xs.ignore_params.indexOf(t) || (n[t] = e[t]);
- return n;
- }(e);
- var t,
- n = [];
- for (t in e) n.push(t + "=" + e[t]);
- return 0 < n.length ? "?" + n.join("&") : "";
- }
- var zs = {
- App: {
- init: function (e) {
- "appID" in e && (xs.app_id = e.appID), "eventID" in e && (xs.event_id = e.eventID), "statShareApp" in e && (xs.stat_share_app = e.statShareApp), "statPullDownFresh" in e && (xs.stat_pull_down_fresh = e.statPullDownFresh), "statReachBottom" in e && (xs.stat_reach_bottom = e.statReachBottom), "ignoreParams" in e && (xs.ignore_params = e.ignoreParams), "statParam" in e && (xs.stat_param = e.statParam), Vs();
- try {
- "lauchOpts" in e && (zs.Data.lanchInfo = e.lauchOpts, zs.Data.lanchInfo.landing = 1);
- } catch (t) {}
- "autoReport" in e && e.autoReport && function () {
- var e = Page;
- Page = function (t) {
- var n = t.onLoad;
- t.onLoad = function (e) {
- n && n.call(this, e), zs.Data.lastPageQuery = zs.Data.pageQuery, zs.Data.pageQuery = e, zs.Data.lastPageUrl = zs.Data.pageUrl, zs.Data.pageUrl = Hs(), zs.Data.show = !1, zs.Page.init();
- }, e(t);
- };
- }();
- }
- },
- Page: {
- init: function () {
- var e,
- t = getCurrentPages()[getCurrentPages().length - 1];
- t.onShow && (e = t.onShow, t.onShow = function () {
- if (!0 === zs.Data.show) {
- var t = zs.Data.lastPageQuery;
- zs.Data.lastPageQuery = zs.Data.pageQuery, zs.Data.pageQuery = t, zs.Data.lastPageUrl = zs.Data.pageUrl, zs.Data.pageUrl = Hs();
- }
- zs.Data.show = !0, zs.Page.stat(), e.apply(this, arguments);
- }), xs.stat_pull_down_fresh && t.onPullDownRefresh && function () {
- var e = t.onPullDownRefresh;
- t.onPullDownRefresh = function () {
- zs.Event.stat(xs.prefix + "pulldownfresh", {
- url: t.__route__
- }), e.apply(this, arguments);
- };
- }(), xs.stat_reach_bottom && t.onReachBottom && function () {
- var e = t.onReachBottom;
- t.onReachBottom = function () {
- zs.Event.stat(xs.prefix + "reachbottom", {
- url: t.__route__
- }), e.apply(this, arguments);
- };
- }(), xs.stat_share_app && t.onShareAppMessage && function () {
- var e = t.onShareAppMessage;
- t.onShareAppMessage = function () {
- return zs.Event.stat(xs.prefix + "shareapp", {
- url: t.__route__
- }), e.apply(this, arguments);
- };
- }();
- },
- multiStat: function (e, t) {
- if (1 == t) zs.Page.stat(e);else {
- var n = getCurrentPages()[getCurrentPages().length - 1];
- n.onShow && function () {
- var t = n.onShow;
- n.onShow = function () {
- zs.Page.stat(e), t.call(this, arguments);
- };
- }();
- }
- },
- stat: function (e) {
- if ("" != xs.app_id) {
- var t = [],
- n = $s();
- if (e && (n.r2 = e), e = [Bs(), n, js()], zs.Data.lanchInfo) {
- e.push({
- ht: zs.Data.lanchInfo.scene
- }), zs.Data.pageQuery && zs.Data.pageQuery._mta_ref_id && e.push({
- rarg: zs.Data.pageQuery._mta_ref_id
- });
- try {
- 1 == zs.Data.lanchInfo.landing && (n.ext += ";lp=1", zs.Data.lanchInfo.landing = 0);
- } catch (i) {}
- }
- e.push({
- rdm: "/",
- rurl: 0 >= zs.Data.lastPageUrl.length ? zs.Data.pageUrl + Ys(zs.Data.lastPageQuery) : encodeURIComponent(zs.Data.lastPageUrl + Ys(zs.Data.lastPageQuery))
- }), e.push({
- rand: +new Date()
- }), n = 0;
- for (var o = e.length; n < o; n++) for (var r in e[n]) e[n].hasOwnProperty(r) && t.push(r + "=" + (void 0 === e[n][r] ? "" : e[n][r]));
- uni.request({
- url: xs.api_base + "?" + t.join("&").toLowerCase()
- });
- }
- }
- },
- Event: {
- stat: function (e, t) {
- if ("" != xs.event_id) {
- var n = [],
- o = Bs(),
- r = $s();
- o.dm = "wxapps.click", o.url = e, r.r2 = xs.event_id;
- var i,
- s = void 0 === t ? {} : t,
- a = [];
- for (i in s) s.hasOwnProperty(i) && a.push(encodeURIComponent(i) + "=" + encodeURIComponent(s[i]));
- for (s = a.join(";"), r.r5 = s, s = 0, r = (o = [o, r, js(), {
- rand: +new Date()
- }]).length; s < r; s++) for (var u in o[s]) o[s].hasOwnProperty(u) && n.push(u + "=" + (void 0 === o[s][u] ? "" : o[s][u]));
- uni.request({
- url: xs.api_base + "?" + n.join("&").toLowerCase()
- });
- }
- }
- },
- Data: {
- userInfo: null,
- lanchInfo: null,
- pageQuery: null,
- lastPageQuery: null,
- pageUrl: "",
- lastPageUrl: "",
- show: !1
- }
- },
- Ws = zs,
- Js = function () {
- function e() {
- o(this, e);
- try {
- Ws.App.init({
- appID: "500690995",
- eventID: "500691014",
- autoReport: !1,
- statParam: !0
- });
- } catch (t) {}
- }
- return i(e, [{
- key: "report",
- value: function (e, t) {
- try {
- Ws.Event.stat(e, t);
- } catch (n) {}
- }
- }, {
- key: "stat",
- value: function () {
- try {
- Ws.Page.stat();
- } catch (e) {}
- }
- }]), e;
- }(),
- Xs = function (e) {
- c(n, e);
- var t = v(n);
- function n(e) {
- var r;
- o(this, n), (r = t.call(this, e)).MTA = new Js();
- var i = r.tim.innerEmitter;
- return i.on(ar, r._stat, f(r)), i.on(sr, r._stat, f(r)), r;
- }
- return i(n, [{
- key: "_stat",
- value: function () {
- this.MTA.report("sdkappid", {
- value: this.tim.context.SDKAppID
- }), this.MTA.report("version", {
- value: "2.9.1"
- }), this.MTA.stat();
- }
- }]), n;
- }(mr),
- Qs = function () {
- function e(t) {
- o(this, e), this._table = "timwebii", this._report = [];
- }
- return i(e, [{
- key: "pushIn",
- value: function (e) {
- de.debug("SSOLogBody.pushIn", this._report.length, e), this._report.push(e);
- }
- }, {
- key: "backfill",
- value: function (e) {
- var t;
- Ie(e) && 0 !== e.length && (de.debug("SSOLogBody.backfill", this._report.length, e.length), (t = this._report).unshift.apply(t, I(e)));
- }
- }, {
- key: "getLogsNumInMemory",
- value: function () {
- return this._report.length;
- }
- }, {
- key: "isEmpty",
- value: function () {
- return 0 === this._report.length;
- }
- }, {
- key: "_reset",
- value: function () {
- this._report.length = 0, this._report = [];
- }
- }, {
- key: "getTable",
- value: function () {
- return this._table;
- }
- }, {
- key: "getLogsInMemory",
- value: function () {
- var e = this._report.slice();
- return this._reset(), e;
- }
- }]), e;
- }(),
- Zs = function (e) {
- c(n, e);
- var t = v(n);
- function n(e) {
- var r;
- return o(this, n), (r = t.call(this, e)).TAG = "im-ssolog-event", r._reportBody = new Qs(), r._version = "2.9.1", r.MIN_THRESHOLD = 20, r.MAX_THRESHOLD = 100, r.WAITING_TIME = 6e4, r.INTERVAL = 2e4, r._timerID = 0, r._resetLastReportTime(), r._startReportTimer(), r._retryCount = 0, r.MAX_RETRY_COUNT = 3, r.tim.innerEmitter.on(Jo, r._onLoginSuccess, f(r)), r;
- }
- return i(n, [{
- key: "reportAtOnce",
- value: function () {
- de.debug("EventStatController.reportAtOnce"), this._report();
- }
- }, {
- key: "_onLoginSuccess",
- value: function () {
- var e = this,
- t = this.tim.storage,
- n = t.getItem(this.TAG, !1);
- !Xe(n) && Ee(n.forEach) && (de.log("EventStatController._onLoginSuccess get ssolog in storage, nums=" + n.length), n.forEach(function (t) {
- e._reportBody.pushIn(t);
- }), t.removeItem(this.TAG, !1));
- }
- }, {
- key: "pushIn",
- value: function (e) {
- e instanceof qr && (e.setCommonInfo({
- SDKAppID: this.tim.context.SDKAppID,
- version: this._version,
- tinyID: this.tim.context.tinyID,
- userID: this.tim.loginInfo.identifier,
- platform: this.getPlatform(),
- scene: this.tim.context.scene,
- instanceID: this.tim.context.instanceID
- }), this._reportBody.pushIn(e), this._reportBody.getLogsNumInMemory() >= this.MIN_THRESHOLD && this._report());
- }
- }, {
- key: "_resetLastReportTime",
- value: function () {
- this._lastReportTime = Date.now();
- }
- }, {
- key: "_startReportTimer",
- value: function () {
- var e = this;
- this._timerID = setInterval(function () {
- Date.now() < e._lastReportTime + e.WAITING_TIME || e._reportBody.isEmpty() || e._report();
- }, this.INTERVAL);
- }
- }, {
- key: "_stopReportTimer",
- value: function () {
- this._timerID > 0 && (clearInterval(this._timerID), this._timerID = 0);
- }
- }, {
- key: "_report",
- value: function () {
- var e = this;
- if (!this._reportBody.isEmpty()) {
- var t = this._reportBody.getLogsInMemory();
- this.request({
- name: "ssoEventStat",
- action: "create",
- param: {
- table: this._reportBody.getTable(),
- report: t
- }
- }).then(function () {
- e._resetLastReportTime(), e._retryCount > 0 && (de.debug("EventStatController.report retry success"), e._retryCount = 0);
- }).catch(function (n) {
- if (de.warn("EventStatController.report, networkType:".concat(e.getNetworkType(), " error:").concat(Re(n))), e._reportBody.backfill(t), e._reportBody.getLogsNumInMemory() > e.MAX_THRESHOLD || e._retryCount === e.MAX_RETRY_COUNT || 0 === e._timerID) return e._retryCount = 0, void e._flushAtOnce();
- e._retryCount += 1;
- });
- }
- }
- }, {
- key: "_flushAtOnce",
- value: function () {
- var e = this.tim.storage,
- t = e.getItem(this.TAG, !1),
- n = this._reportBody.getLogsInMemory();
- if (Xe(t)) de.log("EventStatController._flushAtOnce nums=" + n.length), e.setItem(this.TAG, n, !0, !1);else {
- var o = n.concat(t);
- o.length > this.MAX_THRESHOLD && (o = o.slice(0, this.MAX_THRESHOLD)), de.log("EventStatController._flushAtOnce nums=" + o.length), e.setItem(this.TAG, o, !0, !1);
- }
- }
- }, {
- key: "reset",
- value: function () {
- de.log("EventStatController.reset"), this._stopReportTimer(), this._report();
- }
- }]), n;
- }(mr),
- ea = "none",
- ta = "online",
- na = function () {
- function e() {
- o(this, e), this._networkType = "", this.maxWaitTime = 3e3;
- }
- return i(e, [{
- key: "start",
- value: function () {
- var e = this;
- V ? (K.getNetworkType({
- success: function (t) {
- e._networkType = t.networkType, t.networkType === ea ? de.warn("NetMonitor no network, please check!") : de.info("NetMonitor networkType:".concat(t.networkType));
- }
- }), K.onNetworkStatusChange(this._onNetworkStatusChange.bind(this))) : this._networkType = ta;
- }
- }, {
- key: "_onNetworkStatusChange",
- value: function (e) {
- this._networkType = e.networkType, e.isConnected ? de.info("NetMonitor networkType:".concat(e.networkType)) : de.warn("NetMonitor no network, please check!");
- }
- }, {
- key: "probe",
- value: function () {
- var e = this;
- return new Promise(function (t, n) {
- if (V) K.getNetworkType({
- success: function (n) {
- e._networkType = n.networkType, n.networkType === ea ? (de.warn("NetMonitor no network, please check!"), t([!1, n.networkType])) : (de.info("NetMonitor networkType:".concat(n.networkType)), t([!0, n.networkType]));
- }
- });else if (window && window.fetch) fetch("".concat(qe(), "//webim-1252463788.file.myqcloud.com/assets/test/speed.xml?random=").concat(Math.random())).then(function (e) {
- e.ok ? t([!0, ta]) : t([!1, ea]);
- }).catch(function (e) {
- t([!1, ea]);
- });else {
- var o = new XMLHttpRequest(),
- r = setTimeout(function () {
- de.warn("NetMonitor fetch timeout. Probably no network, please check!"), o.abort(), e._networkType = ea, t([!1, ea]);
- }, e.maxWaitTime);
- o.onreadystatechange = function () {
- 4 === o.readyState && (clearTimeout(r), 200 === o.status || 304 === o.status ? (this._networkType = ta, t([!0, ta])) : (de.warn("NetMonitor fetch status:".concat(o.status, ". Probably no network, please check!")), this._networkType = ea, t([!1, ea])));
- }, o.open("GET", "".concat(qe(), "//webim-1252463788.file.myqcloud.com/assets/test/speed.xml?random=").concat(Math.random())), o.send();
- }
- });
- }
- }, {
- key: "getNetworkType",
- value: function () {
- return this._networkType;
- }
- }, {
- key: "reset",
- value: function () {
- this._networkType = "";
- }
- }]), e;
- }(),
- oa = function () {
- function e(t) {
- var n = this;
- o(this, e), Ie(t) ? (this._map = new Map(), t.forEach(function (e) {
- n._map.set(e, []);
- })) : de.warn("AverageCalculator.constructor need keys");
- }
- return i(e, [{
- key: "push",
- value: function (e, t) {
- return !(Me(e) || !this._map.has(e) || !fe(t)) && (this._map.get(e).push(t), !0);
- }
- }, {
- key: "getSize",
- value: function (e) {
- return Me(e) || !this._map.has(e) ? -1 : this._map.get(e).length;
- }
- }, {
- key: "getAvg",
- value: function (e) {
- if (Me(e) || !this._map.has(e)) return -1;
- var t = this._map.get(e),
- n = t.length;
- if (0 === n) return 0;
- var o = 0;
- return t.forEach(function (e) {
- o += e;
- }), t.length = 0, this._map.set(e, []), parseInt(o / n);
- }
- }, {
- key: "getMax",
- value: function (e) {
- return Me(e) || !this._map.has(e) ? -1 : Math.max.apply(null, this._map.get(e));
- }
- }, {
- key: "getMin",
- value: function (e) {
- return Me(e) || !this._map.has(e) ? -1 : Math.min.apply(null, this._map.get(e));
- }
- }, {
- key: "reset",
- value: function () {
- this._map.forEach(function (e) {
- e.length = 0;
- });
- }
- }]), e;
- }(),
- ra = function () {
- function e(t) {
- var n = this;
- o(this, e), Ie(t) ? (this._map = new Map(), t.forEach(function (e) {
- n._map.set(e, {
- totalCount: 0,
- successCount: 0
- });
- })) : de.warn("SuccessRateCalculator.constructor need keys");
- }
- return i(e, [{
- key: "addTotalCount",
- value: function (e) {
- return !(Me(e) || !this._map.has(e)) && (this._map.get(e).totalCount += 1, !0);
- }
- }, {
- key: "addSuccessCount",
- value: function (e) {
- return !(Me(e) || !this._map.has(e)) && (this._map.get(e).successCount += 1, !0);
- }
- }, {
- key: "getSuccessRate",
- value: function (e) {
- if (Me(e) || !this._map.has(e)) return -1;
- var t = this._map.get(e);
- if (0 === t.totalCount) return 1;
- var n = parseFloat((t.successCount / t.totalCount).toFixed(2));
- return n > 1 && (n = 1), t.totalCount = t.successCount = 0, n;
- }
- }, {
- key: "getTotalCount",
- value: function (e) {
- return Me(e) || !this._map.has(e) ? -1 : this._map.get(e).totalCount;
- }
- }, {
- key: "reset",
- value: function () {
- this._map.forEach(function (e) {
- e.totalCount = 0, e.successCount = 0;
- });
- }
- }]), e;
- }(),
- ia = function (e) {
- c(n, e);
- var t = v(n);
- function n(e) {
- var r;
- return o(this, n), (r = t.call(this, e)).TABLE = "timwebsum", r.TAG = "im-ssolog-sumstat", r._items = [Dr, Sr, kr, Ar, Or, Rr, Nr, Lr, wr, Pr], r._thresholdMap = new Map(), r._thresholdMap.set(Dr, 100), r._thresholdMap.set(Sr, 150), r._thresholdMap.set(kr, 15), r._thresholdMap.set(Ar, 6), r._thresholdMap.set(Or, 6), r._thresholdMap.set(Rr, 6), r._thresholdMap.set(Nr, 6), r._thresholdMap.set(Lr, 6), r._thresholdMap.set(wr, 50), r._thresholdMap.set(Pr, 50), r._lpID = "", r._platform = r.getPlatform(), r._lastReportTime = 0, r._statInfoArr = [], r._retryCount = 0, r._avgCalc = new oa(r._items), r._successRateCalc = new ra(r._items), r.tim.innerEmitter.on(Jo, r._onLoginSuccess, f(r)), r;
- }
- return i(n, [{
- key: "_onLoginSuccess",
- value: function () {
- var e = this,
- t = this.tim.storage,
- n = t.getItem(this.TAG, !1);
- !Xe(n) && Ee(n.forEach) && (de.log("SumStatController._onLoginSuccess get sumstatlog in storage, nums=" + n.length), n.forEach(function (t) {
- e._statInfoArr.push(t);
- }), t.removeItem(this.TAG, !1));
- }
- }, {
- key: "recordLongPollingID",
- value: function (e) {
- this._lpID = e;
- }
- }, {
- key: "addTotalCount",
- value: function (e) {
- this._successRateCalc.addTotalCount(e) ? 1 === this._successRateCalc.getTotalCount(e) && (this._lastReportTime = Date.now()) : de.warn("SumStatController.addTotalCount invalid key:", e);
- }
- }, {
- key: "addSuccessCount",
- value: function (e) {
- this._successRateCalc.addSuccessCount(e) || de.warn("SumStatController.addSuccessCount invalid key:", e);
- }
- }, {
- key: "addCost",
- value: function (e, t) {
- this._avgCalc.push(e, t) ? (de.debug("SumStatController.addCost", e, t, this._avgCalc.getSize(e)), this._avgCalc.getSize(e) >= this._thresholdMap.get(e) && this._report(e)) : de.warn("SumStatController.addCost invalid key or cost:", e, t);
- }
- }, {
- key: "_getItemNum",
- value: function (e) {
- switch (e) {
- case Dr:
- return 1;
- case Sr:
- return 2;
- case kr:
- return 3;
- case wr:
- return 4;
- case Pr:
- return 5;
- case Ar:
- return 6;
- case Or:
- return 7;
- case Rr:
- return 8;
- case Nr:
- return 9;
- case Lr:
- return 10;
- default:
- return 100;
- }
- }
- }, {
- key: "_getStatInfo",
- value: function (e) {
- var t = null;
- return this._avgCalc.getSize(e) > 0 && (t = {
- SDKAppID: "".concat(this.tim.context.SDKAppID),
- version: "".concat("2.9.1"),
- tinyID: this.tim.context.tinyID,
- userID: this.tim.loginInfo.identifier,
- item: this._getItemNum(e),
- lpID: e === Dr ? this._lpID : "",
- platform: this._platform,
- scene: this.tim.context.scene,
- networkType: this.getNetworkType(),
- total: this._successRateCalc.getTotalCount(e),
- successRate: this._successRateCalc.getSuccessRate(e),
- avg: this._avgCalc.getAvg(e),
- timespan: Date.now() - this._lastReportTime,
- time: Ne()
- }), t;
- }
- }, {
- key: "_report",
- value: function (e) {
- var t = this,
- n = [],
- o = null;
- Me(e) ? this._items.forEach(function (e) {
- null !== (o = t._getStatInfo(e)) && n.push(o);
- }) : null !== (o = this._getStatInfo(e)) && n.push(o), de.debug("SumStatController._report", n), this._statInfoArr.length > 0 && (n = n.concat(this.statInfoArr), this._statInfoArr = []), this._doReport(n);
- }
- }, {
- key: "_doReport",
- value: function (e) {
- var t = this;
- Xe(e) ? de.warn("SumStatController._doReport statInfoArr is empty, do nothing") : this.request({
- name: "ssoSumStat",
- action: "create",
- param: {
- table: this.TABLE,
- report: e
- }
- }).then(function () {
- t._lastReportTime = Date.now(), t._retryCount > 0 && (de.debug("SumStatController._doReport retry success"), t._retryCount = 0);
- }).catch(function (n) {
- de.warn("SumStatController._doReport, online:".concat(t.getNetworkType(), " error:").concat(Re(n)), e), t._retryCount <= 1 ? setTimeout(function () {
- de.info("SumStatController._doReport retry", e), t._retryCount += 1, t._doReport(e);
- }, 5e3) : (t._retryCount = 0, t._statInfoArr = t._statInfoArr.concat(e), t._flushAtOnce());
- });
- }
- }, {
- key: "_flushAtOnce",
- value: function () {
- var e = this.tim.storage,
- t = e.getItem(this.TAG, !1),
- n = this._statInfoArr;
- if (Xe(t)) de.log("SumStatController._flushAtOnce nums=" + n.length), e.setItem(this.TAG, n, !0, !1);else {
- var o = n.concat(t);
- o.length > 10 && (o = o.slice(0, 10)), de.log("SumStatController._flushAtOnce nums=" + o.length), e.setItem(this.TAG, o, !0, !1);
- }
- this._statInfoArr = [];
- }
- }, {
- key: "reset",
- value: function () {
- de.info("SumStatController.reset"), this._report(), this._avgCalc.reset(), this._successRateCalc.reset();
- }
- }]), n;
- }(mr),
- sa = function () {
- function t() {
- o(this, t), this._funcMap = new Map();
- }
- return i(t, [{
- key: "defense",
- value: function (e, t) {
- var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : void 0;
- if ("string" != typeof e) return null;
- if (0 === e.length) return null;
- if ("function" != typeof t) return null;
- if (this._funcMap.has(e) && this._funcMap.get(e).has(t)) return this._funcMap.get(e).get(t);
- this._funcMap.has(e) || this._funcMap.set(e, new Map());
- var o = null;
- return this._funcMap.get(e).has(t) ? o = this._funcMap.get(e).get(t) : (o = this._pack(e, t, n), this._funcMap.get(e).set(t, o)), o;
- }
- }, {
- key: "defenseOnce",
- value: function (e, t) {
- var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : void 0;
- return "function" != typeof t ? null : this._pack(e, t, n);
- }
- }, {
- key: "find",
- value: function (e, t) {
- return "string" != typeof e || 0 === e.length || "function" != typeof t ? null : this._funcMap.has(e) ? this._funcMap.get(e).has(t) ? this._funcMap.get(e).get(t) : (de.log("SafetyCallback.find: 找不到 func —— ".concat(e, "/").concat("" !== t.name ? t.name : "[anonymous]")), null) : (de.log("SafetyCallback.find: 找不到 eventName-".concat(e, " 对应的 func")), null);
- }
- }, {
- key: "delete",
- value: function (e, t) {
- return "function" == typeof t && !!this._funcMap.has(e) && !!this._funcMap.get(e).has(t) && (this._funcMap.get(e).delete(t), 0 === this._funcMap.get(e).size && this._funcMap.delete(e), !0);
- }
- }, {
- key: "_pack",
- value: function (t, n, o) {
- return function () {
- try {
- n.apply(o, Array.from(arguments));
- } catch (a) {
- var r = Object.values(e).indexOf(t);
- if (-1 !== r) {
- var i = Object.keys(e)[r];
- de.warn("接入侧事件 TIM.EVENT.".concat(i, " 对应的回调函数逻辑存在问题,请检查!"), a);
- }
- var s = new qr(Hi);
- s.setText("eventName=".concat(t)).setMessage(a.message).setEnd();
- }
- };
- }
- }]), t;
- }(),
- aa = function (e) {
- c(n, e);
- var t = v(n);
- function n(e) {
- var r;
- return o(this, n), (r = t.call(this, e))._maybeLostSequencesMap = new Map(), r;
- }
- return i(n, [{
- key: "onMessageMaybeLost",
- value: function (e, t, n) {
- this._maybeLostSequencesMap.has(e) || this._maybeLostSequencesMap.set(e, []);
- for (var o = this._maybeLostSequencesMap.get(e), r = 0; r < n; r++) o.push(t + r);
- de.debug("MessageLossController.onMessageMaybeLost. maybeLostSequences:".concat(o));
- }
- }, {
- key: "detectMessageLoss",
- value: function (e, t) {
- var n = this._maybeLostSequencesMap.get(e);
- if (!Xe(n) && !Xe(t)) {
- var o = t.filter(function (e) {
- return -1 !== n.indexOf(e);
- });
- if (de.debug("MessageLossController.detectMessageLoss. matchedSequences:".concat(o)), n.length === o.length) de.info("MessageLossController.detectMessageLoss no message loss. conversationID=".concat(e));else {
- var r,
- i = n.filter(function (e) {
- return -1 === o.indexOf(e);
- }),
- s = i.length;
- s <= 5 ? r = e + "-" + i.join("-") : (i.sort(function (e, t) {
- return e - t;
- }), r = e + " start:" + i[0] + " end:" + i[s - 1] + " count:" + s), new qr(Gi).setText(r).setNetworkType(this.getNetworkType()).setEnd(), de.warn("MessageLossController.detectMessageLoss message loss detected. conversationID:".concat(e, " lostSequences:").concat(i));
- }
- n.length = 0;
- }
- }
- }, {
- key: "reset",
- value: function () {
- de.log("MessageLossController.reset"), this._maybeLostSequencesMap.clear();
- }
- }]), n;
- }(mr),
- ua = function (e) {
- c(r, e);
- var n = v(r);
- function r(e) {
- var t;
- return o(this, r), (t = n.call(this, e))._request = V ? new Yi() : new $i(), t;
- }
- return i(r, [{
- key: "sendMessage",
- value: function (e) {
- var t = this,
- n = this._constructMessageInstance(e);
- if (null === n) return Cr({
- code: qt.MESSAGE_SEND_FAIL,
- message: Yt
- });
- var o = Date.now(),
- r = Xe(e.GroupId) ? "openim/sendmsg" : "group_open_http_svc/send_group_msg",
- i = this.tim.context,
- s = i.a2Key,
- a = i.tinyID,
- u = i.SDKAppID,
- c = i.identifier,
- l = {
- url: "https://" + (!0 === this.tim.context.oversea ? "api.im.qcloud.com" : "webim.tim.qq.com") + "/v4/" + r + "?platform=10&websdkappid=537048168&v=1.7.3&a2=" + s + "&tinyid=" + a + "&sdkappid=" + u + "&contentType=json&apn=1&reqtime=" + Date.now() + "tjg_id=" + this._generateTjgID(n),
- data: e,
- method: "POST"
- };
- this._addSendMessageTotalCount(n);
- var p = new qr(Wr);
- return p.setText("".concat(this._generateTjgID(n), "-").concat(n.from, "-").concat(n.to, "-").concat(n.getElements().length)), this._request.request(l).then(function (e) {
- var r = e.data,
- i = r.ErrorCode,
- s = r.ErrorInfo;
- if (0 !== i) return p.setCode(i).setMessage(s).setNetworkType(t.getNetworkType()).setEnd(), n.status = rt.FAIL, Cr(new Ut({
- code: i,
- message: s || Yt,
- data: {
- message: n
- }
- }));
- t._addSendMessageSuccessCount(n, o), n.status = rt.SUCCESS;
- var a = e.data,
- u = a.MsgTime,
- l = a.MsgSeq;
- return n.time = u, l && (n.sequence = l), n.generateMessageID(c), t.tim.messageController.pushToMessageList(n), t.emitInnerEvent(Do, {
- eventDataList: [{
- conversationID: n.conversationID,
- unreadCount: 0,
- type: n.conversationType,
- subType: n.conversationSubType,
- lastMessage: n
- }]
- }), Mr(n);
- }).catch(function (e) {
- return t.probeNetwork().then(function (t) {
- var n = y(t, 2),
- o = n[0],
- r = n[1];
- p.setError(e, o, r).setEnd();
- }), de.warn("ComboMessageController.sendMessage failed. error:", e), n.status = rt.FAIL, Cr(new Ut({
- code: qt.MESSAGE_SEND_FAIL,
- message: Yt,
- data: {
- message: n
- }
- }));
- });
- }
- }, {
- key: "_constructMessageInstance",
- value: function (e) {
- var n = null;
- try {
- var o = this.tim.context.identifier,
- r = {};
- r.currentUser = o, r.from = e.From_Account || o, e.GroupId ? (r.conversationID = "".concat(t.CONV_GROUP).concat(e.GroupId), r.conversationType = t.CONV_GROUP, r.to = e.GroupId) : e.To_Account && (r.conversationID = "".concat(t.CONV_C2C).concat(e.To_Account), r.conversationType = t.CONV_C2C, r.to = e.To_Account), r.time = e.MsgTimeStamp || 0, r.random = e.Random || e.MsgRandom || 0, r.priority = e.MsgPriority, (n = new Qn(r)).status = rt.UNSEND;
- for (var i, s = e.MsgBody.length, a = 0; a < s; a++) "TIMTextElem" === (i = e.MsgBody[a]).MsgType ? n.setTextElement(i.MsgContent.Text) : "TIMCustomElem" === i.MsgType ? n.setCustomElement({
- data: i.MsgContent.Data || "",
- description: i.MsgContent.Desc || "",
- extension: i.MsgContent.Ext || ""
- }) : "TIMFaceElem" === i.MsgType && n.setFaceElement({
- index: i.MsgContent.Index,
- data: i.MsgContent.Data
- });
- var u = n.getElements();
- n.payload = u[0].content, n.type = u[0].type;
- } catch (c) {
- n = null, de.error("ComboMessageController._constructMessageInstance failed. error:", c);
- }
- return n;
- }
- }, {
- key: "_addSendMessageSuccessCount",
- value: function (e, t) {
- var n = this.tim.sumStatController,
- o = Math.abs(Date.now() - t);
- n.addSuccessCount(kr), n.addCost(kr, o);
- var r = this._getSendMessageSpecifiedKey(e);
- r && (n.addSuccessCount(r), n.addCost(r, o));
- }
- }, {
- key: "_addSendMessageTotalCount",
- value: function (e) {
- var t = this.tim.sumStatController;
- t.addTotalCount(kr);
- var n = this._getSendMessageSpecifiedKey(e);
- n && t.addTotalCount(n);
- }
- }, {
- key: "_getSendMessageSpecifiedKey",
- value: function (e) {
- if (e.conversationType === t.CONV_C2C) return Ar;
- if (e.conversationType === t.CONV_GROUP) {
- var n = this.tim.groupController.getLocalGroupProfile(e.to);
- if (!n) return;
- var o = n.type;
- if (Ve(o)) return Or;
- if (Ke(o)) return Rr;
- if (He(o)) return Nr;
- if (Be(o)) return Lr;
- }
- }
- }, {
- key: "_generateTjgID",
- value: function (e) {
- return this.tim.context.tinyID + "-" + e.random;
- }
- }, {
- key: "reset",
- value: function () {
- de.info("ComboMessageController.reset");
- }
- }]), r;
- }(mr),
- ca = function () {
- function t(e) {
- o(this, t);
- var n = new qr(Fr);
- dr.mixin(this), this._initOptions(e), this._initMemberVariables(), this._initControllers(), this._initListener(), qr.bindController(this.eventStatController), n.setText("instanceID=".concat(this.loginInfo.instanceID, "-oversea=").concat(this.loginInfo.oversea, "-mp=").concat(V, "-ua=").concat(B)).setEnd(), de.info("SDK instanceID:".concat(this.loginInfo.instanceID, " oversea:").concat(this.loginInfo.oversea, " inMiniApp:").concat(V, ", SDKAppID:").concat(e.SDKAppID, ", UserAgent:").concat(B)), this._safetyCallbackFactory = new sa();
- }
- return i(t, [{
- key: "login",
- value: function (e) {
- return de.time(Er), this._ssoLog = new qr(xr), this.netMonitor.start(), this.loginInfo.identifier = e.identifier || e.userID, this.loginInfo.userSig = e.userSig, this.signController.login(this.loginInfo);
- }
- }, {
- key: "logout",
- value: function () {
- var e = this.signController.logout();
- return this.resetSDK(), e;
- }
- }, {
- key: "on",
- value: function (t, n, o) {
- t === e.GROUP_SYSTEM_NOTICE_RECEIVED && de.warn("!!!TIM.EVENT.GROUP_SYSTEM_NOTICE_RECEIVED v2.6.0起弃用,为了更好的体验,请在 TIM.EVENT.MESSAGE_RECEIVED 事件回调内接收处理群系统通知,详细请参考:https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/Message.html#.GroupSystemNoticePayload"), de.debug("on", "eventName:".concat(t)), this.outerEmitter.on(t, this._safetyCallbackFactory.defense(t, n, o), o);
- }
- }, {
- key: "once",
- value: function (e, t, n) {
- de.debug("once", "eventName:".concat(e)), this.outerEmitter.once(e, this._safetyCallbackFactory.defenseOnce(e, t, n), n || this);
- }
- }, {
- key: "off",
- value: function (e, t, n, o) {
- de.debug("off", "eventName:".concat(e));
- var r = this._safetyCallbackFactory.find(e, t);
- null !== r && (this.outerEmitter.off(e, r, n, o), this._safetyCallbackFactory.delete(e, t));
- }
- }, {
- key: "registerPlugin",
- value: function (e) {
- var t = this;
- this.plugins || (this.plugins = {}), Object.keys(e).forEach(function (n) {
- t.plugins[n] = e[n];
- }), new qr(jr).setText("key=".concat(Object.keys(e))).setEnd();
- }
- }, {
- key: "getPlugin",
- value: function (e) {
- return this.plugins[e] || void 0;
- }
- }, {
- key: "setLogLevel",
- value: function (e) {
- if (e <= 0) {
- console.log(["", " ________ ______ __ __ __ __ ________ _______", "| \\| \\| \\ / \\| \\ _ | \\| \\| \\", " \\$$$$$$$$ \\$$$$$$| $$\\ / $$| $$ / \\ | $$| $$$$$$$$| $$$$$$$\\", " | $$ | $$ | $$$\\ / $$$| $$/ $\\| $$| $$__ | $$__/ $$", " | $$ | $$ | $$$$\\ $$$$| $$ $$$\\ $$| $$ \\ | $$ $$", " | $$ | $$ | $$\\$$ $$ $$| $$ $$\\$$\\$$| $$$$$ | $$$$$$$\\", " | $$ _| $$_ | $$ \\$$$| $$| $$$$ \\$$$$| $$_____ | $$__/ $$", " | $$ | $$ \\| $$ \\$ | $$| $$$ \\$$$| $$ \\| $$ $$", " \\$$ \\$$$$$$ \\$$ \\$$ \\$$ \\$$ \\$$$$$$$$ \\$$$$$$$", "", ""].join("\n")), console.log("%cIM 智能客服,随时随地解决您的问题 →_→ https://cloud.tencent.com/act/event/smarty-service?from=im-doc", "color:#ff0000");
- console.log(["", "参考以下文档,会更快解决问题哦!(#^.^#)\n", "SDK 更新日志: https://cloud.tencent.com/document/product/269/38492\n", "SDK 接口文档: https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html\n", "常见问题: https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/tutorial-01-faq.html\n", "反馈问题?戳我提 issue: https://github.com/tencentyun/TIMSDK/issues\n", "如果您需要在生产环境关闭上面的日志,请 tim.setLogLevel(1)\n"].join("\n"));
- }
- de.setLevel(e);
- }
- }, {
- key: "destroy",
- value: function () {
- var t = this;
- return this.logout().finally(function () {
- t.outerEmitter.emit(e.SDK_DESTROY, {
- SDKAppID: t.loginInfo.SDKAppID
- });
- });
- }
- }, {
- key: "createTextMessage",
- value: function (e) {
- return this.messageController.createTextMessage(e);
- }
- }, {
- key: "createTextAtMessage",
- value: function (e) {
- return this.messageController.createTextMessage(e);
- }
- }, {
- key: "createImageMessage",
- value: function (e) {
- return this.messageController.createImageMessage(e);
- }
- }, {
- key: "createAudioMessage",
- value: function (e) {
- return this.messageController.createAudioMessage(e);
- }
- }, {
- key: "createVideoMessage",
- value: function (e) {
- return this.messageController.createVideoMessage(e);
- }
- }, {
- key: "createCustomMessage",
- value: function (e) {
- return this.messageController.createCustomMessage(e);
- }
- }, {
- key: "createFaceMessage",
- value: function (e) {
- return this.messageController.createFaceMessage(e);
- }
- }, {
- key: "createFileMessage",
- value: function (e) {
- return this.messageController.createFileMessage(e);
- }
- }, {
- key: "sendMessage",
- value: function (e, t) {
- return e instanceof Qn ? this.messageController.sendMessageInstance(e, t) : Cr(new Ut({
- code: qt.MESSAGE_SEND_NEED_MESSAGE_INSTANCE,
- message: Wt
- }));
- }
- }, {
- key: "callExperimentalAPI",
- value: function (e, t) {
- return "sendComboMessage" === e ? this.comboMessageController.sendMessage(t) : Cr(new Ut({
- code: qt.INVALID_OPERATION,
- message: Hn
- }));
- }
- }, {
- key: "revokeMessage",
- value: function (e) {
- return this.messageController.revokeMessage(e);
- }
- }, {
- key: "resendMessage",
- value: function (e) {
- return this.messageController.resendMessage(e);
- }
- }, {
- key: "getMessageList",
- value: function (e) {
- return this.messageController.getMessageList(e);
- }
- }, {
- key: "setMessageRead",
- value: function (e) {
- return this.messageController.setMessageRead(e);
- }
- }, {
- key: "getConversationList",
- value: function () {
- return this.conversationController.getConversationList();
- }
- }, {
- key: "getConversationProfile",
- value: function (e) {
- return this.conversationController.getConversationProfile(e);
- }
- }, {
- key: "deleteConversation",
- value: function (e) {
- return this.conversationController.deleteConversation(e);
- }
- }, {
- key: "getMyProfile",
- value: function () {
- return this.userController.getMyProfile();
- }
- }, {
- key: "getUserProfile",
- value: function (e) {
- return this.userController.getUserProfile(e);
- }
- }, {
- key: "updateMyProfile",
- value: function (e) {
- return this.userController.updateMyProfile(e);
- }
- }, {
- key: "getFriendList",
- value: function () {
- return this.userController.getFriendList();
- }
- }, {
- key: "deleteFriend",
- value: function (e) {
- return this.userController.deleteFriend(e);
- }
- }, {
- key: "getBlacklist",
- value: function () {
- return this.userController.getBlacklist();
- }
- }, {
- key: "addToBlacklist",
- value: function (e) {
- return this.userController.addBlacklist(e);
- }
- }, {
- key: "removeFromBlacklist",
- value: function (e) {
- return this.userController.deleteBlacklist(e);
- }
- }, {
- key: "getGroupList",
- value: function (e) {
- return this.groupController.getGroupList(e);
- }
- }, {
- key: "getGroupProfile",
- value: function (e) {
- return this.groupController.getGroupProfile(e);
- }
- }, {
- key: "createGroup",
- value: function (e) {
- return this.groupController.createGroup(e);
- }
- }, {
- key: "dismissGroup",
- value: function (e) {
- return this.groupController.dismissGroup(e);
- }
- }, {
- key: "updateGroupProfile",
- value: function (e) {
- return this.groupController.updateGroupProfile(e);
- }
- }, {
- key: "joinGroup",
- value: function (e) {
- return this.groupController.joinGroup(e);
- }
- }, {
- key: "quitGroup",
- value: function (e) {
- return this.groupController.quitGroup(e);
- }
- }, {
- key: "searchGroupByID",
- value: function (e) {
- return this.groupController.searchGroupByID(e);
- }
- }, {
- key: "changeGroupOwner",
- value: function (e) {
- return this.groupController.changeGroupOwner(e);
- }
- }, {
- key: "handleGroupApplication",
- value: function (e) {
- return this.groupController.handleGroupApplication(e);
- }
- }, {
- key: "setMessageRemindType",
- value: function (e) {
- return this.groupController.setMessageRemindType(e);
- }
- }, {
- key: "getGroupMemberList",
- value: function (e) {
- return this.groupController.getGroupMemberList(e);
- }
- }, {
- key: "getGroupMemberProfile",
- value: function (e) {
- return this.groupController.getGroupMemberProfile(e);
- }
- }, {
- key: "getGroupOnlineMemberCount",
- value: function (e) {
- return this.groupController.getGroupOnlineMemberCount(e);
- }
- }, {
- key: "addGroupMember",
- value: function (e) {
- return this.groupController.addGroupMember(e);
- }
- }, {
- key: "deleteGroupMember",
- value: function (e) {
- return this.groupController.deleteGroupMember(e);
- }
- }, {
- key: "setGroupMemberMuteTime",
- value: function (e) {
- return this.groupController.setGroupMemberMuteTime(e);
- }
- }, {
- key: "setGroupMemberRole",
- value: function (e) {
- return this.groupController.setGroupMemberRole(e);
- }
- }, {
- key: "setGroupMemberNameCard",
- value: function (e) {
- return this.groupController.setGroupMemberNameCard(e);
- }
- }, {
- key: "setGroupMemberCustomField",
- value: function (e) {
- return this.groupController.setGroupMemberCustomField(e);
- }
- }, {
- key: "_initOptions",
- value: function (e) {
- this.plugins = {}, this._sdkReloadFlag = !1;
- var t = e.SDKAppID || 0,
- n = we();
- this.context = {
- SDKAppID: t,
- accountType: n
- }, this.loginInfo = {
- SDKAppID: t,
- accountType: n,
- identifier: null,
- userSig: null,
- unlimitedAVChatRoom: e.unlimitedAVChatRoom || !1,
- scene: e.scene || "",
- oversea: e.oversea || !1,
- avchatroomIDList: [],
- instanceID: Ye()
- }, this.options = {
- runLoopNetType: e.runLoopNetType || yt,
- enablePointer: e.enablePointer || !1
- };
- }
- }, {
- key: "_initMemberVariables",
- value: function () {
- this.innerEmitter = new Ns(), this.outerEmitter = new Ns(), Ir(this.outerEmitter), this.packageConfig = new ws(this), this.storage = new Rs(this), this.netMonitor = new na(), this.outerEmitter._emit = this.outerEmitter.emit, this.outerEmitter.emit = function (e, t) {
- var n = arguments[0],
- o = [n, {
- name: arguments[0],
- data: arguments[1]
- }];
- this.outerEmitter._emit.apply(this.outerEmitter, o);
- }.bind(this), this.innerEmitter._emit = this.innerEmitter.emit, this.innerEmitter.emit = function (e, t) {
- var n;
- ye(arguments[1]) && arguments[1].data ? (de.warn("inner eventData has data property, please check!"), n = [e, {
- name: arguments[0],
- data: arguments[1].data
- }]) : n = [e, {
- name: arguments[0],
- data: arguments[1]
- }], this.innerEmitter._emit.apply(this.innerEmitter, n);
- }.bind(this);
- }
- }, {
- key: "_initControllers",
- value: function () {
- this.exceptionController = new Qi(this), this.connectionController = new Xi(this), this.contextController = new _r(this), this.context = this.contextController.getContext(), this.signController = new ji(this), this.messageController = new Is(this), this.comboMessageController = new ua(this), this.conversationController = new hs(this), this.userController = new as(this), this.groupController = new ks(this), this.notificationController = new Us(this), this.bigDataHallwayController = new Fs(this), this.statusController = new As(this), this.uploadController = new qs(this), this.messageLossController = new aa(this), this.eventStatController = new Zs(this), this.sumStatController = new ia(this), this.mtaReportController = new Xs(this), this._initReadyListener();
- }
- }, {
- key: "_initListener",
- value: function () {
- var e = this;
- if (this.innerEmitter.on(ur, this._onSDKReload, this), V && "function" == typeof K.onAppShow && "function" == typeof K.onAppHide) {
- var t = null;
- K.onAppHide(function () {
- t = new qr(Ki);
- }), K.onAppShow(function () {
- null !== t && t.setNetworkType(e.netMonitor.getNetworkType()).setEnd();
- });
- }
- }
- }, {
- key: "_initReadyListener",
- value: function () {
- for (var e = this, t = this.readyList, n = 0, o = t.length; n < o; n++) this[t[n]].ready(function () {
- return e._readyHandle();
- });
- }
- }, {
- key: "_onSDKReload",
- value: function () {
- var e = this;
- de.log("sdk reloading..."), this.resetSDK(), this.login(this.loginInfo).then(function (t) {
- e._sdkReloadFlag = !0;
- });
- }
- }, {
- key: "resetSDK",
- value: function () {
- var t = this;
- this.initList.forEach(function (e) {
- t[e].reset && t[e].reset();
- }), this.netMonitor.reset(), this.storage.reset(), this.resetReady(), this._initReadyListener(), this.outerEmitter.emit(e.SDK_NOT_READY);
- }
- }, {
- key: "_readyHandle",
- value: function () {
- for (var t = this.readyList, n = !0, o = 0, r = t.length; o < r; o++) if (!this[t[o]].isReady()) {
- n = !1;
- break;
- }
- if (n) {
- var i = de.timeEnd(Er);
- de.warn("SDK is ready. cost=".concat(i, "ms")), this.triggerReady(), this.innerEmitter.emit(ar), this.outerEmitter.emit(e.SDK_READY), this._sdkReloadFlag && (this.outerEmitter.emit(e.SDK_RELOAD), this.groupController.AVChatRoomHandler.joinAVChatRoomSilently(), this._sdkReloadFlag = !1), this._ssoLog.setNetworkType(this.netMonitor.getNetworkType()).setText(i).setEnd();
- }
- }
- }]), t;
- }();
- ca.prototype.readyList = ["conversationController"], ca.prototype.initList = ["exceptionController", "connectionController", "signController", "contextController", "messageController", "comboMessageController", "conversationController", "userController", "groupController", "notificationController", "eventStatController", "sumStatController", "messageLossController", "statusController"];
- var la = {
- login: "login",
- logout: "logout",
- destroy: "destroy",
- on: "on",
- off: "off",
- ready: "ready",
- setLogLevel: "setLogLevel",
- joinGroup: "joinGroup",
- quitGroup: "quitGroup",
- registerPlugin: "registerPlugin",
- getGroupOnlineMemberCount: "getGroupOnlineMemberCount"
- };
- function pa(e, t) {
- return !(!e.isReady() && void 0 === la[t]) || (e.innerEmitter.emit(er, new Ut({
- code: qt.SDK_IS_NOT_READY,
- message: "".concat(t, " ").concat(Bn, ",请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/module-EVENT.html#.SDK_READY")
- })), !1);
- }
- var ga = {},
- ha = {};
- return ha.create = function (t) {
- if (t.SDKAppID && ga[t.SDKAppID]) return ga[t.SDKAppID];
- de.log("TIM.create");
- var n = new ca(t);
- n.on(e.SDK_DESTROY, function (e) {
- ga[e.data.SDKAppID] = null, delete ga[e.data.SDKAppID];
- });
- var o = function (e) {
- var t = Object.create(null);
- return Object.keys(so).forEach(function (n) {
- if (e[n]) {
- var o = so[n],
- r = new k();
- t[o] = function () {
- var t = Array.from(arguments);
- return r.use(function (t, o) {
- return pa(e, n) ? o() : Cr(new Ut({
- code: qt.SDK_IS_NOT_READY,
- message: "".concat(n, " ").concat(Bn, "。")
- }));
- }).use(function (e, t) {
- if (!0 === Qe(e, io[n], o)) return t();
- }).use(function (t, o) {
- return e[n].apply(e, t);
- }), r.run(t);
- };
- }
- }), t;
- }(n);
- return ga[t.SDKAppID] = o, de.log("TIM.create ok"), o;
- }, ha.TYPES = t, ha.EVENT = e, ha.VERSION = "2.9.1", de.log("TIM.VERSION: ".concat(ha.VERSION)), ha;
- });
- }, function (modId) {
- var map = {};
- return __REQUIRE__(map[modId], modId);
- });
- return __REQUIRE__(1611536305607);
- }(); //# sourceMappingURL=index.js.map
|