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