@@ -115,15 +115,13 @@ type Conversation struct {
115115
116116 IsLocked bool `xorm:"-"`
117117
118- Comments CommentList `xorm:"-"`
119- Attachments []* repo_model.Attachment `xorm:"-"`
120- isAttachmentsLoaded bool `xorm:"-"`
118+ Comments CommentList `xorm:"-"`
121119
122120 CommitSha string `xorm:"VARCHAR(64)"`
123121 IsRead bool `xorm:"-"`
124122}
125123
126- // IssueIndex represents the issue index table
124+ // ConversationIndex represents the conversation index table
127125type ConversationIndex db.ResourceIndex
128126
129127func init () {
@@ -173,7 +171,7 @@ func GetConversationByID(ctx context.Context, id int64) (*Conversation, error) {
173171 return conversation , nil
174172}
175173
176- // GetIssueByIndex returns raw issue without loading attributes by index in a repository.
174+ // GetConversationByIndex returns raw conversation without loading attributes by index in a repository.
177175func GetConversationByIndex (ctx context.Context , repoID , index int64 ) (* Conversation , error ) {
178176 if index < 1 {
179177 return nil , ErrConversationNotExist {}
@@ -202,10 +200,6 @@ func (conversation *Conversation) LoadAttributes(ctx context.Context) (err error
202200 return err
203201 }
204202
205- if err = conversation .LoadAttachments (ctx ); err != nil {
206- return err
207- }
208-
209203 if err = conversation .loadComments (ctx ); err != nil {
210204 return err
211205 }
@@ -228,51 +222,38 @@ func (conversation *Conversation) LoadRepo(ctx context.Context) (err error) {
228222 return nil
229223}
230224
231- func (conversation * Conversation ) LoadAttachments (ctx context.Context ) (err error ) {
232- if conversation .isAttachmentsLoaded || conversation .Attachments != nil {
233- return nil
234- }
235-
236- conversation .Attachments , err = repo_model .GetAttachmentsByConversationID (ctx , conversation .ID )
237- if err != nil {
238- return fmt .Errorf ("getAttachmentsByConversationID [%d]: %w" , conversation .ID , err )
239- }
240- conversation .isAttachmentsLoaded = true
241- return nil
242- }
243-
244225// GetConversationIDsByRepoID returns all conversation ids by repo id
245226func GetConversationIDsByRepoID (ctx context.Context , repoID int64 ) ([]int64 , error ) {
246227 ids := make ([]int64 , 0 , 10 )
247228 err := db .GetEngine (ctx ).Table ("conversation" ).Cols ("id" ).Where ("repo_id = ?" , repoID ).Find (& ids )
248229 return ids , err
249230}
250231
251- // GetConversationsByIDs return issues with the given IDs.
232+ // GetConversationsByIDs return conversations with the given IDs.
252233// If keepOrder is true, the order of the returned Conversations will be the same as the given IDs.
253- func GetConversationsByIDs (ctx context.Context , issueIDs []int64 , keepOrder ... bool ) (ConversationList , error ) {
254- issues := make ([]* Conversation , 0 , len (issueIDs ))
234+ func GetConversationsByIDs (ctx context.Context , conversationIDs []int64 , keepOrder ... bool ) (ConversationList , error ) {
235+ conversations := make ([]* Conversation , 0 , len (conversationIDs ))
255236
256- if err := db .GetEngine (ctx ).In ("id" , issueIDs ).Find (& issues ); err != nil {
237+ if err := db .GetEngine (ctx ).In ("id" , conversationIDs ).Find (& conversations ); err != nil {
257238 return nil , err
258239 }
259240
260241 if len (keepOrder ) > 0 && keepOrder [0 ] {
261- m := make (map [int64 ]* Conversation , len (issues ))
242+ m := make (map [int64 ]* Conversation , len (conversations ))
262243 appended := container.Set [int64 ]{}
263- for _ , issue := range issues {
264- m [issue .ID ] = issue
244+ for _ , conversation := range conversations {
245+ m [conversation .ID ] = conversation
265246 }
266- issues = issues [:0 ]
267- for _ , id := range issueIDs {
268- if issue , ok := m [id ]; ok && ! appended .Contains (id ) { // make sure the id is existed and not appended
247+ conversations = conversations [:0 ]
248+ for _ , id := range conversationIDs {
249+ if conversation , ok := m [id ]; ok && ! appended .Contains (id ) { // make sure the id is existed and not appended
269250 appended .Add (id )
270- issues = append (issues , issue )
251+ conversations = append (conversations , conversation )
271252 }
272253 }
273254 }
274255
275- return issues , nil
256+ return conversations , nil
276257}
277258
278259func GetConversationByCommitID (ctx context.Context , commitID string ) (* Conversation , error ) {
@@ -318,7 +299,7 @@ func (conversation *Conversation) HTMLURL() string {
318299 return fmt .Sprintf ("%s/%s/%s" , conversation .Repo .HTMLURL (), "commit" , conversation .CommitSha )
319300}
320301
321- // APIURL returns the absolute APIURL to this issue .
302+ // APIURL returns the absolute APIURL to this conversation .
322303func (conversation * Conversation ) APIURL (ctx context.Context ) string {
323304 if conversation .Repo == nil {
324305 err := conversation .LoadRepo (ctx )
0 commit comments