Skip to content

Commit

Permalink
ignore roster pushes if roster has not been retrieved yet
Browse files Browse the repository at this point in the history
  • Loading branch information
primalmotion committed Aug 24, 2012
1 parent c25d6e9 commit bd68bb3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion TNStropheRoster.j
Expand Up @@ -44,6 +44,8 @@ TNStropheRosterSubGroupDelimiterReceivedNotification = @"TNStropheRosterSubGr
@implementation TNStropheRoster : TNStropheRosterBase @implementation TNStropheRoster : TNStropheRosterBase
{ {
CPDictionary _pendingPresence @accessors(getter=pendingPresence); CPDictionary _pendingPresence @accessors(getter=pendingPresence);

BOOL _rosterRetrieved;
} }




Expand Down Expand Up @@ -87,6 +89,7 @@ TNStropheRosterSubGroupDelimiterReceivedNotification = @"TNStropheRosterSubGr


[_groupCache removeAllObjects]; [_groupCache removeAllObjects];
[_pendingPresence removeAllObjects]; [_pendingPresence removeAllObjects];
_rosterRetrieved = NO;
[super clear]; [super clear];
} }


Expand Down Expand Up @@ -194,9 +197,12 @@ TNStropheRosterSubGroupDelimiterReceivedNotification = @"TNStropheRosterSubGr
if (!subscription || ![allowedSubs containsObject:subscription]) if (!subscription || ![allowedSubs containsObject:subscription])
[item setValue:@"none" forAttribute:@"subscription"]; [item setValue:@"none" forAttribute:@"subscription"];


[self _addContactFromRosterItem:item]; if (![self containsJID:[TNStropheJID stropheJIDWithString:[item valueForAttribute:@"jid"]]])
[self _addContactFromRosterItem:item];
} }


_rosterRetrieved = YES;

[[CPNotificationCenter defaultCenter] postNotificationName:TNStropheRosterRetrievedNotification object:self]; [[CPNotificationCenter defaultCenter] postNotificationName:TNStropheRosterRetrievedNotification object:self];


return NO; return NO;
Expand Down Expand Up @@ -282,6 +288,9 @@ TNStropheRosterSubGroupDelimiterReceivedNotification = @"TNStropheRosterSubGr
*/ */
- (BOOL)_didReceiveRosterPush:(TNStropheStanzas)aStanza - (BOOL)_didReceiveRosterPush:(TNStropheStanzas)aStanza
{ {
if (!_rosterRetrieved)
return;

var item = [aStanza firstChildWithName:@"item"], var item = [aStanza firstChildWithName:@"item"],
theJID = [TNStropheJID stropheJIDWithString:[item valueForAttribute:@"jid"]], theJID = [TNStropheJID stropheJIDWithString:[item valueForAttribute:@"jid"]],
subscription = [item valueForAttribute:@"subscription"], subscription = [item valueForAttribute:@"subscription"],
Expand Down

0 comments on commit bd68bb3

Please sign in to comment.