예제 #1
0
    def __get_account(self, account_handles, command):
        try:
            account = Account.objects.get(handles__in=account_handles, source=command.source,
                                          protocol=command.protocol)
        except DoesNotExist:
            account = Account(handles=account_handles, source=command.source, protocol=command.protocol)
            account.save()

        return account
예제 #2
0
    def get_messages(self, account_handle, **kwargs):
        try:
            accounts = Account.objects(handles__in=[account_handle])
        except DoesNotExist:
            return []

        messages = Message.objects(account__in=accounts).all()[:20]
        return [MessageTuple(text=msg.message, datetime=msg.datetime, direction=msg.direction, contact=msg.contact.name)
                for msg in messages]