adding reporting endpoints required by android

This commit is contained in:
Roland Osborne 2022-10-30 23:28:46 -07:00
parent ccf84790b0
commit 126866e5fa
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package databag
import (
"databag/internal/store"
"github.com/gorilla/mux"
"net/http"
)
//AddFlag adds a UGC alert for specified account and or content
func AddFlag(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
guid := params["guid"]
channel := r.FormValue("channel")
topic := r.FormValue("topic")
flag := &store.Flag{
GUID: guid,
ChannelSlotID: channel,
TopicSlotID: topic,
}
if res := store.DB.Save(flag).Error; res != nil {
ErrResponse(w, http.StatusInternalServerError, res)
return
}
WriteResponse(w, nil)
}

View File

@ -265,6 +265,13 @@ var endpoints = routes{
SetNodeStatus,
},
route{
"AddFlag",
strings.ToUpper("Post"),
"/account/flag/{guid}",
AddFlag,
},
route{
"AddGroup",
strings.ToUpper("Post"),

View File

@ -22,6 +22,7 @@ func AutoMigrate(db *gorm.DB) {
db.AutoMigrate(&Asset{});
db.AutoMigrate(&TagSlot{});
db.AutoMigrate(&Tag{});
db.AutoMigrate(&Flag{});
}
type Notification struct {
@ -52,6 +53,13 @@ type AccountToken struct {
Account *Account
}
type Flag struct {
ID uint `gorm:"primaryKey;not null;unique;autoIncrement"`
GUID string `gorm:"not null;"`
ChannelSlotID string
TopicSlotID string
}
type Account struct {
ID uint `gorm:"primaryKey;not null;unique;autoIncrement"`
AccountDetailID uint `gorm:"not null"`