Commit da946e1e authored by valtron's avatar valtron

send MSNP18+ JOIs, set MPOPEnabled (#64)

parent c0fbb282
......@@ -317,11 +317,9 @@ class Backend:
sess.client = extra_data['client']
chat = self._chats.get(chatid)
if chat is None: return None
for sc, _ in chat.get_roster(self):
sc.send_event(event.ChatParticipantJoined(user))
chat.add_session(sess)
return chat, extra_data
def _load_user(self, purpose, token):
data = self._auth_service.pop_token(purpose, token)
if data is None: return (None, None)
......@@ -479,6 +477,10 @@ class Chat:
roster.append((sess1, su1))
return roster
def send_participant_joined(self, sess):
for sc, _ in self.get_roster(self):
sc.send_event(event.ChatParticipantJoined(sess))
def on_leave(self, sess):
su = self._users_by_sess.pop(sess, None)
if su is None: return
......
......@@ -14,8 +14,8 @@ class InvitedToChatEvent:
self.caller = caller
class ChatParticipantJoined:
def __init__(self, user):
self.user = user
def __init__(self, sess):
self.sess = sess
class ChatParticipantLeft:
def __init__(self, user):
......
......@@ -513,7 +513,7 @@ MSPAuth: t={token}Y6+H31sTUOFkqjNTDYqAAFLr5Ote7BMrMnUIzpg860jh084QMgs5djRQLLQP0T
ClientIP: {ip}
ClientPort: {port}
ABCHMigrated: 1
MPOPEnabled: 0
MPOPEnabled: 1
'''
......
......@@ -28,7 +28,7 @@ def _m_ans(sess, trid, arg, token, sessid):
#>>> ANS trid email@example.com token sessionid (MSNP < 18)
#>>> ANS trid email@example.com;{00000000-0000-0000-0000-000000000000} token sessionid (MSNP >= 18)
state = sess.state
(email, _) = _decode_email_pop(arg)
(email, pop_id) = _decode_email_pop(arg)
data = state.backend.login_cal(sess, email, token, sessid)
if data is None:
sess.send_reply(Err.AuthFail, trid)
......@@ -38,6 +38,10 @@ def _m_ans(sess, trid, arg, token, sessid):
state.dialect = dialect
state.chat = chat
state.front_specific['msn_capabilities'] = extra_data['msn_capabilities']
state.pop_id = pop_id
chat.send_participant_joined(sess)
roster = [
(sc, su) for (sc, su) in chat.get_roster(sess)
if su != sess.user
......
......@@ -51,15 +51,14 @@ class MSNPWriter:
self._write(['BYE', user.email])
return
if isinstance(outgoing_event, event.ChatParticipantJoined):
user = outgoing_event.user
sess = outgoing_event.sess
user = sess.user
extra = ()
dialect = self._sess_state.dialect
if dialect >= 13:
extra = (self._sess_state.front_specific.get('msn_capabilities') or 0,)
# TODO: This needs to receive the chatsession of the user that joined
# If chatsession.pop_id and chatsession != this session:
# TODO: user.email:{pop_id}
#self._write(['JOI', user.email, user.status.name, *extra])
if dialect >= 18 and sess.pop_id and sess.state is not self._sess_state:
self._write(['JOI', '{}:{}'.format(user.email, sess.pop_id), user.status.name, *extra])
self._write(['JOI', user.email, user.status.name, *extra])
return
if isinstance(outgoing_event, event.ChatMessage):
......
  • @valtron I think you coded too quickly. Line 61 is incorrect. {}:{} is for netword id not pop id. Pop id is email@addres.com;{0000000-0000-0000-0000000000}

    Also under MSNP18 at least, the JOI command is never sent anymore (even for the other contact).

  • Very similar, those two characters are.

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment