Terminate all topics associated with the given user: * all p2p topics with the given user * group topics where the given user is the owner. * user's 'me', 'fnd', 'slf' topics.
(uid types.Uid, reason int, alldone chan<- bool)
| 565 | // * group topics where the given user is the owner. |
| 566 | // * user's 'me', 'fnd', 'slf' topics. |
| 567 | func (h *Hub) stopTopicsForUser(uid types.Uid, reason int, alldone chan<- bool) { |
| 568 | var done chan bool |
| 569 | if alldone != nil { |
| 570 | done = make(chan bool, 128) |
| 571 | } |
| 572 | |
| 573 | count := 0 |
| 574 | h.topics.Range(func(name any, t any) bool { |
| 575 | topic := t.(*Topic) |
| 576 | if _, isMember := topic.perUser[uid]; (topic.cat != types.TopicCatGrp && isMember) || |
| 577 | topic.owner == uid { |
| 578 | topic.markDeleted() |
| 579 | h.topics.Delete(name) |
| 580 | |
| 581 | // This call is non-blocking unless some other routine tries to stop it at the same time. |
| 582 | topic.exit <- &shutDown{reason: reason, done: done} |
| 583 | |
| 584 | // Just send to p2p topics here. |
| 585 | if topic.cat == types.TopicCatP2P && len(topic.perUser) == 2 { |
| 586 | presSingleUserOfflineOffline(topic.p2pOtherUser(uid), uid.UserId(), "gone", nilPresParams, "") |
| 587 | } |
| 588 | count++ |
| 589 | } |
| 590 | return true |
| 591 | }) |
| 592 | |
| 593 | statsInc("LiveTopics", -count) |
| 594 | |
| 595 | if alldone != nil { |
| 596 | for range count { |
| 597 | <-done |
| 598 | } |
| 599 | alldone <- true |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | // replyOfflineTopicGetDesc reads a minimal topic Desc from the database. |
| 604 | // The requester may or maynot be subscribed to the topic. |
no test coverage detected