command line follow and unfollow
This commit is contained in:
parent
e8d1d64f1c
commit
e965f7090f
12
activity.go
12
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
|
var url, owner string
|
||||||
db := opendatabase()
|
db := opendatabase()
|
||||||
row := db.QueryRow("select xid, owner from honkers where honkerid = ? and userid = ? and flavor in ('unsub', 'peep', 'presub', 'sub')",
|
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)
|
elog.Printf("error updating honker: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if sync {
|
||||||
|
subsub(user, url, owner, folxid)
|
||||||
|
} else {
|
||||||
go subsub(user, url, owner, folxid)
|
go subsub(user, url, owner, folxid)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
func unfollowyou(user *WhatAbout, honkerid int64) {
|
func unfollowyou(user *WhatAbout, honkerid int64, sync bool) {
|
||||||
db := opendatabase()
|
db := opendatabase()
|
||||||
row := db.QueryRow("select xid, owner, folxid from honkers where honkerid = ? and userid = ? and flavor in ('sub')",
|
row := db.QueryRow("select xid, owner, folxid from honkers where honkerid = ? and userid = ? and flavor in ('sub')",
|
||||||
honkerid, user.ID)
|
honkerid, user.ID)
|
||||||
|
@ -1918,8 +1922,12 @@ func unfollowyou(user *WhatAbout, honkerid int64) {
|
||||||
elog.Printf("error updating honker: %s", err)
|
elog.Printf("error updating honker: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if sync {
|
||||||
|
itakeitallback(user, url, owner, folxid)
|
||||||
|
} else {
|
||||||
go itakeitallback(user, url, owner, folxid)
|
go itakeitallback(user, url, owner, folxid)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func followyou2(user *WhatAbout, j junk.Junk) {
|
func followyou2(user *WhatAbout, j junk.Junk) {
|
||||||
who, _ := j.GetString("actor")
|
who, _ := j.GetString("actor")
|
||||||
|
|
|
@ -1002,9 +1002,6 @@ func savehonker(user *WhatAbout, url, name, flavor, combos, mj string) (int64, e
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
honkerid, _ := res.LastInsertId()
|
honkerid, _ := res.LastInsertId()
|
||||||
if flavor == "presub" {
|
|
||||||
followyou(user, honkerid)
|
|
||||||
}
|
|
||||||
return honkerid, nil
|
return honkerid, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,11 @@ command.
|
||||||
Users may be deleted with the
|
Users may be deleted with the
|
||||||
.Ic deluser Ar username
|
.Ic deluser Ar username
|
||||||
command.
|
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
|
.Ss Maintenance
|
||||||
The database may grow large over time.
|
The database may grow large over time.
|
||||||
The
|
The
|
||||||
|
|
36
honk.go
36
honk.go
|
@ -373,6 +373,42 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
chpass(args[1])
|
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":
|
case "cleanup":
|
||||||
arg := "30"
|
arg := "30"
|
||||||
if len(args) > 1 {
|
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 honkerid > 0 {
|
||||||
if r.FormValue("delete") == "delete" {
|
if r.FormValue("delete") == "delete" {
|
||||||
unfollowyou(user, honkerid)
|
unfollowyou(user, honkerid, false)
|
||||||
stmtDeleteHonker.Exec(honkerid)
|
stmtDeleteHonker.Exec(honkerid)
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
if r.FormValue("unsub") == "unsub" {
|
if r.FormValue("unsub") == "unsub" {
|
||||||
unfollowyou(user, honkerid)
|
unfollowyou(user, honkerid, false)
|
||||||
}
|
}
|
||||||
if r.FormValue("sub") == "sub" {
|
if r.FormValue("sub") == "sub" {
|
||||||
followyou(user, honkerid)
|
followyou(user, honkerid, false)
|
||||||
}
|
}
|
||||||
_, err := stmtUpdateHonker.Exec(name, combos, mj, honkerid, u.UserID)
|
_, err := stmtUpdateHonker.Exec(name, combos, mj, honkerid, u.UserID)
|
||||||
if err != nil {
|
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)
|
http.Error(w, "had some trouble with that: "+err.Error(), http.StatusInternalServerError)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if flavor == "presub" {
|
||||||
|
followyou(user, honkerid, false)
|
||||||
|
}
|
||||||
h.ID = id
|
h.ID = id
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue