Implement admin media approval endpoints and add JWT role-based auth - NOT TESTED
This commit is contained in:
@@ -88,6 +88,8 @@ func (ps *PostService) InsertNewAccounts(newAccounts []models.Account) int {
|
||||
return int(ps.db.Clauses(clause.OnConflict{UpdateAll: true}).Create(&newAccounts).RowsAffected)
|
||||
}
|
||||
|
||||
// From this point on, its for the api endpoints
|
||||
|
||||
func (ps *PostService) GetRandomPost() models.Post {
|
||||
var post models.Post
|
||||
ps.db.
|
||||
@@ -98,6 +100,18 @@ func (ps *PostService) GetRandomPost() models.Post {
|
||||
return post
|
||||
}
|
||||
|
||||
func (ps *PostService) ApproveMedia(mediaId string) bool {
|
||||
return ps.db.Model(&models.MediaAttachment{}).
|
||||
Where("id = ?", mediaId).
|
||||
Update("approved", true).RowsAffected > 0
|
||||
}
|
||||
|
||||
func (ps *PostService) RejectMedia(mediaId string) bool {
|
||||
return ps.db.Model(&models.MediaAttachment{}).
|
||||
Where("id = ?", mediaId).
|
||||
Update("rejected", true).RowsAffected > 0
|
||||
}
|
||||
|
||||
func arrayContains(arr []string, str string) bool {
|
||||
for _, a := range arr {
|
||||
if a == str {
|
||||
|
||||
Reference in New Issue
Block a user