roster.go
changeset 47 22e575eff35a
parent 46 4a4530b8f622
child 50 08d2b9deb710
--- a/roster.go	Sun Jan 01 19:32:51 2012 -0700
+++ b/roster.go	Sun Jan 01 20:00:43 2012 -0700
@@ -101,11 +101,19 @@
 	}(in, out)
 }
 
+// BUG(cjyar) This isn't actually thread safe, though it's unlikely it
+// will fail in practice. Either the roster should be protected with a
+// mutex, or we should make the roster available on a channel instead
+// of via a method call.
 func (cl *Client) maybeUpdateRoster(st Stanza) {
 	rq, ok := st.GetNested().(*RosterQuery)
 	if st.GetName() == "iq" && st.GetType() == "set" && ok {
 		for _, item := range(rq.Item) {
-			cl.roster[item.Jid] = &item
+			if item.Subscription == "remove" {
+				cl.roster[item.Jid] = nil
+			} else {
+				cl.roster[item.Jid] = &item
+			}
 		}
 	}
 }