MCPcopy Create free account
hub / github.com/daodst/chat / loadSubscriptions

Method loadSubscriptions

server/hub.go:531–557  ·  view source on GitHub ↗

loadSubscriptions loads topic subscribers, sets topic owner & lastMessage

()

Source from the content-addressed store, hash-verified

529
530// loadSubscriptions loads topic subscribers, sets topic owner & lastMessage
531func (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
560func replyTopicInfoBasic(sess *Session, topic string, get *MsgClientGet) {

Callers 1

topicInitFunction · 0.95

Calls 2

GetSubsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected