Skip to content

Add comments to commit pages #32384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 80 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
6051ff8
Decouple conversations from issues
RedCocoon Oct 20, 2024
c511070
Add backend functionalities to create and display conversations
RedCocoon Oct 24, 2024
c55ca5d
Allow creation of commit comments
RedCocoon Oct 25, 2024
637788b
Reimplement delete comment for conversations
RedCocoon Oct 28, 2024
bb94379
Reimplement reactions and delete, fixed conversation styling css
RedCocoon Oct 29, 2024
17fb682
Reimplement quote reply and translation text
RedCocoon Oct 29, 2024
692f0aa
Reimplement edit comment for conversations
RedCocoon Oct 29, 2024
bea92f6
Add insertconversationcomments
RedCocoon Oct 29, 2024
7b263cd
Merge branch 'go-gitea:main' into main
RedCocoon Oct 29, 2024
95c57a1
Clean up code based on lint
RedCocoon Oct 30, 2024
c039238
Merge branch 'main' of https://github.com/RedCocoon/gitea
RedCocoon Oct 30, 2024
505a230
Update copyright informations
RedCocoon Oct 30, 2024
abc5d12
Merge branch 'main' into main
RedCocoon Oct 30, 2024
5ba8ae1
Remove unnecessary data from Conversation
RedCocoon Oct 30, 2024
fddda21
Fix comment form orphan tag issue with lint
RedCocoon Oct 30, 2024
1eff5bb
Remove unnecessary data from comment
RedCocoon Oct 30, 2024
ab083c8
Remove unused struct, fix duplicate table name
RedCocoon Oct 31, 2024
60b750e
Remove duplicate functions
RedCocoon Oct 31, 2024
b1af5cd
Rename variables in conversation.go
RedCocoon Oct 31, 2024
8509c5c
Generate Swagger
RedCocoon Oct 31, 2024
b03448b
Revert variable name to adhere to codestyle
RedCocoon Oct 31, 2024
706b919
make fmt and add option to swagger
RedCocoon Oct 31, 2024
6976590
Update v1_json.tmpl
RedCocoon Nov 1, 2024
2084a7a
Remove unneccessary api calls
RedCocoon Nov 1, 2024
940fa35
Change v1_json.tmpl
RedCocoon Nov 1, 2024
98baaa2
Consolidate reaction web/repo logic
RedCocoon Nov 1, 2024
5a49efb
Update reaction.go to conform to lint revive
RedCocoon Nov 1, 2024
933b4b4
Add copyright information to reaction.go
RedCocoon Nov 1, 2024
e344e37
Add unit test for conversations
RedCocoon Nov 3, 2024
5d7dcdf
Add unit test for comments
RedCocoon Nov 3, 2024
b1f07f2
Add unit test for comments
RedCocoon Nov 3, 2024
3327b83
Merge branch 'main' of https://github.com/RedCocoon/gitea
RedCocoon Nov 3, 2024
2ba22a8
Merge remote-tracking branch 'upstream/main'
RedCocoon Nov 3, 2024
56fca5e
Fix LoadPosters remove from conversation comment list
RedCocoon Nov 3, 2024
8b68cc8
Fix warning lines and remove unused variables
RedCocoon Nov 3, 2024
ed576c2
Fix lint backend compliance issues
RedCocoon Nov 3, 2024
34c0068
Update pull_review_test.go to add new data to ctx
RedCocoon Nov 3, 2024
13e8d84
Undo adding unnecessary ctx Data
RedCocoon Nov 3, 2024
f2fc87b
Load PR attachments before assigning value
RedCocoon Nov 4, 2024
b2a93cd
Remove unused data from indexer/search
RedCocoon Nov 4, 2024
6f9647b
Remove invalid options from conversation_stat.go
RedCocoon Nov 4, 2024
0d65d71
Load issue attributes instead of only loading pullrequest details
RedCocoon Nov 4, 2024
5b9049d
Add ShouldShowCommentType function when rendering pull review convers…
RedCocoon Nov 4, 2024
8e012eb
add comments for testing conversation search
RedCocoon Nov 4, 2024
2585c8b
Merge remote-tracking branch 'upstream/main'
RedCocoon Nov 4, 2024
a3e5eaf
Revert "Merge remote-tracking branch 'upstream/main'"
RedCocoon Nov 4, 2024
19ba51f
Change comment type 22 to refer to the correct template
RedCocoon Nov 4, 2024
c7c1010
Reapply "Merge remote-tracking branch 'upstream/main'"
RedCocoon Nov 4, 2024
5ea9292
Update issue header comment to use new time formatter
RedCocoon Nov 5, 2024
3a8cade
Update issue_header_comment.tmpl
RedCocoon Nov 5, 2024
c1735ac
Merge remote-tracking branch 'upstream/main'
RedCocoon Nov 5, 2024
0e10d6d
Fix pull_review.go referring to the wrong template
RedCocoon Nov 5, 2024
bedd7ec
Add fixtures for conversation, comments, reactions
RedCocoon Nov 6, 2024
ac4152d
Update conversation_comment.yml
RedCocoon Nov 6, 2024
d9ef4e4
Update comment count correctly when adding/removing comments
RedCocoon Nov 6, 2024
e3b51e8
Fix conversation comment
RedCocoon Nov 6, 2024
cb05620
Update conversation_test.go
RedCocoon Nov 6, 2024
18d0f3a
Fix indexer querying wrong column
RedCocoon Nov 6, 2024
991618c
Add conversation index yml, fix indexing unavailable columns
RedCocoon Nov 7, 2024
f65f92c
Merge remote-tracking branch 'upstream/main'
RedCocoon Nov 7, 2024
6d8d5ad
Update comments.tmpl
RedCocoon Nov 7, 2024
cd41147
Update conversation_stat.go
RedCocoon Nov 7, 2024
948ef91
Update conversation_stat.go
RedCocoon Nov 7, 2024
b762846
Update conversation.go
RedCocoon Nov 7, 2024
0cdfa15
Fix incorrect data in conversation fixture
RedCocoon Nov 7, 2024
519ca72
Update conversation.go
RedCocoon Nov 7, 2024
2311318
Fix data assignment for unit test
RedCocoon Nov 7, 2024
703f13b
Update db.go
RedCocoon Nov 7, 2024
93e125e
Update db.go
RedCocoon Nov 7, 2024
dc10ad9
Add tests for conversation indexer
RedCocoon Nov 7, 2024
0b33898
Update conversation_comment.yml
RedCocoon Nov 7, 2024
59732a9
Update conversation.go
RedCocoon Nov 7, 2024
0d80405
Fix comment xorm
RedCocoon Nov 7, 2024
6f9c81f
Update comment.go
RedCocoon Nov 7, 2024
13ddbd1
fix wrong xorg type
RedCocoon Nov 7, 2024
e38b875
Update consistency.go
RedCocoon Nov 7, 2024
05f6e61
Update consistency.go
RedCocoon Nov 7, 2024
dda6b57
update conversation fixture comment amount
RedCocoon Nov 7, 2024
e6d5fcd
Remove conversation indexer
RedCocoon Nov 9, 2024
d3aad28
Update conversation.go
RedCocoon Nov 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions models/activities/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/url"
"strconv"

conversations_model "code.gitea.io/gitea/models/conversations"
"code.gitea.io/gitea/models/db"
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/models/organization"
Expand Down Expand Up @@ -159,6 +160,16 @@ func GetIssueNotification(ctx context.Context, userID, issueID int64) (*Notifica
return notification, err
}

// GetConversationNotification return the notification about an conversation
func GetConversationNotification(ctx context.Context, userID, conversationID int64) (*Notification, error) {
notification := new(Notification)
_, err := db.GetEngine(ctx).
Where("user_id = ?", userID).
And("conversation_id = ?", conversationID).
Get(notification)
return notification, err
}

// LoadAttributes load Repo Issue User and Comment if not loaded
func (n *Notification) LoadAttributes(ctx context.Context) (err error) {
if err = n.loadRepo(ctx); err != nil {
Expand Down Expand Up @@ -322,6 +333,32 @@ func setIssueNotificationStatusReadIfUnread(ctx context.Context, userID, issueID
return err
}

// SetConversationReadBy sets conversation to be read by given user.
func SetConversationReadBy(ctx context.Context, conversationID, userID int64) error {
if err := conversations_model.UpdateConversationUserByRead(ctx, userID, conversationID); err != nil {
return err
}

return setConversationNotificationStatusReadIfUnread(ctx, userID, conversationID)
}

func setConversationNotificationStatusReadIfUnread(ctx context.Context, userID, conversationID int64) error {
notification, err := GetConversationNotification(ctx, userID, conversationID)
// ignore if not exists
if err != nil {
return nil
}

if notification.Status != NotificationStatusUnread {
return nil
}

notification.Status = NotificationStatusRead

_, err = db.GetEngine(ctx).ID(notification.ID).Cols("status").Update(notification)
return err
}

// SetRepoReadBy sets repo to be visited by given user.
func SetRepoReadBy(ctx context.Context, userID, repoID int64) error {
_, err := db.GetEngine(ctx).Where(builder.Eq{
Expand Down
Loading
Loading