]> source.dussan.org Git - gitea.git/commitdiff
Show private heatmap on profile to self & admins (#14881)
authorNorwin <noerw@users.noreply.github.com>
Thu, 4 Mar 2021 22:59:13 +0000 (22:59 +0000)
committerGitHub <noreply@github.com>
Thu, 4 Mar 2021 22:59:13 +0000 (23:59 +0100)
followup to #14080

integrations/privateactivity_test.go
routers/user/home.go
routers/user/profile.go

index 381cb6b3386240a3021e61dd756e4e4d15c5ac31..23c6a7e8ccf4e775348096b6e390de9aa3a9efaf 100644 (file)
@@ -268,9 +268,6 @@ func TestPrivateActivityNoHeatmapVisibleForAdmin(t *testing.T) {
 }
 
 // check heatmap visibility if the visibility is disabled
-// this behavior, in special the one for the admin, is
-// due to the fact that the heatmap is the same for all viewers;
-// otherwise, there is no reason for it
 
 func TestPrivateActivityYesHeatmapInvisibleForPublic(t *testing.T) {
        defer prepareTestEnv(t)()
@@ -282,7 +279,7 @@ func TestPrivateActivityYesHeatmapInvisibleForPublic(t *testing.T) {
        assert.False(t, visible, "user should have no visible heatmap")
 }
 
-func TestPrivateActivityYesHeatmapInvisibleForUserItselfAtProfile(t *testing.T) {
+func TestPrivateActivityYesHeatmapVisibleForUserItselfAtProfile(t *testing.T) {
        defer prepareTestEnv(t)()
        testPrivateActivityDoSomethingForActionEntries(t)
        testPrivateActivityHelperEnablePrivateActivity(t)
@@ -290,10 +287,10 @@ func TestPrivateActivityYesHeatmapInvisibleForUserItselfAtProfile(t *testing.T)
        session := loginUser(t, privateActivityTestUser)
        visible := testPrivateActivityHelperHasVisibleProfileHeatmapFromSession(t, session)
 
-       assert.False(t, visible, "user should have no visible heatmap")
+       assert.True(t, visible, "user should have visible heatmap")
 }
 
-func TestPrivateActivityYesHeatmapInvisibleForUserItselfAtDashboard(t *testing.T) {
+func TestPrivateActivityYesHeatmapVisibleForUserItselfAtDashboard(t *testing.T) {
        defer prepareTestEnv(t)()
        testPrivateActivityDoSomethingForActionEntries(t)
        testPrivateActivityHelperEnablePrivateActivity(t)
@@ -301,7 +298,7 @@ func TestPrivateActivityYesHeatmapInvisibleForUserItselfAtDashboard(t *testing.T
        session := loginUser(t, privateActivityTestUser)
        visible := testPrivateActivityHelperHasVisibleDashboardHeatmapFromSession(t, session)
 
-       assert.False(t, visible, "user should have no visible heatmap")
+       assert.True(t, visible, "user should have visible heatmap")
 }
 
 func TestPrivateActivityYesHeatmapInvisibleForOtherUser(t *testing.T) {
@@ -315,7 +312,7 @@ func TestPrivateActivityYesHeatmapInvisibleForOtherUser(t *testing.T) {
        assert.False(t, visible, "user should have no visible heatmap")
 }
 
-func TestPrivateActivityYesHeatmapInvsisibleForAdmin(t *testing.T) {
+func TestPrivateActivityYesHeatmapVisibleForAdmin(t *testing.T) {
        defer prepareTestEnv(t)()
        testPrivateActivityDoSomethingForActionEntries(t)
        testPrivateActivityHelperEnablePrivateActivity(t)
@@ -323,7 +320,7 @@ func TestPrivateActivityYesHeatmapInvsisibleForAdmin(t *testing.T) {
        session := loginUser(t, privateActivityTestAdmin)
        visible := testPrivateActivityHelperHasVisibleProfileHeatmapFromSession(t, session)
 
-       assert.False(t, visible, "user should have no visible heatmap")
+       assert.True(t, visible, "user should have visible heatmap")
 }
 
 // check heatmap api provides content if the visibility is enabled
index 9957ec6b02b4d04337c3a0419b141186767b75c6..886c4ab1baaa2bc04a513ed1e83ae2cc76dca4eb 100644 (file)
@@ -104,9 +104,7 @@ func Dashboard(ctx *context.Context) {
        ctx.Data["PageIsNews"] = true
        ctx.Data["SearchLimit"] = setting.UI.User.RepoPagingNum
 
-       // no heatmap access for admins; GetUserHeatmapDataByUser ignores the calling user
-       // so everyone would get the same empty heatmap
-       if setting.Service.EnableUserHeatmap && !ctxUser.KeepActivityPrivate {
+       if setting.Service.EnableUserHeatmap {
                data, err := models.GetUserHeatmapDataByUserTeam(ctxUser, ctx.Org.Team, ctx.User)
                if err != nil {
                        ctx.ServerError("GetUserHeatmapDataByUserTeam", err)
index 5dfee07d7622f48afe0eb17e4acaa43a8d5e011d..ea4a1e889346687abbe70c32bea2b2f0df54e65c 100644 (file)
@@ -99,9 +99,7 @@ func Profile(ctx *context.Context) {
        ctx.Data["Owner"] = ctxUser
        ctx.Data["OpenIDs"] = openIDs
 
-       // no heatmap access for admins; GetUserHeatmapDataByUser ignores the calling user
-       // so everyone would get the same empty heatmap
-       if setting.Service.EnableUserHeatmap && !ctxUser.KeepActivityPrivate {
+       if setting.Service.EnableUserHeatmap {
                data, err := models.GetUserHeatmapDataByUser(ctxUser, ctx.User)
                if err != nil {
                        ctx.ServerError("GetUserHeatmapDataByUser", err)