Example #1
0
                def _onRatingsReceived(ratingsResponse):
                    if ratingsResponse.isSuccess():
                        ratings = ctx.getDataObj(ratingsResponse.data)
                    else:
                        ratings = {}
                    for m in membersResponse.data:
                        m['ratings'] = ratings.get(m['account_id'], items.AccountClanRatingsData(account_id=m['account_id']))

                    callback(membersResponse)
Example #2
0
 def __sendRequest(self, invite, context, successStatus):
     self.__sentRequestCount += 1
     userDbID = getPlayerDatabaseID()
     temp = self.__accountNameMapping.get(userDbID, set())
     temp.add(invite.getDbID())
     self.__accountNameMapping[userDbID] = temp
     result = yield self._requester.sendRequest(context, allowDelay=True)
     if result.isSuccess():
         status = (successStatus, None)
     else:
         status = (CLAN_INVITE_STATES.ERROR, result.getCode())
     result, users = yield self._requester.requestUsers([userDbID])
     sender = users.get(userDbID, items.AccountClanRatingsData(userDbID))
     senderName = self.getUserName(userDbID)
     changerName = getPlayerName()
     item = self.__updateInvite(invite, status, sender, senderName, changerName)
     self.syncUsersInfo()
     self.__sentRequestCount -= 1
     self.onListItemsUpdated(self, [item])
     return
Example #3
0
    def __requestInvites(self, offset, count, isReset, callback):
        ctx = self.__ctxClass(clanDbID=self.__clanDbID, offset=offset, limit=count, statuses=self.__statuses, getTotalCount=isReset)
        result = yield self._requester.sendRequest(ctx, allowDelay=True)
        invites = ctx.getDataObj(result.data)
        self.__lastStatus = result.isSuccess()
        if isReset:
            self.__totalCount = ctx.getTotalCount(result.data)
        if result.isSuccess():
            if not invites and not isReset:
                self.revertOffset()
            usrIDs = set()
            for item in invites:
                usrIDs.add(item.getAccountDbID())
                temp = self.__accountNameMapping.get(item.getAccountDbID(), set())
                temp.add(item.getDbID())
                self.__accountNameMapping[item.getAccountDbID()] = temp
                usrIDs.add(item.getChangedBy())
                temp = self.__changerNameMapping.get(item.getChangedBy(), set())
                temp.add(item.getDbID())
                self.__changerNameMapping[item.getChangedBy()] = temp
                usrIDs.add(item.getSenderDbID())
                temp = self.__senderNameMapping.get(item.getSenderDbID(), set())
                temp.add(item.getDbID())
                self.__senderNameMapping[item.getSenderDbID()] = temp

            self.__lastStatus, users = yield self._requester.requestUsers(usrIDs)
            if self.__lastStatus:
                self.__invitesCache = [ ClanInviteWrapper(invite, users.get(invite.getAccountDbID(), items.AccountClanRatingsData(invite.getAccountDbID())), self.getUserName(invite.getAccountDbID()), users.get(invite.getChangedBy(), items.AccountClanRatingsData(invite.getChangedBy())), senderName=self.getUserName(invite.getSenderDbID()), changerName=self.getUserName(invite.getChangedBy())) for invite in invites ]
            else:
                self.__invitesCache = []
                self.revertOffset()
        else:
            self.__invitesCache = []
            self.revertOffset()
        self.__rebuildMapping()
        self.syncUsersInfo()
        self.__isSynced = self.__lastStatus
        callback((self.__lastStatus, self.__invitesCache))