cleanup a few if statements
This commit is contained in:
parent
3562c42e3c
commit
5f690af54b
40
activity.go
40
activity.go
|
@ -604,26 +604,22 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
}
|
}
|
||||||
|
|
||||||
if obj != nil {
|
if obj != nil {
|
||||||
_, ok := obj.GetString("diaspora:guid")
|
if _, ok := obj.GetString("diaspora:guid"); ok {
|
||||||
if ok {
|
|
||||||
// friendica does the silliest bonks
|
// friendica does the silliest bonks
|
||||||
c, ok := obj.GetString("source", "content")
|
if c, ok := obj.GetString("source", "content"); ok {
|
||||||
if ok {
|
|
||||||
re_link := regexp.MustCompile(`link='([^']*)'`)
|
re_link := regexp.MustCompile(`link='([^']*)'`)
|
||||||
m := re_link.FindStringSubmatch(c)
|
if m := re_link.FindStringSubmatch(c); len(m) > 1 {
|
||||||
if len(m) > 1 {
|
|
||||||
xid := m[1]
|
xid := m[1]
|
||||||
log.Printf("getting friendica flavored bonk: %s", xid)
|
log.Printf("getting friendica flavored bonk: %s", xid)
|
||||||
if !needxonkid(user, xid) {
|
if !needxonkid(user, xid) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
newobj, err := GetJunkHardMode(xid)
|
if newobj, err := GetJunkHardMode(xid); err == nil {
|
||||||
if err != nil {
|
|
||||||
log.Printf("error getting bonk: %s: %s", xid, err)
|
|
||||||
} else {
|
|
||||||
obj = newobj
|
obj = newobj
|
||||||
origin = originate(xid)
|
origin = originate(xid)
|
||||||
what = "bonk"
|
what = "bonk"
|
||||||
|
} else {
|
||||||
|
log.Printf("error getting bonk: %s: %s", xid, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -654,8 +650,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
if obj != nil {
|
if obj != nil {
|
||||||
ot, _ := obj.GetString("type")
|
ot, _ := obj.GetString("type")
|
||||||
url, _ = obj.GetString("url")
|
url, _ = obj.GetString("url")
|
||||||
dt2, ok := obj.GetString("published")
|
if dt2, ok := obj.GetString("published"); ok {
|
||||||
if ok {
|
|
||||||
dt = dt2
|
dt = dt2
|
||||||
}
|
}
|
||||||
xid, _ = obj.GetString("id")
|
xid, _ = obj.GetString("id")
|
||||||
|
@ -670,14 +665,12 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
if !strings.HasPrefix(content, "<p>") {
|
if !strings.HasPrefix(content, "<p>") {
|
||||||
content = "<p>" + content
|
content = "<p>" + content
|
||||||
}
|
}
|
||||||
sens, _ := obj["sensitive"].(bool)
|
if sens, _ := obj["sensitive"].(bool); sens && precis == "" {
|
||||||
if sens && precis == "" {
|
|
||||||
precis = "unspecified horror"
|
precis = "unspecified horror"
|
||||||
}
|
}
|
||||||
rid, ok = obj.GetString("inReplyTo")
|
rid, ok = obj.GetString("inReplyTo")
|
||||||
if !ok {
|
if !ok {
|
||||||
robj, ok := obj.GetMap("inReplyTo")
|
if robj, ok := obj.GetMap("inReplyTo"); ok {
|
||||||
if ok {
|
|
||||||
rid, _ = robj.GetString("id")
|
rid, _ = robj.GetString("id")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -801,10 +794,8 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
mentions = append(mentions, m)
|
mentions = append(mentions, m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
starttime, ok := obj.GetString("startTime")
|
if starttime, ok := obj.GetString("startTime"); ok {
|
||||||
if ok {
|
if start, err := time.Parse(time.RFC3339, starttime); err == nil {
|
||||||
start, err := time.Parse(time.RFC3339, starttime)
|
|
||||||
if err == nil {
|
|
||||||
t := new(Time)
|
t := new(Time)
|
||||||
t.StartTime = start
|
t.StartTime = start
|
||||||
endtime, _ := obj.GetString("endTime")
|
endtime, _ := obj.GetString("endTime")
|
||||||
|
@ -818,13 +809,10 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
xonk.Time = t
|
xonk.Time = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loca, ok := obj.GetMap("location")
|
if loca, ok := obj.GetMap("location"); ok {
|
||||||
if ok {
|
if tt, _ := loca.GetString("type"); tt == "Place" {
|
||||||
tt, _ := loca.GetString("type")
|
|
||||||
name, _ := loca.GetString("name")
|
|
||||||
if tt == "Place" {
|
|
||||||
p := new(Place)
|
p := new(Place)
|
||||||
p.Name = name
|
p.Name, _ = loca.GetString("name")
|
||||||
p.Latitude, _ = loca["latitude"].(float64)
|
p.Latitude, _ = loca["latitude"].(float64)
|
||||||
p.Longitude, _ = loca["longitude"].(float64)
|
p.Longitude, _ = loca["longitude"].(float64)
|
||||||
p.Url, _ = loca.GetString("url")
|
p.Url, _ = loca.GetString("url")
|
||||||
|
|
Loading…
Reference in New Issue