Skip to content
Open
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions server/route/api/v1/shortcut_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,17 @@ func (s *APIV1Service) GetShortcutAnalytics(ctx context.Context, request *v1pb.G
return nil, status.Errorf(codes.NotFound, "shortcut not found")
}

// Analytics (referrers, device/browser breakdown) are more sensitive than
// the shortcut's own visibility setting governs, so restrict to the
// shortcut's creator or an admin, matching UpdateShortcut/DeleteShortcut.
user, err := getCurrentUser(ctx, s.Store)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err)
}
if user == nil || (shortcut.CreatorId != user.ID && user.Role != store.RoleAdmin) {
return nil, status.Errorf(codes.PermissionDenied, "Permission denied")
}

activityFind := &store.FindActivity{
Type: store.ActivityShortcutView,
PayloadShortcutID: &shortcut.Id,
Expand Down