Changeset 17b7fc5


Ignore:
Timestamp:
Jan 23, 2007, 4:43:33 PM (14 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
455f1ab
Parents:
4ee1cf4
Message:
Add better handling for changing groups in the roster.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/Net/XMPP/Roster.pm

    r72a53e9 r17b7fc5  
    272272    if (exists $self->{JIDS}->{$jid})
    273273    {
    274         foreach my $key (keys %item)
    275         {
    276             $self->{JIDS}->{$jid}->{$key} = $item{$key};
    277         }
     274        foreach my $key (keys %item)
     275        {
     276            $self->{JIDS}->{$jid}->{$key} = $item{$key};
     277        }
    278278    }
    279279    else
    280280    {
    281281        $self->{JIDS}->{$jid} = \%item;
    282 
    283     }
     282    }
     283
     284    foreach my $group (keys %{ $self->{GROUPS} })
     285    {
     286        # Clear user from old groups.
     287        delete $self->{GROUPS}->{$group}->{$jid};
     288        # Clean up empty groups.
     289        delete $self->{GROUPS}->{$group} unless scalar keys %{ $self->{GROUPS}->{$group} };
     290    }
     291
    284292    foreach my $group (@{$item{groups}})
    285293    {
    286         $self->{GROUPS}->{$group}->{$jid} = 1;
     294        $self->{GROUPS}->{$group}->{$jid} = 1;
    287295    }
    288296}
Note: See TracChangeset for help on using the changeset viewer.