예제 #1
0
func (p *SmugMugContactService) ConvertToDsocialContact(externalContact interface{}, originalDsocialContact *dm.Contact, dsocialUserId string) (dsocialContact *dm.Contact) {
	if externalContact == nil {
		return
	}
	if extContact, ok := externalContact.(*smugmug.PersonReference); ok && extContact != nil {
		dsocialContact = dm.SmugMugUserToDsocial(extContact, originalDsocialContact, dsocialUserId)
	}
	return
}
예제 #2
0
func (p *SmugMugContactService) handleRetrievedContact(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, contactId string, extContact *smugmug.PersonReference) (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.NickName
	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.SmugMugUserToDsocial(extContact, origDsocialContact, dsocialUserId)
	contact = &Contact{
		ExternalServiceId: p.ServiceId(),
		ExternalUserId:    externalUserId,
		ExternalContactId: externalContactId,
		DsocialUserId:     dsocialUserId,
		DsocialContactId:  dsocialContactId,
		Value:             dsocialContact,
	}
	return contact, useErr
}