✨ Separate news permission level
This commit is contained in:
		| @@ -7,4 +7,5 @@ type NewsSource struct { | |||||||
| 	Source   string `json:"source"` | 	Source   string `json:"source"` | ||||||
| 	Depth    int    `json:"depth"` | 	Depth    int    `json:"depth"` | ||||||
| 	Enabled  bool   `json:"enabled"` | 	Enabled  bool   `json:"enabled"` | ||||||
|  | 	Advanced bool   `json:"advanced"` | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package api | package api | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"git.solsynth.dev/hypernet/reader/pkg/internal/services" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"git.solsynth.dev/hypernet/nexus/pkg/nex/sec" | 	"git.solsynth.dev/hypernet/nexus/pkg/nex/sec" | ||||||
| @@ -48,6 +49,19 @@ func listNewsArticles(c *fiber.Ctx) error { | |||||||
| 		tx = tx.Where("source = ?", source) | 		tx = tx.Where("source = ?", source) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	isAdvanced := false | ||||||
|  | 	if err := sec.EnsureGrantedPerm(c, "ListNewsAdvanced", true); err == nil { | ||||||
|  | 		isAdvanced = true | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	var sources []string | ||||||
|  | 	for _, srv := range services.NewsSources { | ||||||
|  | 		if !isAdvanced && srv.Advanced { | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
|  | 		sources = append(sources, srv.ID) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	var count int64 | 	var count int64 | ||||||
| 	countTx := tx | 	countTx := tx | ||||||
| 	if err := countTx.Model(&models.NewsArticle{}).Count(&count).Error; err != nil { | 	if err := countTx.Model(&models.NewsArticle{}).Count(&count).Error; err != nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user