command line follow and unfollow
This commit is contained in:
parent
e8d1d64f1c
commit
e965f7090f
16
activity.go
16
activity.go
|
@ -1882,7 +1882,7 @@ func unfollowme(user *WhatAbout, who string, name string, j junk.Junk) {
|
|||
}
|
||||
}
|
||||
|
||||
func followyou(user *WhatAbout, honkerid int64) {
|
||||
func followyou(user *WhatAbout, honkerid int64, sync bool) {
|
||||
var url, owner string
|
||||
db := opendatabase()
|
||||
row := db.QueryRow("select xid, owner from honkers where honkerid = ? and userid = ? and flavor in ('unsub', 'peep', 'presub', 'sub')",
|
||||
|
@ -1899,10 +1899,14 @@ func followyou(user *WhatAbout, honkerid int64) {
|
|||
elog.Printf("error updating honker: %s", err)
|
||||
return
|
||||
}
|
||||
go subsub(user, url, owner, folxid)
|
||||
if sync {
|
||||
subsub(user, url, owner, folxid)
|
||||
} else {
|
||||
go subsub(user, url, owner, folxid)
|
||||
}
|
||||
|
||||
}
|
||||
func unfollowyou(user *WhatAbout, honkerid int64) {
|
||||
func unfollowyou(user *WhatAbout, honkerid int64, sync bool) {
|
||||
db := opendatabase()
|
||||
row := db.QueryRow("select xid, owner, folxid from honkers where honkerid = ? and userid = ? and flavor in ('sub')",
|
||||
honkerid, user.ID)
|
||||
|
@ -1918,7 +1922,11 @@ func unfollowyou(user *WhatAbout, honkerid int64) {
|
|||
elog.Printf("error updating honker: %s", err)
|
||||
return
|
||||
}
|
||||
go itakeitallback(user, url, owner, folxid)
|
||||
if sync {
|
||||
itakeitallback(user, url, owner, folxid)
|
||||
} else {
|
||||
go itakeitallback(user, url, owner, folxid)
|
||||
}
|
||||
}
|
||||
|
||||
func followyou2(user *WhatAbout, j junk.Junk) {
|
||||
|
|
|
@ -1002,9 +1002,6 @@ func savehonker(user *WhatAbout, url, name, flavor, combos, mj string) (int64, e
|
|||
return 0, err
|
||||
}
|
||||
honkerid, _ := res.LastInsertId()
|
||||
if flavor == "presub" {
|
||||
followyou(user, honkerid)
|
||||
}
|
||||
return honkerid, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -142,6 +142,11 @@ command.
|
|||
Users may be deleted with the
|
||||
.Ic deluser Ar username
|
||||
command.
|
||||
.Pp
|
||||
Follow and unfollow requests can be sent via command line with
|
||||
.Ic follow Ar username Ar url
|
||||
and
|
||||
.Ic unfollow Ar username Ar url .
|
||||
.Ss Maintenance
|
||||
The database may grow large over time.
|
||||
The
|
||||
|
|
36
honk.go
36
honk.go
|
@ -373,6 +373,42 @@ func main() {
|
|||
return
|
||||
}
|
||||
chpass(args[1])
|
||||
case "follow":
|
||||
if len(args) < 3 {
|
||||
fmt.Printf("usage: honk follow username url\n")
|
||||
return
|
||||
}
|
||||
user, err := butwhatabout(args[1])
|
||||
if err != nil {
|
||||
fmt.Printf("user not found")
|
||||
return
|
||||
}
|
||||
var meta HonkerMeta
|
||||
mj, _ := jsonify(&meta)
|
||||
honkerid, err := savehonker(user, args[2], "", "presub", "", mj)
|
||||
if err != nil {
|
||||
fmt.Printf("had some trouble with that: %s", err)
|
||||
return
|
||||
}
|
||||
followyou(user, honkerid, true)
|
||||
case "unfollow":
|
||||
if len(args) < 3 {
|
||||
fmt.Printf("usage: honk unfollow username url\n")
|
||||
return
|
||||
}
|
||||
user, err := butwhatabout(args[1])
|
||||
if err != nil {
|
||||
fmt.Printf("user not found")
|
||||
return
|
||||
}
|
||||
row := db.QueryRow("select honkerid from honkers where xid = ? and userid = ?", args[2], user.ID)
|
||||
var honkerid int64
|
||||
err = row.Scan(&honkerid)
|
||||
if err != nil {
|
||||
fmt.Printf("sorry couldn't find them")
|
||||
return
|
||||
}
|
||||
unfollowyou(user, honkerid, true)
|
||||
case "cleanup":
|
||||
arg := "30"
|
||||
if len(args) > 1 {
|
||||
|
|
9
web.go
9
web.go
|
@ -1923,15 +1923,15 @@ func submithonker(w http.ResponseWriter, r *http.Request) *Honker {
|
|||
|
||||
if honkerid > 0 {
|
||||
if r.FormValue("delete") == "delete" {
|
||||
unfollowyou(user, honkerid)
|
||||
unfollowyou(user, honkerid, false)
|
||||
stmtDeleteHonker.Exec(honkerid)
|
||||
return h
|
||||
}
|
||||
if r.FormValue("unsub") == "unsub" {
|
||||
unfollowyou(user, honkerid)
|
||||
unfollowyou(user, honkerid, false)
|
||||
}
|
||||
if r.FormValue("sub") == "sub" {
|
||||
followyou(user, honkerid)
|
||||
followyou(user, honkerid, false)
|
||||
}
|
||||
_, err := stmtUpdateHonker.Exec(name, combos, mj, honkerid, u.UserID)
|
||||
if err != nil {
|
||||
|
@ -1956,6 +1956,9 @@ func submithonker(w http.ResponseWriter, r *http.Request) *Honker {
|
|||
http.Error(w, "had some trouble with that: "+err.Error(), http.StatusInternalServerError)
|
||||
return nil
|
||||
}
|
||||
if flavor == "presub" {
|
||||
followyou(user, honkerid, false)
|
||||
}
|
||||
h.ID = id
|
||||
return h
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue