mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-28 12:16:17 +01:00
Update action struct
This commit is contained in:
parent
3005a0f13e
commit
ea765d25e2
3 changed files with 16 additions and 39 deletions
|
@ -5,7 +5,6 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -21,30 +20,24 @@ const (
|
|||
|
||||
// An Action represents
|
||||
type Action struct {
|
||||
Id int64
|
||||
UserId int64
|
||||
OpType int
|
||||
RepoId int64
|
||||
Content string
|
||||
Created time.Time `xorm:"created"`
|
||||
}
|
||||
|
||||
type NewRepoContent struct {
|
||||
Id int64
|
||||
UserId int64
|
||||
UserName string
|
||||
OpType int
|
||||
RepoId int64
|
||||
RepoName string
|
||||
Content string
|
||||
Created time.Time `xorm:"created"`
|
||||
}
|
||||
|
||||
// NewRepoAction inserts action for create repository.
|
||||
func NewRepoAction(user *User, repo *Repository) error {
|
||||
content, err := json.Marshal(&NewRepoContent{user.Name, repo.Name})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = orm.InsertOne(&Action{
|
||||
UserId: user.Id,
|
||||
OpType: OP_CREATE_REPO,
|
||||
RepoId: repo.Id,
|
||||
Content: string(content),
|
||||
_, err := orm.InsertOne(&Action{
|
||||
UserId: user.Id,
|
||||
UserName: user.Name,
|
||||
OpType: OP_CREATE_REPO,
|
||||
RepoId: repo.Id,
|
||||
RepoName: repo.Name,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
|
||||
"github.com/codegangsta/martini"
|
||||
|
@ -167,20 +166,10 @@ func Delete(data base.TmplData, req *http.Request, session sessions.Session, r r
|
|||
r.HTML(200, "user/delete", data)
|
||||
}
|
||||
|
||||
func Feeds(form auth.FeedsForm, r render.Render) string {
|
||||
func Feeds(form auth.FeedsForm, r render.Render) {
|
||||
actions, err := models.GetFeeds(form.UserId, form.Offset)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
r.JSON(500, err)
|
||||
}
|
||||
|
||||
length := len(actions)
|
||||
buf := bytes.NewBuffer([]byte("["))
|
||||
for i, action := range actions {
|
||||
buf.WriteString(action.Content)
|
||||
if i < length-1 {
|
||||
buf.WriteString(",")
|
||||
}
|
||||
}
|
||||
buf.WriteString("]")
|
||||
return buf.String()
|
||||
r.JSON(200, actions)
|
||||
}
|
||||
|
|
7
web.go
7
web.go
|
@ -30,10 +30,7 @@ var CmdWeb = cli.Command{
|
|||
Description: `
|
||||
gogs web`,
|
||||
Action: runWeb,
|
||||
Flags: []cli.Flag{
|
||||
//cli.BoolFlag{"update, u", "update pakcage(s) and dependencies if any"},
|
||||
//cli.BoolFlag{"verbose, v", "show process details"},
|
||||
},
|
||||
Flags: []cli.Flag{},
|
||||
}
|
||||
|
||||
var AppHelpers template.FuncMap = map[string]interface{}{
|
||||
|
@ -78,8 +75,6 @@ func runWeb(*cli.Context) {
|
|||
|
||||
//m.Get("/:username/:reponame", repo.Repo)
|
||||
|
||||
//m.Get("/:username/:reponame", repo.Repo)
|
||||
|
||||
listenAddr := fmt.Sprintf("%s:%s",
|
||||
base.Cfg.MustValue("server", "HTTP_ADDR"),
|
||||
base.Cfg.MustValue("server", "HTTP_PORT", "3000"))
|
||||
|
|
Loading…
Reference in a new issue