✨ Separate news permission level
This commit is contained in:
parent
a9b8fbf558
commit
48b2a8d470
@ -1,10 +1,11 @@
|
||||
package models
|
||||
|
||||
type NewsSource struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Type string `json:"type"`
|
||||
Source string `json:"source"`
|
||||
Depth int `json:"depth"`
|
||||
Enabled bool `json:"enabled"`
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Type string `json:"type"`
|
||||
Source string `json:"source"`
|
||||
Depth int `json:"depth"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Advanced bool `json:"advanced"`
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"git.solsynth.dev/hypernet/reader/pkg/internal/services"
|
||||
"time"
|
||||
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||
@ -48,6 +49,19 @@ func listNewsArticles(c *fiber.Ctx) error {
|
||||
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
|
||||
countTx := tx
|
||||
if err := countTx.Model(&models.NewsArticle{}).Count(&count).Error; err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user