MCPcopy Create free account
hub / github.com/gogs/gogs / loadAttributes

Method loadAttributes

internal/database/comment.go:93–127  ·  view source on GitHub ↗
(e Engine)

Source from the content-addressed store, hash-verified

91}
92
93func (c *Comment) loadAttributes(e Engine) (err error) {
94 if c.Poster == nil {
95 c.Poster, err = Handle.Users().GetByID(context.TODO(), c.PosterID)
96 if err != nil {
97 if IsErrUserNotExist(err) {
98 c.PosterID = -1
99 c.Poster = NewGhostUser()
100 } else {
101 return errors.Newf("getUserByID.(Poster) [%d]: %v", c.PosterID, err)
102 }
103 }
104 }
105
106 if c.Issue == nil {
107 c.Issue, err = getRawIssueByID(e, c.IssueID)
108 if err != nil {
109 return errors.Newf("getIssueByID [%d]: %v", c.IssueID, err)
110 }
111 if c.Issue.Repo == nil {
112 c.Issue.Repo, err = getRepositoryByID(e, c.Issue.RepoID)
113 if err != nil {
114 return errors.Newf("getRepositoryByID [%d]: %v", c.Issue.RepoID, err)
115 }
116 }
117 }
118
119 if c.Attachments == nil {
120 c.Attachments, err = getAttachmentsByCommentID(e, c.ID)
121 if err != nil {
122 return errors.Newf("getAttachmentsByCommentID [%d]: %v", c.ID, err)
123 }
124 }
125
126 return nil
127}
128
129func (c *Comment) LoadAttributes() error {
130 return c.loadAttributes(x)

Callers 3

LoadAttributesMethod · 0.95
createCommentFunction · 0.95
loadCommentsAttributesFunction · 0.45

Calls 7

IsErrUserNotExistFunction · 0.85
NewGhostUserFunction · 0.85
getRawIssueByIDFunction · 0.85
getRepositoryByIDFunction · 0.85
UsersMethod · 0.80
GetByIDMethod · 0.65

Tested by

no test coverage detected