Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import #426

Closed
wants to merge 1 commit into from
Closed

Import #426

wants to merge 1 commit into from

Conversation

babelouest
Copy link
Contributor

Pull request retry
I did a git rebase before sending the pull request, hope it looks better now.

@tanghus
Copy link
Contributor

tanghus commented Feb 27, 2014

I did a git rebase before sending the pull request, hope it looks better now.

Sorry, but no it doesn't. Look at the number of changed files. I guess you haven't changed 313 files? ;)

I'll have a look at it tonight (CET)

@babelouest
Copy link
Contributor Author

@tanghus , no, I haven't changed all those files, although most of the reported changes are ACL changes. I don't know why I did that, but I changed most of the access control from 0644 to 0755...
Can I make git to skip it when it's only ACL changes ?

@tanghus
Copy link
Contributor

tanghus commented Feb 27, 2014

Can I make git to skip it when it's only ACL changes ?

Yes, but not github. I suggest you make a new clone of the repo, make a new branch, and take the files you've changed and manually copy them from the old clone to the new.

But wait till tomorrow; I'll see if I can sort it out.

@tanghus
Copy link
Contributor

tanghus commented Feb 27, 2014

@babelouest Looking at your commits I figured it was the one with the WTF ? comment 257d082 ;)

@tanghus
Copy link
Contributor

tanghus commented Feb 27, 2014

@babelouest I think I've resolved it. Please check in the Files changed tab and see if it looks correct.

@babelouest
Copy link
Contributor Author

@tanghus , looks correct to me, thanks !

@tanghus
Copy link
Contributor

tanghus commented Mar 3, 2014

@babelouest Sorry I haven't been able to review this yet. I'm a bit tight on time in the beginning of the week though. Just to let you know I haven't forgotten :)

</import_entry>

<import_entry property="X-PRIMARY-PHONE" enabled="true">
<vcard_entry property="PHONE" type="HOME">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@babelouest Can you add more than one type here? PRIMARY indicates it should also have type PREF. Or am I wrong here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand your question.
Here, X-PRIMARY-PHONE stands for the property name that we're looking for, to be replace by the one below (PHONE type:HOME).
If you want to convert other properties, just add an <import_entry> tag with the <vcard_entry> tag for the result.
What do you mean by PREF ? is it a VCard property ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PREF is a standard type for the preferred property if there are more than one. Used for e.g TEL, EMAIL, URL, ADR etc. Like in TEL;TYPE=HOME,PREF:+1-919-676-9564 or TEL;TYPE=HOME;TYPE=PREF:+1-919-676-9564. Not sure if Yahoo has more than one PHONE type though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if it's a type, you can use this:
<vcard_entry property="PHONE" type="HOME,PREF">

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK. Excellent!

@tanghus
Copy link
Contributor

tanghus commented Mar 3, 2014

Just a few coding style issues. Full test later :)

@babelouest
Copy link
Contributor Author

no problem :)

@tanghus
Copy link
Contributor

tanghus commented Mar 4, 2014

@babelouest First test with a Google CSV:

  1. csv_gmail/import/upload returned count: 0 even though there was 62 contacts and they were apparently recognized.
  2. None of the contacts were parsed correctly, but all resulted in almost similar entries. See below.
  3. All entries got a BDAY of current date.
  4. CATEGORIES was recognized, but parsed incorrectly: * My Contacts ::: * Starred

Not in "My contacts":

BEGIN:VCARD
VERSION:3.0
X-UNKNOWN-ELEMENT;TYPE=ÿþName:
N:;;;;
X-UNKNOWN-ELEMENT;TYPE=Yomi Name:
X-PHONETIC-FIRST-NAME:
X-UNKNOWN-ELEMENT;TYPE=Additional Name Yomi:
X-PHONETIC-LAST-NAME:
NICKNAME:
X-UNKNOWN-ELEMENT;TYPE=Short Name:
X-UNKNOWN-ELEMENT;TYPE=Maiden Name:
BDAY:2014-03-04
GENDER:
X-UNKNOWN-ELEMENT;TYPE=Location:
X-UNKNOWN-ELEMENT;TYPE=Billing Information:
X-UNKNOWN-ELEMENT;TYPE=Directory Server:
X-UNKNOWN-ELEMENT;TYPE=Mileage:
X-UNKNOWN-ELEMENT;TYPE=Occupation:
X-UNKNOWN-ELEMENT;TYPE=Hobby:
X-UNKNOWN-ELEMENT;TYPE=Sensitivity:
X-UNKNOWN-ELEMENT;TYPE=Priority:
X-UNKNOWN-ELEMENT;TYPE=Subject:
NOTE:
CATEGORIES:
EMAIL1.EMAIL;TYPE=* :
FN:
UID:20140304T175950.59641b4556@localhost
REV:2014-03-04T18:00:09+00:00
PRODID:-//ownCloud//NONSGML Contacts 0.3.0.1//EN
END:VCARD

In "My contacts":

BEGIN:VCARD
VERSION:3.0
X-UNKNOWN-ELEMENT;TYPE=ÿþName:
N:;;;;
X-UNKNOWN-ELEMENT;TYPE=Yomi Name:
X-PHONETIC-FIRST-NAME:
X-UNKNOWN-ELEMENT;TYPE=Additional Name Yomi:
X-PHONETIC-LAST-NAME:
NICKNAME:
X-UNKNOWN-ELEMENT;TYPE=Short Name:
X-UNKNOWN-ELEMENT;TYPE=Maiden Name:
BDAY:2014-03-04
GENDER:
X-UNKNOWN-ELEMENT;TYPE=Location:
X-UNKNOWN-ELEMENT;TYPE=Billing Information:
X-UNKNOWN-ELEMENT;TYPE=Directory Server:
X-UNKNOWN-ELEMENT;TYPE=Mileage:
X-UNKNOWN-ELEMENT;TYPE=Occupation:
X-UNKNOWN-ELEMENT;TYPE=Hobby:
X-UNKNOWN-ELEMENT;TYPE=Sensitivity:
X-UNKNOWN-ELEMENT;TYPE=Priority:
X-UNKNOWN-ELEMENT;TYPE=Subject:
NOTE:
CATEGORIES:* My Contacts ::: * Starred
EMAIL1.EMAIL;TYPE=* Home:
FN:
UID:20140304T175950.84593cab0d@localhost
REV:2014-03-04T17:59:55+00:00
PRODID:-//ownCloud//NONSGML Contacts 0.3.0.1//EN
END:VCARD

Something to start with ;)

@babelouest
Copy link
Contributor Author

OK, that's a problem indeed :p
Can you send me the csv file you used ?

@tanghus
Copy link
Contributor

tanghus commented Mar 4, 2014

Can you send me the csv file you used ?

Done

@tanghus
Copy link
Contributor

tanghus commented Mar 4, 2014

BTW when the contact is in the Starred group it should be added to Favorites instead.

@babelouest
Copy link
Contributor Author

OK, you tried to trick me with a UTF16 file where I expect a UTF8 file ! Damn you ! ;)
This has been fixed in the code.

About the CATEGORIES issue, I see two problems there.
The fact that when there are several categories they are separated with :::and also that every category is prefixed with *, no problem, I can add a separator and remove the prefix.
But fixing when the contact is in the Starred group it should be added to Favorites instead needs more info.
Is "Favourites" a CATEGORIES value ?

@tanghus
Copy link
Contributor

tanghus commented Mar 6, 2014

OK, you tried to trick me with a UTF16 file where I expect a UTF8 file ! Damn you ! ;)

I wasn't even aware of that. Just exported it from google contacts :)

Is "Favourites" a CATEGORIES value ?

It is kinda like the Starred group in google contacts:

For CATEGORIES you have to - besides converting them to vCard CATEGORIES - index them using the OCP\Tags lib. This is done automatically when just adding them, but you should treat Starred as Favorites in the contacts app.
In the controller that is very easy:

$tagMgr = $this->server->getTagManager()->load('contact');
$tagMgr->addToFavorites($id);

But you may wanna pass $this->server as an argument to the import class instead..?
Mentioning @jancborchardt just to be sure that Gmail Starred contacts should be filtered out and converted to favorites. And what to do with the My Contacts group? I don't quite get what google thinks is the difference between the two?

@tanghus
Copy link
Contributor

tanghus commented Mar 6, 2014

OK, you tried to trick me with a UTF16 file where I expect a UTF8 file ! Damn you ! ;)
This has been fixed in the code.

How do you do that? I'm not sure I have come across any; at least I haven't noticed :P

@babelouest
Copy link
Contributor Author

I wasn't even aware of that. Just exported it from google contacts :)

No problem, to be sure, I translate the file into UTF8 all the time now

It is kinda like the Starred group in google contacts:

Yeah but I mean, does the csv value * My Contacts ::: * Starred need to be transformed into the VCard property CATEGORIES:My Contacts,Favourites ?

@tanghus
Copy link
Contributor

tanghus commented Mar 6, 2014

Yeah but I mean, does the csv value * My Contacts ::: * Starred need to be transformed into the VCard property CATEGORIES:My Contacts,Favourites ?

I would say it should be transformed into CATEGORIES:My Contacts plus adding the contact id to favorites using the call I quoted above.
The OCP\Tags lib (formerly OC_VCategories) was originally made for fast access access to CATEGORIES in VCARD, VEVENT, VJOURNAL etc. but I have since removed the VObject specific code from it, to make it a more general "Tagging" lib. See e.g. owncloud/core#3812
The groups in contacts app utilizes it and calendar app uses it for basic CATEGORIES editing.
For use with VObjects it requires an amount of data duplication to keep the content of the objects CATEGORIES property in sync with the index, but the code required for doing that is well made up for by the speed gained.

@babelouest
Copy link
Contributor Author

I will put this in the xml format and change the code as needed to make the changes:

  <import_entry name="Group Membership" enabled="true" separator=":::" remove="*">
    <vcard_favourites value="Starred">
    </vcard_favourites>
    <vcard_entry property="CATEGORIES">
    </vcard_entry>
  </import_entry>

Then the parsing will be modified like this:

$csv_value = str_replace($remove, '', $csv_value);
$values = explode($separator, $csv_value);
foreach($values as $value) {
    if ($value == $vcard_favourites) {
        $tagMgr->addToFavorites($id);
    } else {
        // Parse normally
    }
}

@tanghus
Copy link
Contributor

tanghus commented Mar 6, 2014

Nice!

@babelouest
Copy link
Contributor Author

Or even better:

    if ($value == $vcard_favourites) {
        $property = \Sabre\VObject\Property::create("X-FAVOURITES", "yes");
        $vcard->add($property);
    } else {
        // Parse normally
    }

Then, the $tagMgr->addToFavorites($id); will be done in the importController class, right after the $addressbook->add($vcard) if the VCard has the X-FAVOURITES property set to yes.

@jancborchardt
Copy link
Contributor

There still are a lot of merge commits and 2 "WTF?" commits. ;) Would be cool to clean the history up a bit, otherwise no one from outside knows what happened to the code.

@babelouest
Copy link
Contributor Author

@jancborchardt , I agree, but how can I clean the history ? Can I make a PR with just the last commit and not the previous ones for example ? (I have googled it and couldn't find an answer...)

@jancborchardt
Copy link
Contributor

I guess easiest here would be to make a fresh branch off master and do the changes again manually. I know it's a pain, but in this case (looking at the diff) there's also just a lot of file additions so it's not that difficult.

Is that ok?

@tanghus
Copy link
Contributor

tanghus commented Mar 6, 2014

@babelouest
Copy link
Contributor Author

@tanghus , try with the last commit for your bugs: owncloud/contacts@3b516a1
Should be fixed.

@jancborchardt , using your technique or tabghus' technique, either way I suggest I'll fix that when the new import interface will pass your tests, so it will be done once ;)
Do yo agree ?

@tanghus
Copy link
Contributor

tanghus commented Mar 6, 2014

You mean dfba196 right? ;) I'll give it a go tomorrow.

@babelouest
Copy link
Contributor Author

@tanghus , yup ;)

@tanghus
Copy link
Contributor

tanghus commented Mar 9, 2014

@babelouest @jancborchardt I made so many changes when cleaning up the code in master that this wasn't mergable anymore. A cleaned up version is now in #443

@tanghus tanghus closed this Mar 9, 2014
@jancborchardt jancborchardt deleted the import branch March 13, 2014 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants