loadSubscriptions loads topic subscribers, sets topic owner & lastMessage
()
| 529 | |
| 530 | // loadSubscriptions loads topic subscribers, sets topic owner & lastMessage |
| 531 | func (t *Topic) loadSubscriptions() error { |
| 532 | subs, err := store.Topics.GetSubs(t.appid, t.name, nil) |
| 533 | if err != nil { |
| 534 | return err |
| 535 | } |
| 536 | |
| 537 | for _, sub := range subs { |
| 538 | uid := types.ParseUid(sub.User) |
| 539 | t.perUser[uid] = perUserData{ |
| 540 | private: sub.Private, |
| 541 | lastSeenTag: sub.LastSeen, // could be nil |
| 542 | modeWant: sub.ModeWant, |
| 543 | modeGiven: sub.ModeGiven} |
| 544 | |
| 545 | if sub.ModeGiven&sub.ModeWant&types.ModeOwner != 0 { |
| 546 | log.Printf("hub.loadSubscriptions: %s set owner to %s", t.name, uid.String()) |
| 547 | t.owner = uid |
| 548 | } |
| 549 | |
| 550 | // For 'me' topic: |
| 551 | if sub.LastMessageAt != nil && !sub.LastMessageAt.IsZero() { |
| 552 | t.lastMessage = *sub.LastMessageAt |
| 553 | log.Printf("hub.loadSubscriptions: topic %s set lastMessage to %s", t.name, t.lastMessage.String()) |
| 554 | } |
| 555 | } |
| 556 | return nil |
| 557 | } |
| 558 | |
| 559 | // replyTopicInfoBasic loads minimal topic Info when the requester is not subscribed to the topic |
| 560 | func replyTopicInfoBasic(sess *Session, topic string, get *MsgClientGet) { |