Skip to content

Commit b2400ba

Browse files
authored
Merge branch 'main' into custom-file-icon-2
2 parents 66db26b + ae63568 commit b2400ba

File tree

7 files changed

+205
-191
lines changed

7 files changed

+205
-191
lines changed

models/activities/action.go

Lines changed: 5 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import (
1616
"code.gitea.io/gitea/models/db"
1717
issues_model "code.gitea.io/gitea/models/issues"
1818
"code.gitea.io/gitea/models/organization"
19-
access_model "code.gitea.io/gitea/models/perm/access"
2019
repo_model "code.gitea.io/gitea/models/repo"
21-
"code.gitea.io/gitea/models/unit"
2220
user_model "code.gitea.io/gitea/models/user"
2321
"code.gitea.io/gitea/modules/git"
2422
"code.gitea.io/gitea/modules/log"
@@ -200,15 +198,13 @@ func (a *Action) LoadActUser(ctx context.Context) {
200198
}
201199
}
202200

203-
func (a *Action) LoadRepo(ctx context.Context) {
201+
func (a *Action) LoadRepo(ctx context.Context) error {
204202
if a.Repo != nil {
205-
return
203+
return nil
206204
}
207205
var err error
208206
a.Repo, err = repo_model.GetRepositoryByID(ctx, a.RepoID)
209-
if err != nil {
210-
log.Error("repo_model.GetRepositoryByID(%d): %v", a.RepoID, err)
211-
}
207+
return err
212208
}
213209

214210
// GetActFullName gets the action's user full name.
@@ -250,7 +246,7 @@ func (a *Action) GetActDisplayNameTitle(ctx context.Context) string {
250246

251247
// GetRepoUserName returns the name of the action repository owner.
252248
func (a *Action) GetRepoUserName(ctx context.Context) string {
253-
a.LoadRepo(ctx)
249+
_ = a.LoadRepo(ctx)
254250
if a.Repo == nil {
255251
return "(non-existing-repo)"
256252
}
@@ -265,7 +261,7 @@ func (a *Action) ShortRepoUserName(ctx context.Context) string {
265261

266262
// GetRepoName returns the name of the action repository.
267263
func (a *Action) GetRepoName(ctx context.Context) string {
268-
a.LoadRepo(ctx)
264+
_ = a.LoadRepo(ctx)
269265
if a.Repo == nil {
270266
return "(non-existing-repo)"
271267
}
@@ -567,130 +563,6 @@ func DeleteOldActions(ctx context.Context, olderThan time.Duration) (err error)
567563
return err
568564
}
569565

570-
// NotifyWatchers creates batch of actions for every watcher.
571-
// It could insert duplicate actions for a repository action, like this:
572-
// * Original action: UserID=1 (the real actor), ActUserID=1
573-
// * Organization action: UserID=100 (the repo's org), ActUserID=1
574-
// * Watcher action: UserID=20 (a user who is watching a repo), ActUserID=1
575-
func NotifyWatchers(ctx context.Context, actions ...*Action) error {
576-
var watchers []*repo_model.Watch
577-
var repo *repo_model.Repository
578-
var err error
579-
var permCode []bool
580-
var permIssue []bool
581-
var permPR []bool
582-
583-
e := db.GetEngine(ctx)
584-
585-
for _, act := range actions {
586-
repoChanged := repo == nil || repo.ID != act.RepoID
587-
588-
if repoChanged {
589-
// Add feeds for user self and all watchers.
590-
watchers, err = repo_model.GetWatchers(ctx, act.RepoID)
591-
if err != nil {
592-
return fmt.Errorf("get watchers: %w", err)
593-
}
594-
}
595-
596-
// Add feed for actioner.
597-
act.UserID = act.ActUserID
598-
if _, err = e.Insert(act); err != nil {
599-
return fmt.Errorf("insert new actioner: %w", err)
600-
}
601-
602-
if repoChanged {
603-
act.LoadRepo(ctx)
604-
repo = act.Repo
605-
606-
// check repo owner exist.
607-
if err := act.Repo.LoadOwner(ctx); err != nil {
608-
return fmt.Errorf("can't get repo owner: %w", err)
609-
}
610-
} else if act.Repo == nil {
611-
act.Repo = repo
612-
}
613-
614-
// Add feed for organization
615-
if act.Repo.Owner.IsOrganization() && act.ActUserID != act.Repo.Owner.ID {
616-
act.ID = 0
617-
act.UserID = act.Repo.Owner.ID
618-
if err = db.Insert(ctx, act); err != nil {
619-
return fmt.Errorf("insert new actioner: %w", err)
620-
}
621-
}
622-
623-
if repoChanged {
624-
permCode = make([]bool, len(watchers))
625-
permIssue = make([]bool, len(watchers))
626-
permPR = make([]bool, len(watchers))
627-
for i, watcher := range watchers {
628-
user, err := user_model.GetUserByID(ctx, watcher.UserID)
629-
if err != nil {
630-
permCode[i] = false
631-
permIssue[i] = false
632-
permPR[i] = false
633-
continue
634-
}
635-
perm, err := access_model.GetUserRepoPermission(ctx, repo, user)
636-
if err != nil {
637-
permCode[i] = false
638-
permIssue[i] = false
639-
permPR[i] = false
640-
continue
641-
}
642-
permCode[i] = perm.CanRead(unit.TypeCode)
643-
permIssue[i] = perm.CanRead(unit.TypeIssues)
644-
permPR[i] = perm.CanRead(unit.TypePullRequests)
645-
}
646-
}
647-
648-
for i, watcher := range watchers {
649-
if act.ActUserID == watcher.UserID {
650-
continue
651-
}
652-
act.ID = 0
653-
act.UserID = watcher.UserID
654-
act.Repo.Units = nil
655-
656-
switch act.OpType {
657-
case ActionCommitRepo, ActionPushTag, ActionDeleteTag, ActionPublishRelease, ActionDeleteBranch:
658-
if !permCode[i] {
659-
continue
660-
}
661-
case ActionCreateIssue, ActionCommentIssue, ActionCloseIssue, ActionReopenIssue:
662-
if !permIssue[i] {
663-
continue
664-
}
665-
case ActionCreatePullRequest, ActionCommentPull, ActionMergePullRequest, ActionClosePullRequest, ActionReopenPullRequest, ActionAutoMergePullRequest:
666-
if !permPR[i] {
667-
continue
668-
}
669-
}
670-
671-
if err = db.Insert(ctx, act); err != nil {
672-
return fmt.Errorf("insert new action: %w", err)
673-
}
674-
}
675-
}
676-
return nil
677-
}
678-
679-
// NotifyWatchersActions creates batch of actions for every watcher.
680-
func NotifyWatchersActions(ctx context.Context, acts []*Action) error {
681-
ctx, committer, err := db.TxContext(ctx)
682-
if err != nil {
683-
return err
684-
}
685-
defer committer.Close()
686-
for _, act := range acts {
687-
if err := NotifyWatchers(ctx, act); err != nil {
688-
return err
689-
}
690-
}
691-
return committer.Commit()
692-
}
693-
694566
// DeleteIssueActions delete all actions related with issueID
695567
func DeleteIssueActions(ctx context.Context, repoID, issueID, issueIndex int64) error {
696568
// delete actions assigned to this issue

models/activities/action_test.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -82,43 +82,6 @@ func TestActivityReadable(t *testing.T) {
8282
}
8383
}
8484

85-
func TestNotifyWatchers(t *testing.T) {
86-
assert.NoError(t, unittest.PrepareTestDatabase())
87-
88-
action := &activities_model.Action{
89-
ActUserID: 8,
90-
RepoID: 1,
91-
OpType: activities_model.ActionStarRepo,
92-
}
93-
assert.NoError(t, activities_model.NotifyWatchers(db.DefaultContext, action))
94-
95-
// One watchers are inactive, thus action is only created for user 8, 1, 4, 11
96-
unittest.AssertExistsAndLoadBean(t, &activities_model.Action{
97-
ActUserID: action.ActUserID,
98-
UserID: 8,
99-
RepoID: action.RepoID,
100-
OpType: action.OpType,
101-
})
102-
unittest.AssertExistsAndLoadBean(t, &activities_model.Action{
103-
ActUserID: action.ActUserID,
104-
UserID: 1,
105-
RepoID: action.RepoID,
106-
OpType: action.OpType,
107-
})
108-
unittest.AssertExistsAndLoadBean(t, &activities_model.Action{
109-
ActUserID: action.ActUserID,
110-
UserID: 4,
111-
RepoID: action.RepoID,
112-
OpType: action.OpType,
113-
})
114-
unittest.AssertExistsAndLoadBean(t, &activities_model.Action{
115-
ActUserID: action.ActUserID,
116-
UserID: 11,
117-
RepoID: action.RepoID,
118-
OpType: action.OpType,
119-
})
120-
}
121-
12285
func TestConsistencyUpdateAction(t *testing.T) {
12386
if !setting.Database.Type.IsSQLite3() {
12487
t.Skip("Test is only for SQLite database.")

options/locale/locale_de-DE.ini

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ license_desc=Hol dir den Code unter <a target="_blank" rel="noopener noreferrer"
245245

246246
[install]
247247
install=Installation
248+
installing_desc=Wird jetzt installiert, bitte warten...
248249
title=Erstkonfiguration
249250
docker_helper=Wenn du Gitea in einem Docker-Container nutzt, lies bitte die <a target="_blank" rel="noopener noreferrer" href="%s">Dokumentation</a>, bevor du irgendwelche Einstellungen veränderst.
250251
require_db_desc=Gitea benötigt MySQL, PostgreSQL, MSSQL, SQLite3 oder TiDB (MySQL-Protokoll).
@@ -384,6 +385,12 @@ show_only_public=Nur öffentliche anzeigen
384385

385386
issues.in_your_repos=Eigene Repositories
386387

388+
guide_title=Keine Aktivität
389+
guide_desc=Du folgst derzeit keinen Repositories oder Benutzern, sodass es keinen Inhalt zum Anzeigen gibt. Du kannst Repositories oder Benutzer von Interesse über die untenstehenden Links erkunden.
390+
explore_repos=Repositories erkunden
391+
explore_users=Benutzer erkunden
392+
empty_org=Es gibt noch keine Organisationen.
393+
empty_repo=Es gibt noch keine Repositories.
387394

388395
[explore]
389396
repos=Repositories
@@ -1685,6 +1692,7 @@ issues.time_estimate_invalid=Format der Zeitschätzung ist ungültig
16851692
issues.start_tracking_history=hat die Zeiterfassung %s gestartet
16861693
issues.tracker_auto_close=Der Timer wird automatisch gestoppt, wenn dieser Issue geschlossen wird
16871694
issues.tracking_already_started=`Du hast die Zeiterfassung bereits in <a href="%s">diesem Issue</a> gestartet!`
1695+
issues.cancel_tracking=Verwerfen
16881696
issues.cancel_tracking_history=`hat die Zeiterfassung %s abgebrochen`
16891697
issues.del_time=Diese Zeiterfassung löschen
16901698
issues.del_time_history=`hat %s gearbeitete Zeit gelöscht`
@@ -2854,6 +2862,13 @@ teams.invite.by=Von %s eingeladen
28542862
teams.invite.description=Bitte klicke auf die folgende Schaltfläche, um dem Team beizutreten.
28552863

28562864

2865+
worktime.date_range_start=Startdatum
2866+
worktime.date_range_end=Enddatum
2867+
worktime.query=Abfrage
2868+
worktime.time=Zeit
2869+
worktime.by_repositories=Nach Repositories
2870+
worktime.by_milestones=Nach Meilensteinen
2871+
worktime.by_members=Nach Mitgliedern
28572872

28582873
[admin]
28592874
maintenance=Wartung
@@ -3709,7 +3724,7 @@ runners.delete_runner_header=Bestätigen, um diesen Runner zu löschen
37093724
runners.delete_runner_notice=Wenn eine Aufgabe auf diesem Runner ausgeführt wird, wird sie beendet und als fehlgeschlagen markiert. Dies könnte Workflows zerstören.
37103725
runners.none=Keine Runner verfügbar
37113726
runners.status.unspecified=Unbekannt
3712-
runners.status.idle=Inaktiv
3727+
runners.status.idle=Leerlauf
37133728
runners.status.active=Aktiv
37143729
runners.status.offline=Offline
37153730
runners.version=Version

routers/web/feed/convert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func toReleaseLink(ctx *context.Context, act *activities_model.Action) string {
5050

5151
// renderCommentMarkdown renders the comment markdown to html
5252
func renderCommentMarkdown(ctx *context.Context, act *activities_model.Action, content string) template.HTML {
53-
act.LoadRepo(ctx)
53+
_ = act.LoadRepo(ctx)
5454
if act.Repo == nil {
5555
return ""
5656
}

0 commit comments

Comments
 (0)