mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
Watch backend
This commit is contained in:
parent
8b0f421eb5
commit
a922c3ff6a
7 changed files with 44 additions and 13 deletions
|
@ -88,7 +88,8 @@ func setEngine() {
|
|||
|
||||
func init() {
|
||||
setEngine()
|
||||
if err := orm.Sync(new(User), new(PublicKey), new(Repository), new(Access), new(Action)); err != nil {
|
||||
if err := orm.Sync(new(User), new(PublicKey), new(Repository), new(Access),
|
||||
new(Action), new(Watch)); err != nil {
|
||||
fmt.Printf("sync database struct error: %v\n", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
|
|
@ -43,11 +43,20 @@ type Repository struct {
|
|||
Updated time.Time `xorm:"updated"`
|
||||
}
|
||||
|
||||
type Star struct {
|
||||
Id int64
|
||||
RepoId int64
|
||||
UserId int64
|
||||
Created time.Time `xorm:"created"`
|
||||
// Watch is connection request for receiving repository notifycation.
|
||||
type Watch struct {
|
||||
Id int64
|
||||
RepoId int64 `xorm:"UNIQUE(watch)"`
|
||||
UserId int64 `xorm:"UNIQUE(watch)"`
|
||||
}
|
||||
|
||||
func WatchRepo(userId, repoId int64, watch bool) (err error) {
|
||||
if watch {
|
||||
_, err = orm.Insert(&Watch{RepoId: repoId, UserId: userId})
|
||||
} else {
|
||||
_, err = orm.Delete(&Watch{0, repoId, userId})
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue