Does not send presence if it has not change
darcs-hash:20080514063321-86b55-befb7d76016153a5da1f1190f1d498b5a8813c47.gz
This commit is contained in:
@@ -387,13 +387,13 @@ class AccountManager(object):
|
|||||||
"""Send available presence to account's user and ask for password
|
"""Send available presence to account's user and ask for password
|
||||||
if necessary"""
|
if necessary"""
|
||||||
result = []
|
result = []
|
||||||
model.db_connect()
|
|
||||||
old_status = _account.status
|
old_status = _account.status
|
||||||
_account.status = account.ONLINE
|
_account.status = account.ONLINE
|
||||||
if _account.error is not None:
|
if _account.error is not None:
|
||||||
_account.status = account.DND
|
_account.status = account.DND
|
||||||
elif not _account.enabled:
|
elif not _account.enabled:
|
||||||
_account.status = account.XA
|
_account.status = account.XA
|
||||||
|
if old_status != _account.status:
|
||||||
result.extend(self.get_presence(from_jid=_account.jid,
|
result.extend(self.get_presence(from_jid=_account.jid,
|
||||||
to_jid=_account.user.jid,
|
to_jid=_account.user.jid,
|
||||||
status=_account.status_msg,
|
status=_account.status_msg,
|
||||||
@@ -405,7 +405,6 @@ class AccountManager(object):
|
|||||||
and old_status == account.OFFLINE \
|
and old_status == account.OFFLINE \
|
||||||
and _account.password == None :
|
and _account.password == None :
|
||||||
result.extend(self.ask_password(_account, lang_class))
|
result.extend(self.ask_password(_account, lang_class))
|
||||||
model.db_disconnect()
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def probe_all_accounts_presence(self):
|
def probe_all_accounts_presence(self):
|
||||||
|
|||||||
@@ -3189,6 +3189,16 @@ class AccountManager_TestCase(JCLTestCase):
|
|||||||
self.assertEquals(presence.children.name, "show")
|
self.assertEquals(presence.children.name, "show")
|
||||||
self.assertEquals(presence.children.content, "online")
|
self.assertEquals(presence.children.content, "online")
|
||||||
|
|
||||||
|
def test_get_account_presence_available_no_change(self):
|
||||||
|
"""Test when presence status does not change"""
|
||||||
|
_account = Account(user=User(jid="user1@test.com"),
|
||||||
|
name="account11",
|
||||||
|
jid="account11@jcl.test.com")
|
||||||
|
_account.status = account.ONLINE
|
||||||
|
result = self.account_manager.get_account_presence_available(\
|
||||||
|
_account, _account.default_lang_class)
|
||||||
|
self.assertEquals(len(result), 0)
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
test_suite = unittest.TestSuite()
|
test_suite = unittest.TestSuite()
|
||||||
test_suite.addTest(unittest.makeSuite(JCLComponent_TestCase, 'test'))
|
test_suite.addTest(unittest.makeSuite(JCLComponent_TestCase, 'test'))
|
||||||
|
|||||||
Reference in New Issue
Block a user