Exemple #1
0
 def sendInvites(self, accountsToInvite, comment):
     self.as_showWaitingS(WAITING.CLANS_INVITES_SEND, {})
     accountsToInvite = [int(userDbID) for userDbID in accountsToInvite]
     ctx = clan_ctx.CreateInviteCtx(self.__clanDbID, accountsToInvite,
                                    comment)
     self.as_onReceiveSendInvitesCooldownS(ctx.getCooldown())
     result = yield self.clansCtrl.sendRequest(ctx)
     successAccounts = [
         item.getAccountDbID() for item in ctx.getDataObj(result.data)
     ]
     failedAccounts = set(accountsToInvite) - set(successAccounts)
     if len(accountsToInvite) > 1:
         if successAccounts:
             accountNames = [
                 self.getUserName(userDbID) for userDbID in successAccounts
             ]
             SystemMessages.pushMessage(
                 clans_fmts.getInvitesSentSysMsg(accountNames))
         if failedAccounts:
             accountNames = [
                 self.getUserName(userDbID) for userDbID in failedAccounts
             ]
             SystemMessages.pushMessage(
                 clans_fmts.getInvitesNotSentSysMsg(accountNames),
                 type=SystemMessages.SM_TYPE.Error)
     else:
         showClanInviteSystemMsg(self.getUserName(accountsToInvite[0]),
                                 result.isSuccess(), result.getCode())
     self.as_hideWaitingS()
 def sendClanInvite(self):
     profile = g_clanCtrl.getAccountProfile()
     context = CreateInviteCtx(profile.getClanDbID(), [self.databaseID])
     result = yield g_clanCtrl.sendRequest(context, allowDelay=True)
     if result.isSuccess():
         SystemMessages.pushMessage(clans_fmts.getAppSentSysMsg(profile.getClanName(), profile.getClanAbbrev()))
     else:
         SystemMessages.pushMessage(clans_fmts.getInvitesNotSentSysMsg([self.userName or '']), type=SystemMessages.SM_TYPE.Error)
Exemple #3
0
 def userAddToClan(self):
     self.as_showWaitingS(WAITING.CLANS_INVITES_SEND, {})
     profile = g_clanCtrl.getAccountProfile()
     context = CreateInviteCtx(profile.getClanDbID(), [self.__databaseID])
     result = yield g_clanCtrl.sendRequest(context, allowDelay=True)
     if result.isSuccess():
         SystemMessages.pushMessage(clans_fmts.getAppSentSysMsg(profile.getClanName(), profile.getClanAbbrev()))
     else:
         SystemMessages.pushMessage(
             clans_fmts.getInvitesNotSentSysMsg([self.__userName]), type=SystemMessages.SM_TYPE.Error
         )
     self.__updateAddToClanBtn()
     self.as_hideWaitingS()
 def sendInvites(self, accountsToInvite, comment):
     self.as_showWaitingS(WAITING.CLANS_INVITES_SEND, {})
     accountsToInvite = [ int(userDbID) for userDbID in accountsToInvite ]
     ctx = clan_ctx.CreateInviteCtx(self.__clanDbID, accountsToInvite, comment)
     self.__cooldown = ctx.getCooldown()
     result = yield self.clansCtrl.sendRequest(ctx)
     successAccounts = [ item.getAccountDbID() for item in ctx.getDataObj(result.data) ]
     failedAccounts = set(accountsToInvite) - set(successAccounts)
     if successAccounts:
         accountNames = [ self.getUserName(userDbID) for userDbID in successAccounts ]
         SystemMessages.pushMessage(clans_fmts.getInvitesSentSysMsg(accountNames))
     if failedAccounts:
         accountNames = [ self.getUserName(userDbID) for userDbID in failedAccounts ]
         SystemMessages.pushMessage(clans_fmts.getInvitesNotSentSysMsg(accountNames), type=SystemMessages.SM_TYPE.Error)
     self.as_hideWaitingS()
Exemple #5
0
 def sendInvites(self, accountsToInvite, comment):
     self.as_showWaitingS(backport.msgid(R.strings.waiting.clans.invites.send()), {})
     accountsToInvite = [ int(userDbID) for userDbID in accountsToInvite ]
     ctx = clan_ctx.CreateInviteCtx(self.__clanDbID, accountsToInvite, comment)
     self.as_onReceiveSendInvitesCooldownS(ctx.getCooldown())
     result = yield self.webCtrl.sendRequest(ctx)
     expectedCodes = (ResponseCodes.ACCOUNT_ALREADY_APPLIED, ResponseCodes.ACCOUNT_ALREADY_INVITED, ResponseCodes.NO_ERRORS)
     if result.getCode() in expectedCodes:
         successAccounts = [ item.getAccountDbID() for item in ctx.getDataObj(result.data) ]
         failedAccounts = set(accountsToInvite) - set(successAccounts)
     else:
         successAccounts = []
         failedAccounts = accountsToInvite
     if len(accountsToInvite) > 1:
         if successAccounts:
             accountNames = [ self.getUserName(userDbID) for userDbID in successAccounts ]
             SystemMessages.pushMessage(clans_fmts.getInvitesSentSysMsg(accountNames))
         if failedAccounts:
             accountNames = [ self.getUserName(userDbID) for userDbID in failedAccounts ]
             SystemMessages.pushMessage(clans_fmts.getInvitesNotSentSysMsg(accountNames), type=SystemMessages.SM_TYPE.Error)
     else:
         showClanInviteSystemMsg(self.getUserName(accountsToInvite[0]), result.isSuccess(), result.getCode(), result.data)
     self.as_hideWaitingS()