mirror of https://github.com/perkeep/perkeep.git
Merge "importer/foursquare: import also the photo of the companion"
This commit is contained in:
commit
de4ab2ae55
|
@ -22,6 +22,7 @@ type user struct {
|
||||||
Id string
|
Id string
|
||||||
FirstName string
|
FirstName string
|
||||||
LastName string
|
LastName string
|
||||||
|
Photo photoItem
|
||||||
}
|
}
|
||||||
|
|
||||||
type userInfo struct {
|
type userInfo struct {
|
||||||
|
@ -87,6 +88,13 @@ func (vi *venueItem) icon() string {
|
||||||
return c.Icon.Prefix + "bg_88" + c.Icon.Suffix
|
return c.Icon.Prefix + "bg_88" + c.Icon.Suffix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (user *user) icon() string {
|
||||||
|
if user.Photo.Prefix == "" || user.Photo.Suffix == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return user.Photo.Prefix + "500x500" + user.Photo.Suffix
|
||||||
|
}
|
||||||
|
|
||||||
type venueLocationItem struct {
|
type venueLocationItem struct {
|
||||||
Address string
|
Address string
|
||||||
City string
|
City string
|
||||||
|
|
|
@ -385,10 +385,12 @@ func (r *run) importCompanions(parent *importer.Object, companions []*user) (com
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
icon := user.icon()
|
||||||
if err := personNode.SetAttrs(
|
if err := personNode.SetAttrs(
|
||||||
attrFoursquareId, user.Id,
|
attrFoursquareId, user.Id,
|
||||||
nodeattr.Type, "foursquare.com:person",
|
nodeattr.Type, "foursquare.com:person",
|
||||||
nodeattr.Title, user.FirstName+" "+user.LastName,
|
nodeattr.Title, user.FirstName+" "+user.LastName,
|
||||||
|
nodeattr.CamliContentImage, r.urlFileRef(icon, path.Base(icon)),
|
||||||
nodeattr.GivenName, user.FirstName,
|
nodeattr.GivenName, user.FirstName,
|
||||||
nodeattr.FamilyName, user.LastName); err != nil {
|
nodeattr.FamilyName, user.LastName); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -42,6 +42,10 @@ func TestGetUserId(t *testing.T) {
|
||||||
Id: "13674",
|
Id: "13674",
|
||||||
FirstName: "Brad",
|
FirstName: "Brad",
|
||||||
LastName: "Fitzpatrick",
|
LastName: "Fitzpatrick",
|
||||||
|
Photo: photoItem{
|
||||||
|
Prefix: "https://irs0.4sqi.net/img/user/",
|
||||||
|
Suffix: "/CKG5FOF2WMCMPD3E.jpg",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
if inf != want {
|
if inf != want {
|
||||||
t.Errorf("user info = %+v; want %+v", inf, want)
|
t.Errorf("user info = %+v; want %+v", inf, want)
|
||||||
|
|
|
@ -170,6 +170,10 @@ func fakeCheckinsList(offset, maxCheckin int, towns map[int]*venueLocationItem,
|
||||||
Id: "123",
|
Id: "123",
|
||||||
FirstName: "Kate",
|
FirstName: "Kate",
|
||||||
LastName: "Pek",
|
LastName: "Pek",
|
||||||
|
Photo: photoItem{
|
||||||
|
Prefix: "https://irs3.4sqi.net/img/user/",
|
||||||
|
Suffix: "/13674-S2IUMHALCCJJUTQO.jpg",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CreatedAt: time.Now().Unix(),
|
CreatedAt: time.Now().Unix(),
|
||||||
|
|
Loading…
Reference in New Issue