mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
adding reporting endpoints required by android
This commit is contained in:
parent
ccf84790b0
commit
126866e5fa
29
net/server/internal/api_addFlag.go
Normal file
29
net/server/internal/api_addFlag.go
Normal 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)
|
||||
}
|
@ -265,6 +265,13 @@ var endpoints = routes{
|
||||
SetNodeStatus,
|
||||
},
|
||||
|
||||
route{
|
||||
"AddFlag",
|
||||
strings.ToUpper("Post"),
|
||||
"/account/flag/{guid}",
|
||||
AddFlag,
|
||||
},
|
||||
|
||||
route{
|
||||
"AddGroup",
|
||||
strings.ToUpper("Post"),
|
||||
|
@ -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"`
|
||||
|
Loading…
Reference in New Issue
Block a user