Initialize 'me' topic.
(t *Topic, sreg *ClientComMessage)
| 136 | |
| 137 | // Initialize 'me' topic. |
| 138 | func initTopicMe(t *Topic, sreg *ClientComMessage) error { |
| 139 | t.cat = types.TopicCatMe |
| 140 | |
| 141 | user, err := store.Users.Get(types.ParseUserId(t.name)) |
| 142 | if err != nil { |
| 143 | // Log out the session |
| 144 | sreg.sess.uid = types.ZeroUid |
| 145 | return err |
| 146 | } else if user == nil { |
| 147 | // Log out the session |
| 148 | sreg.sess.uid = types.ZeroUid |
| 149 | return types.ErrUserNotFound |
| 150 | } |
| 151 | |
| 152 | // User's default access for p2p topics |
| 153 | t.accessAuth = user.Access.Auth |
| 154 | t.accessAnon = user.Access.Anon |
| 155 | |
| 156 | // Assign tags |
| 157 | t.tags = user.Tags |
| 158 | |
| 159 | if err = t.loadSubscribers(); err != nil { |
| 160 | return err |
| 161 | } |
| 162 | |
| 163 | t.public = user.Public |
| 164 | t.trusted = user.Trusted |
| 165 | |
| 166 | t.created = user.CreatedAt |
| 167 | t.updated = user.UpdatedAt |
| 168 | |
| 169 | // The following values are exlicitly not set for 'me'. |
| 170 | // t.touched, t.lastId, t.delId |
| 171 | |
| 172 | // 'me' has no owner, t.owner = nil |
| 173 | |
| 174 | // Initiate User Agent with the UA of the creating session to report it later |
| 175 | t.userAgent = sreg.sess.userAgent |
| 176 | // Initialize channel for receiving user agent and session online updates. |
| 177 | t.supd = make(chan *sessionUpdate, 32) |
| 178 | |
| 179 | if !t.isProxy { |
| 180 | // Allocate storage for contacts. |
| 181 | t.perSubs = make(map[string]perSubsData) |
| 182 | } |
| 183 | |
| 184 | return nil |
| 185 | } |
| 186 | |
| 187 | // Initialize 'fnd' topic |
| 188 | func initTopicFnd(t *Topic, sreg *ClientComMessage) error { |
no test coverage detected
searching dependent graphs…