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

Method Create

server/store/store.go:526–548  ·  view source on GitHub ↗

Create creates a topic and owner's subscription to it.

(topic *types.Topic, owner types.Uid, private any)

Source from the content-addressed store, hash-verified

524
525// Create creates a topic and owner's subscription to it.
526func (topicsMapper) Create(topic *types.Topic, owner types.Uid, private any) error {
527
528 topic.InitTimes()
529 topic.TouchedAt = topic.CreatedAt
530 topic.Owner = owner.String()
531
532 err := adp.TopicCreate(topic)
533 if err != nil {
534 return err
535 }
536
537 if !owner.IsZero() {
538 err = Subs.Create(&types.Subscription{
539 ObjHeader: types.ObjHeader{CreatedAt: topic.CreatedAt},
540 User: owner.String(),
541 Topic: topic.Id,
542 ModeGiven: types.ModeCFull,
543 ModeWant: topic.GetAccess(owner),
544 Private: private})
545 }
546
547 return err
548}
549
550// CreateP2P creates a P2P topic by generating two user's subsciptions to each other.
551func (topicsMapper) CreateP2P(initiator, invited *types.Subscription) error {

Callers

nothing calls this directly

Calls 6

InitTimesMethod · 0.80
GetAccessMethod · 0.80
TopicCreateMethod · 0.65
CreateMethod · 0.65
StringMethod · 0.45
IsZeroMethod · 0.45

Tested by

no test coverage detected