Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

HTTP 400 on msg.read() (sometimes) #207

@truenicoco

Description

@truenicoco

Marking a message as read sometimes raise a 400 response from PUT.

I did not manage to understand exactly when or why it happens, but it is not uncommon at all

Account type

Live account - app password

Conversation details

1 on 1

Steps to reproduce

from threading import Thread

import skpy

def skype_blocking():
    while True:
        for event in sk.getEvents():
            print(event)
            if isinstance(event, skpy.SkypeNewMessageEvent):
                if event.msg.userId != sk.userId:
                    print(event.msg)
                    print("Attempting to mark it as read")
                    event.msg.read()

sk = skpy.Skype(user, pass)

Thread(target=skype_blocking).start()

input()  # just to keep the thing going
# then wait for a few messages, since it does not happen all the time...

Result or traceback

=> [15/07 22:20:18] 200
{'Cache-Control': 'no-store, must-revalidate, no-cache',
 'Content-Encoding': 'gzip',
 'Content-Length': '461',
 'Content-Type': 'application/json; charset=utf-8',
 'ContextId': 'tcid=6903253961969671623,server=SN3PEPF00009CED',
 'Date': 'Fri, 15 Jul 2022 20:20:17 GMT',
 'Pragma': 'no-cache',
 'X-Content-Type-Options': 'nosniff'}
{'eventMessages': [{'id': 1024,
                    'resource': {'ackrequired': 'https://azscus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/ALL/messages/1657916418393/ack',
                                 'clientmessageid': '15356246672076019567',
                                 'composetime': '2022-07-15T20:20:18.321Z',
                                 'content': 'comprends pas',
                                 'contenttype': 'text',
                                 'conversationLink': 'https://azscus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:OTHERPARTYSKYPEID',
                                 'counterpartymessageid': '1657916418393',
                                 'from': 'https://azscus1-client-s.gateway.messenger.live.com/v1/users/ME/contacts/8:OTHERPARTYSKYPEID',
                                 'id': '1657916418393',
                                 'imdisplayname': 'Nico Prout',
                                 'isactive': True,
                                 'messagetype': 'RichText',
                                 'mlsEpoch': '0',
                                 'originalarrivaltime': '2022-07-15T20:20:18.321Z',
                                 'origincontextid': '0',
                                 'receiverdisplayname': 'REDACTED',
                                 'threadtopic': 'OTHERPARTYSKYPEID, '
                                                'REDACTED',
                                 'type': 'Message',
                                 'version': '1657916418393'},
                    'resourceLink': 'https://azscus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:OTHERPARTYSKYPEID/messages/1657916418393',
                    'resourceType': 'NewMessage',
                    'time': '2022-07-15T20:20:18Z',
                    'type': 'EventMessage'}]}
[SkypeNewMessageEvent]
Id: 1024
Type: NewMessage
Time: 2022-07-15 20:20:18
MsgId: 1657916418393
[SkypeTextMsg]
Id: 1657916418393
Type: RichText
Time: 2022-07-15 20:20:18.321000
ClientId: 15356246672076019567
UserId: OTHERPARTYSKYPEID
ChatId: 8:OTHERPARTYSKYPEID
Content: comprends pas
Attempting to mark it as read
<= [15/07 22:20:18] PUT https://azscus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:OTHERPARTYSKYPEID/properties
{'json': {'consumptionhorizon': '15356246672076019567;1657916418490;15356246672076019567'},
 'params': {'name': 'consumptionhorizon'}}
=> [15/07 22:20:18] 400
{'Cache-Control': 'no-store, must-revalidate, no-cache',
 'Content-Length': '70',
 'Content-Type': 'application/json; charset=utf-8',
 'ContextId': 'tcid=2776881302533368130,server=SN3PEPF00009CED',
 'Date': 'Fri, 15 Jul 2022 20:20:18 GMT',
 'Pragma': 'no-cache',
 'StatusText': 'Update Conversation has invalid property'}
{'errorCode': 202, 'message': 'Update Conversation has invalid property'}
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/tmp/sktest.py", line 13, in skype_blocking
    event.msg.read()
  File "/home/nicoco/.cache/pypoetry/virtualenvs/slidge-AjQFdees-py3.9/lib/python3.9/site-packages/skpy/msg.py", line 278, in read
    self.chat.setConsumption("{0};{1};{0}".format(self.clientId, int(time.time() * 1000)))
  File "/home/nicoco/.cache/pypoetry/virtualenvs/slidge-AjQFdees-py3.9/lib/python3.9/site-packages/skpy/chat.py", line 266, in setConsumption
    self.skype.conn("PUT", "{0}/users/ME/conversations/{1}/properties".format(self.skype.conn.msgsHost, self.id),
  File "/home/nicoco/.cache/pypoetry/virtualenvs/slidge-AjQFdees-py3.9/lib/python3.9/site-packages/skpy/conn.py", line 237, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('400 response from PUT https://azscus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:OTHERPARTYSKYPEID/properties', <Response [400]>)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions