Create creates a topic and owner's subscription to it.
(topic *types.Topic, owner types.Uid, private any)
| 524 | |
| 525 | // Create creates a topic and owner's subscription to it. |
| 526 | func (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. |
| 551 | func (topicsMapper) CreateP2P(initiator, invited *types.Subscription) error { |