-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: add example contact on first login #50156
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
Conversation
b237d7a
to
3af4fc4
Compare
9101f07
to
979db68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works.
3c3150b
to
85f8d9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are new classes but no new tests. Could you please add some unit tests at least?
} | ||
|
||
if (is_null($cardData)) { | ||
$cardData = file_get_contents(__DIR__ . '/../ExampleContentFiles/exampleContact.vcf'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error handling missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file_get_contents
returns false
on error. This is not handled.
85f8d9f
to
4c0fd9e
Compare
|
4c0fd9e
to
a0b6856
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm is not happy about the int vs string addressbookId
Looks good
} | ||
|
||
if (is_null($cardData)) { | ||
$cardData = file_get_contents(__DIR__ . '/../ExampleContentFiles/exampleContact.vcf'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file_get_contents
returns false
on error. This is not handled.
a0b6856
to
74eb1da
Compare
9bad0ac
to
916abc8
Compare
Signed-off-by: Hamza Mahjoubi <hamzamahjoubi221@gmail.com>
916abc8
to
099d9fb
Compare
public function createDefaultContact(int $addressBookId): void { | ||
$appData = $this->appDataFactory->get('dav'); | ||
try { | ||
$folder = $appData->getFolder('defaultContact'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates some log spam on richdocuments integration tests.
Should it rather also create that folder if it does not exist yet here?
https://github.com/nextcloud/richdocuments/actions/runs/14662537867/job/41149995116?pr=4698
{
"Exception": "OCP\\Files\\NotFoundException",
"Message": "/appdata_oceljvc7njtr/dav/defaultContact",
"Code": 0,
"Trace": [
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/Files/Node/LazyFolder.php",
"line": 138,
"function": "get",
"class": "OC\\Files\\Node\\Root",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/Files/AppData/AppData.php",
"line": 114,
"function": "get",
"class": "OC\\Files\\Node\\LazyFolder",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/apps/dav/lib/Service/DefaultContactService.php",
"line": 30,
"function": "getFolder",
"class": "OC\\Files\\AppData\\AppData",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/apps/dav/lib/Listener/UserEventsListener.php",
"line": 155,
"function": "createDefaultContact",
"class": "OCA\\DAV\\Service\\DefaultContactService",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/apps/dav/lib/Listener/UserEventsListener.php",
"line": 71,
"function": "firstLogin",
"class": "OCA\\DAV\\Listener\\UserEventsListener",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/EventDispatcher/ServiceEventListener.php",
"line": 68,
"function": "handle",
"class": "OCA\\DAV\\Listener\\UserEventsListener",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
"line": 220,
"function": "__invoke",
"class": "OC\\EventDispatcher\\ServiceEventListener",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
"line": 56,
"function": "callListeners",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/EventDispatcher/EventDispatcher.php",
"line": 67,
"function": "dispatch",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/EventDispatcher/EventDispatcher.php",
"line": 79,
"function": "dispatch",
"class": "OC\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/User/Session.php",
"line": 528,
"function": "dispatchTyped",
"class": "OC\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/User/Session.php",
"line": 357,
"function": "prepareUserLogin",
"class": "OC\\User\\Session",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/User/Session.php",
"line": 585,
"function": "completeLogin",
"class": "OC\\User\\Session",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/User/Session.php",
"line": 307,
"function": "loginWithPassword",
"class": "OC\\User\\Session",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/User/Session.php",
"line": 405,
"function": "login",
"class": "OC\\User\\Session",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/User/Session.php",
"line": 544,
"function": "logClientIn",
"class": "OC\\User\\Session",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/base.php",
"line": 1143,
"function": "tryBasicAuthLogin",
"class": "OC\\User\\Session",
"type": "->"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/ocs/v1.php",
"line": 46,
"function": "handleLogin",
"class": "OC",
"type": "::"
},
{
"file": "/home/runner/actions-runner/_work/richdocuments/richdocuments/ocs/v2.php",
"line": 7,
"args": [
"/home/runner/actions-runner/_work/richdocuments/richdocuments/ocs/v1.php"
],
"function": "require_once"
}
],
"File": "/home/runner/actions-runner/_work/richdocuments/richdocuments/lib/private/Files/Node/Root.php",
"Line": 182,
"message": "Couldn't get default contact file",
"exception": {},
"CustomMessage": "Couldn't get default contact file"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer catching NotFoundException
in a separate block and not logging it. If there is no default contact template, we don't need to create it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll push a fix soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: #52493
Checklist