MCPcopy
hub / github.com/tinode/chat / initTopicFnd

Function initTopicFnd

server/init_topic.go:188–223  ·  view source on GitHub ↗

Initialize 'fnd' topic

(t *Topic, sreg *ClientComMessage)

Source from the content-addressed store, hash-verified

186
187// Initialize 'fnd' topic
188func initTopicFnd(t *Topic, sreg *ClientComMessage) error {
189 t.cat = types.TopicCatFnd
190
191 uid := types.ParseUserId(sreg.AsUser)
192 if uid.IsZero() {
193 return types.ErrNotFound
194 }
195
196 user, err := store.Users.Get(uid)
197 if err != nil {
198 return err
199 } else if user == nil {
200 if !sreg.sess.isMultiplex() {
201 sreg.sess.uid = types.ZeroUid
202 }
203 return types.ErrNotFound
204 }
205
206 // Make sure no one can join the topic.
207 t.accessAuth = getDefaultAccess(t.cat, true, false)
208 t.accessAnon = getDefaultAccess(t.cat, false, false)
209
210 if err = t.loadSubscribers(); err != nil {
211 return err
212 }
213
214 t.created = user.CreatedAt
215 t.updated = user.UpdatedAt
216
217 // 'fnd' has no owner, t.owner = nil
218
219 // Publishing to fnd is not supported
220 // t.lastId = 0, t.delId = 0, t.touched = nil
221
222 return nil
223}
224
225// Load or create a P2P topic.
226// There is a reace condition when two users try to create a p2p topic at the same time.

Callers 1

topicInitFunction · 0.85

Calls 6

ParseUserIdFunction · 0.92
getDefaultAccessFunction · 0.85
isMultiplexMethod · 0.80
loadSubscribersMethod · 0.80
GetMethod · 0.65
IsZeroMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…