Zimbra-Community / python-zimbra

Core framework for easily sending requests to the Zimbra SOAP-API
BSD 2-Clause "Simplified" License
63 stars 26 forks source link

WaitSetRequest #30

Open vladus06 opened 4 years ago

vladus06 commented 4 years ago

I'm trying to listen for new emails being added, getting emptiness. How can I view new letters correctly?

info_request = comm.gen_request(token=usr_token)
iinfo_request = comm.gen_request(token=usr_token)

#Create waitset
info_request.add_request(
    'CreateWaitSetRequest',
    {
    'defTypes': 'f,m,c',
    'add': {
        'a': {
            'name': 'my@mail',
            'types': 'f,m,c'
        },
    },

    },
    'urn:zimbraMail'
)
info_response = comm.send_request(info_request)
if not info_response.is_fault():
    waitset = (info_response.get_response()['CreateWaitSetResponse']['waitSet'])
    seq = (info_response.get_response()['CreateWaitSetResponse']['seq'])
    defTypes = (info_response.get_response()['CreateWaitSetResponse']['defTypes'])
......

everything above works. I get values {u'CreateWaitSetResponse': {u'waitSet': u'WaitSet-064715ab-1867-4254-ac38-63bfd6255484', u'defTypes': u'f,m,c', u'seq': 0}}

.......
iinfo_request.add_request(
    'WaitSetRequest',
    {
    'waitSet': waitset,
    'seq': seq,
    'block': '1',
    'defTypes': defTypes,
    'timeout': '1000',
    'expand': '1',
    'add': {
        'a': {
            'name': 'my@mail',
            'token': '',
            'types': defTypes
        },
    },

    },
    'urn:zimbraMail'
)
iinfo_response = comm.send_request(iinfo_request)
if not iinfo_response.is_fault():
    print (iinfo_response.get_response()['WaitSetResponse'])

I think the problem is here

if not iinfo_response.is_fault():
    print (iinfo_response.get_response()['WaitSetResponse'])

Result: [root@mail zmadmin]# python ./test.py [root@mail zmadmin]#

I want to see: [root@mail zmadmin]# python ./test.py {u'WaitSetResponse': {u'waitSet': u'WaitSet-064715ab-1867-4254-ac38-63bfd6255484', ... bla-bla-bla {u'WaitSetResponse': {u'waitSet': u'WaitSet-064715ab-1867-4254-ac38-63bfd6255484', ... bla-bla-bla {u'WaitSetResponse': {u'waitSet': u'WaitSet-064715ab-1867-4254-ac38-63bfd6255484', ... bla-bla-bla

vladus06 commented 4 years ago

I added values to CreateWaitSetRequest and WaitSetRequest 'token': '401',

Result: [root@mail zmadmin]# python ./test.py {u'a': {u'id': u'7ac0ebb7-2bd5-4c48-828c-74cbc0e636d1', u'changeid': 4136}, u'waitSet': u'WaitSet-aadbba9d-1385-4f2b-97a6-a508776ed050', u'seq': u'2', u'error': {u'type': u'ALREADY_IN_SET_DURING_ADD', u'id': u'7ac0ebb7-2bd5-4c48-828c-74cbc0e636d1'}} [root@mail zmadmin]#

How to listen to messages continuously?