(post *SubmittedPost, accessToken, collAlias, hostName string)
| 639 | } |
| 640 | |
| 641 | func (db *datastore) CreateOwnedPost(post *SubmittedPost, accessToken, collAlias, hostName string) (*PublicPost, error) { |
| 642 | var userID, collID int64 = -1, -1 |
| 643 | var coll *Collection |
| 644 | var err error |
| 645 | if accessToken != "" { |
| 646 | userID = db.GetUserID(accessToken) |
| 647 | if userID == -1 { |
| 648 | return nil, ErrBadAccessToken |
| 649 | } |
| 650 | if collAlias != "" { |
| 651 | coll, err = db.GetCollection(collAlias) |
| 652 | if err != nil { |
| 653 | return nil, err |
| 654 | } |
| 655 | coll.hostName = hostName |
| 656 | if coll.OwnerID != userID { |
| 657 | return nil, ErrForbiddenCollection |
| 658 | } |
| 659 | collID = coll.ID |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | rp := &PublicPost{} |
| 664 | rp.Post, err = db.CreatePost(userID, collID, post) |
| 665 | if err != nil { |
| 666 | return rp, err |
| 667 | } |
| 668 | if coll != nil { |
| 669 | coll.ForPublic() |
| 670 | rp.Collection = &CollectionObj{Collection: *coll} |
| 671 | } |
| 672 | return rp, nil |
| 673 | } |
| 674 | |
| 675 | func (db *datastore) CreatePost(userID, collID int64, post *SubmittedPost) (*Post, error) { |
| 676 | idLen := postIDLen |
nothing calls this directly
no test coverage detected