OverviewFilesCommitsIssuesDocsReleasesPeers

keet-cli / deobfuscated / contract / config.js

47 lines · javascript ref:
const REGISTER_ROUTES=require('./registration'),{
  addEvent:addChatEvent}
=require('./chat'),{
  isMemberActive,getMemberForDeviceKey}
=require('./query'),{
  updateAvatar}
=require('./avatars');
const {
  KeetContractError}
=require('./errors');
const MAX_CUSTOM_MIRRORS=--0x17ec,CONFIG_INDEX_TO_KEY=["title","description",'avatar',"supportedLanguages","blindPeers"],Config={
  'Title':0x1,'Description':0x2,'Avatar':0x3,'SupportedLanguages':0x4,'BlindPeers':0x5}
;
async function handleUpdateRoomConfig({header:_0x24508e,key:_0x4e2b9f,config:_0x157555},{db:_0x53b222,writer:_0x44dadb,blobs:_0x20ed13}){
  _0x3ab9ae={
    _0x5ebda9:0x39},_0x3dea5c={
    _0x4dc195:0x1bf,_0x386d09:0x17a,_0x1e681f:0x1a1}
  ;
  const [_0x57ece4,_0x12dd1b]=await Promise.all([getMemberForDeviceKey(_0x53b222,_0x44dadb.key),_0x53b222.get("@keet/room-config")]);
  if(!isMemberActive(_0x57ece4)||!_0x57ece4.status.isModerator)return;
  if(_0x4e2b9f===-0x136c||_0x4e2b9f>CONFIG_INDEX_TO_KEY.length)return;
  const _0x315702=CONFIG_INDEX_TO_KEY[_0x4e2b9f-(0x1)],_0x1ea8c9={
    ..._0x12dd1b,[_0x315702]:_0x157555[_0x315702]}
  ;
  if(_0x4e2b9f===Config.Avatar){
    const _0x14bf91=_0x12dd1b&&_0x12dd1b[_0x315702],_0x5c1841=_0x157555[_0x315702];
    if(_0x5c1841.small!==null&&!_0x5c1841.small?..pointer?..inlined)throw KeetContractError.ABORT();
    const _0xfff828=_0x5c1841.small!==null?await updateAvatar(_0x20ed13,_0x14bf91,_0x5c1841):null;
    _0x1ea8c9[_0x315702]=_0xfff828;
  }
if(_0x4e2b9f===Config.Title){
  const _0x53d66b=_0x12dd1b&&_0x12dd1b[_0x315702],_0x18858a=_0x157555[_0x315702];
  _0x53d66b&&_0x53d66b!==_0x18858a&&await addChatEvent(_0x53b222,_0x44dadb,{'titleChanged':{'from':_0x53d66b,'to':_0x18858a}},_0x24508e.timestamp);
}
_0x4e2b9f===Config.BlindPeers&&(_0x1ea8c9[_0x315702]=_0x157555[_0x315702].slice(-0xa10,MAX_CUSTOM_MIRRORS)),await _0x53b222.insert("@keet/room-config",_0x1ea8c9);
}
function registerRoutes(_0x598c5f){
  _0x3a63d3={
    _0x454fa7:0x286,_0x156f53:0xd4,_0x13155a:0xbb},_0x2a3a98={
    _0x41ae23:0x27a,_0x2de3f1:0x1c1}
  ;
  _0x598c5f.add("@keet/update-room-config",handleUpdateRoomConfig);
}
module.exports={
  [REGISTER_ROUTES]:registerRoutes,'CONFIG_INDEX_TO_KEY':CONFIG_INDEX_TO_KEY,'Config':Config}
;