diff --git a/pkg/importer/foursquare/api.go b/pkg/importer/foursquare/api.go index b47531d33..0b6715d99 100644 --- a/pkg/importer/foursquare/api.go +++ b/pkg/importer/foursquare/api.go @@ -22,6 +22,7 @@ type user struct { Id string FirstName string LastName string + Photo photoItem } type userInfo struct { @@ -87,6 +88,13 @@ func (vi *venueItem) icon() string { 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 { Address string City string diff --git a/pkg/importer/foursquare/foursquare.go b/pkg/importer/foursquare/foursquare.go index 6ca7b2b8e..c7081f63a 100644 --- a/pkg/importer/foursquare/foursquare.go +++ b/pkg/importer/foursquare/foursquare.go @@ -385,10 +385,12 @@ func (r *run) importCompanions(parent *importer.Object, companions []*user) (com if err != nil { return nil, err } + icon := user.icon() if err := personNode.SetAttrs( attrFoursquareId, user.Id, nodeattr.Type, "foursquare.com:person", nodeattr.Title, user.FirstName+" "+user.LastName, + nodeattr.CamliContentImage, r.urlFileRef(icon, path.Base(icon)), nodeattr.GivenName, user.FirstName, nodeattr.FamilyName, user.LastName); err != nil { return nil, err diff --git a/pkg/importer/foursquare/foursquare_test.go b/pkg/importer/foursquare/foursquare_test.go index d0c0b3761..a56ad704b 100644 --- a/pkg/importer/foursquare/foursquare_test.go +++ b/pkg/importer/foursquare/foursquare_test.go @@ -42,6 +42,10 @@ func TestGetUserId(t *testing.T) { Id: "13674", FirstName: "Brad", LastName: "Fitzpatrick", + Photo: photoItem{ + Prefix: "https://irs0.4sqi.net/img/user/", + Suffix: "/CKG5FOF2WMCMPD3E.jpg", + }, } if inf != want { t.Errorf("user info = %+v; want %+v", inf, want) diff --git a/pkg/importer/foursquare/testdata.go b/pkg/importer/foursquare/testdata.go index 2ee4b4e18..49fc9eb7b 100644 --- a/pkg/importer/foursquare/testdata.go +++ b/pkg/importer/foursquare/testdata.go @@ -170,6 +170,10 @@ func fakeCheckinsList(offset, maxCheckin int, towns map[int]*venueLocationItem, Id: "123", FirstName: "Kate", LastName: "Pek", + Photo: photoItem{ + Prefix: "https://irs3.4sqi.net/img/user/", + Suffix: "/13674-S2IUMHALCCJJUTQO.jpg", + }, }, }, CreatedAt: time.Now().Unix(),