Esempio n. 1
0
func (p *LinkedInContactService) ConvertToDsocialContact(externalContact interface{}, originalDsocialContact *dm.Contact, dsocialUserId string) (dsocialContact *dm.Contact) {
	if externalContact == nil {
		return
	}
	if extContact, ok := externalContact.(*linkedin.Contact); ok && extContact != nil {
		dsocialContact = dm.LinkedInContactToDsocial(extContact, originalDsocialContact, dsocialUserId)
	}
	return
}
Esempio n. 2
0
func (p *LinkedInContactService) handleRetrievedContact(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, contactId string, extContact *linkedin.Contact) (contact *Contact, err os.Error) {
	if extContact == nil {
		return nil, nil
	}
	externalServiceId := p.ServiceId()
	userInfo, err := client.RetrieveUserInfo()
	externalUserId := userInfo.Guid()
	var useErr os.Error = nil
	dsocialContactId := ""
	var origDsocialContact *dm.Contact = nil
	externalContactId := extContact.Id
	if len(externalContactId) > 0 {
		dsocialContactId, err = ds.DsocialIdForExternalContactId(externalServiceId, externalUserId, dsocialUserId, contactId)
		if err != nil {
			useErr = err
		}
		if dsocialContactId != "" {
			origDsocialContact, _, err = ds.RetrieveDsocialContactForExternalContact(externalServiceId, externalUserId, externalContactId, dsocialUserId)
			if err != nil && useErr == nil {
				useErr = err
			}
		} else {
			ds.StoreExternalContact(externalServiceId, externalUserId, dsocialUserId, externalContactId, extContact)
		}
	}
	dsocialContact := dm.LinkedInContactToDsocial(extContact, origDsocialContact, dsocialUserId)
	contact = &Contact{
		ExternalServiceId: p.ServiceId(),
		ExternalUserId:    externalUserId,
		ExternalContactId: extContact.Id,
		DsocialUserId:     dsocialUserId,
		DsocialContactId:  dsocialContactId,
		Value:             dsocialContact,
	}
	return contact, useErr
}