Skip to content

Commit e422db5

Browse files
committed
feat: v1.2.0 maintenance update
chore: bump app version, NC30-31 chore: update changelog enh: migrate adjustments from (nextcloud/contacts#4231) chore: update npm packages Signed-off-by: Andrey Borysenko <[email protected]>
1 parent d3cab30 commit e422db5

7 files changed

+4409
-3927
lines changed

.github/workflows/appstore-build-publish.yml

+23-27
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
release:
1313
types: [published]
1414

15+
env:
16+
PHP_VERSION: 8.1
17+
1518
jobs:
1619
build_and_publish:
1720
runs-on: ubuntu-latest
@@ -21,7 +24,7 @@ jobs:
2124

2225
steps:
2326
- name: Check actor permission
24-
uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0
27+
uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2.1
2528
with:
2629
require: write
2730

@@ -32,7 +35,7 @@ jobs:
3235
echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
3336
3437
- name: Checkout
35-
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
38+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
3639
with:
3740
path: ${{ env.APP_NAME }}
3841

@@ -44,19 +47,19 @@ jobs:
4447
expression: "//info//dependencies//nextcloud/@min-version"
4548

4649
- name: Read package.json node and npm engines version
47-
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
50+
uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
4851
id: versions
4952
# Continue if no package.json
5053
continue-on-error: true
5154
with:
5255
path: ${{ env.APP_NAME }}
53-
fallbackNode: '^20'
54-
fallbackNpm: '^10'
56+
fallbackNode: "^16"
57+
fallbackNpm: "^7"
5558

5659
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
5760
# Skip if no package.json
5861
if: ${{ steps.versions.outputs.nodeVersion }}
59-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v3
62+
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
6063
with:
6164
node-version: ${{ steps.versions.outputs.nodeVersion }}
6265

@@ -65,23 +68,17 @@ jobs:
6568
if: ${{ steps.versions.outputs.npmVersion }}
6669
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
6770

68-
- name: Get php version
69-
id: php-versions
70-
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
71-
with:
72-
filename: ${{ env.APP_NAME }}/appinfo/info.xml
73-
74-
- name: Set up php ${{ steps.php-versions.outputs.php-min }}
75-
uses: shivammathur/setup-php@c665c7a15b5295c2488ac8a87af9cb806cd72198 # v2
71+
- name: Set up php ${{ env.PHP_VERSION }}
72+
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d # v2
7673
with:
77-
php-version: ${{ steps.php-versions.outputs.php-min }}
74+
php-version: ${{ env.PHP_VERSION }}
7875
coverage: none
7976
env:
8077
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8178

8279
- name: Check composer.json
8380
id: check_composer
84-
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
81+
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
8582
with:
8683
files: "${{ env.APP_NAME }}/composer.json"
8784

@@ -94,16 +91,14 @@ jobs:
9491
- name: Build ${{ env.APP_NAME }}
9592
# Skip if no package.json
9693
if: ${{ steps.versions.outputs.nodeVersion }}
97-
env:
98-
NODE_ENV: production
9994
run: |
10095
cd ${{ env.APP_NAME }}
10196
npm ci
102-
npm run build --if-present
97+
npm run build
10398
10499
- name: Check Krankerl config
105100
id: krankerl
106-
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
101+
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
107102
with:
108103
files: ${{ env.APP_NAME }}/krankerl.toml
109104

@@ -134,7 +129,7 @@ jobs:
134129
unzip latest-$NCVERSION.zip
135130
136131
- name: Checkout server master fallback
137-
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
132+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
138133
if: ${{ steps.server-checkout.outcome != 'success' }}
139134
with:
140135
submodules: true
@@ -144,24 +139,24 @@ jobs:
144139
- name: Sign app
145140
run: |
146141
# Extracting release
147-
cd ${{ env.APP_NAME }}/build/artifacts
142+
cd ${{ env.APP_NAME }}/build/artifacts/appstore
148143
tar -xvf ${{ env.APP_NAME }}.tar.gz
149-
cd ../../../
144+
cd ../../../../
150145
# Setting up keys
151146
echo "${{ secrets.APP_PRIVATE_KEY }}" > ${{ env.APP_NAME }}.key
152147
wget --quiet "https://github.com/nextcloud/app-certificate-requests/raw/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt"
153148
# Signing
154-
php nextcloud/occ integrity:sign-app --privateKey=../${{ env.APP_NAME }}.key --certificate=../${{ env.APP_NAME }}.crt --path=../${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}
149+
php nextcloud/occ integrity:sign-app --privateKey=../${{ env.APP_NAME }}.key --certificate=../${{ env.APP_NAME }}.crt --path=../${{ env.APP_NAME }}/build/artifacts/appstore/${{ env.APP_NAME }}
155150
# Rebuilding archive
156-
cd ${{ env.APP_NAME }}/build/artifacts
151+
cd ${{ env.APP_NAME }}/build/artifacts/appstore
157152
tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }}
158153
159154
- name: Attach tarball to github release
160-
uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2
155+
uses: svenstaro/upload-release-action@2b9d2847a97b04d02ad5c3df2d3a27baa97ce689 # v2
161156
id: attach_to_release
162157
with:
163158
repo_token: ${{ secrets.GITHUB_TOKEN }}
164-
file: ${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}.tar.gz
159+
file: ${{ env.APP_NAME }}/build/artifacts/appstore/${{ env.APP_NAME }}.tar.gz
165160
asset_name: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}.tar.gz
166161
tag: ${{ github.ref }}
167162
overwrite: true
@@ -173,3 +168,4 @@ jobs:
173168
appstore_token: ${{ secrets.APPSTORE_TOKEN }}
174169
download_url: ${{ steps.attach_to_release.outputs.browser_download_url }}
175170
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
171+

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
88

9+
## [1.2.0 - 2025-01-21]
10+
11+
Maintenance update. NC31 support.
12+
13+
### Added
14+
15+
- Added support of Nextcloud 31
16+
17+
### Changed
18+
19+
- Drop support of NC28, NC29
20+
- Update npm pkgs
21+
22+
923
## [1.1.0 - 2024-09-16]
1024

1125
Maintenance update

appinfo/info.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<name>Profile picker</name>
55
<summary>Profile smart picker and link preview</summary>
66
<description><![CDATA[This app adds ability to search for user profiles via smart picker and link previews for them.]]></description>
7-
<version>1.1.0</version>
7+
<version>1.2.0</version>
88
<licence>agpl</licence>
99
<author mail="[email protected]" homepage="https://github.com/andrey18106">Andrey Borysenko</author>
1010
<namespace>UsersPicker</namespace>
@@ -19,6 +19,6 @@
1919
<screenshot>https://raw.githubusercontent.com/nextcloud/users_picker/main/screenshots/users_picker_2.png</screenshot>
2020
<screenshot>https://raw.githubusercontent.com/nextcloud/users_picker/main/screenshots/users_picker_3.png</screenshot>
2121
<dependencies>
22-
<nextcloud min-version="28" max-version="30"/>
22+
<nextcloud min-version="30" max-version="31"/>
2323
</dependencies>
2424
</info>

lib/Reference/ProfilePickerReferenceProvider.php

+49-54
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,35 @@
44

55
namespace OCA\UsersPicker\Reference;
66

7-
use OC\Collaboration\Reference\LinkReferenceProvider;
7+
use OCA\UsersPicker\AppInfo\Application;
8+
use OCP\Accounts\IAccountManager;
9+
810
use OCP\Collaboration\Reference\ADiscoverableReferenceProvider;
11+
use OCP\Collaboration\Reference\IReference;
912
use OCP\Collaboration\Reference\Reference;
1013

11-
use OCP\Collaboration\Reference\IReference;
12-
use OCP\Contacts\IManager;
1314
use OCP\IL10N;
1415
use OCP\IURLGenerator;
15-
16-
use OCA\UsersPicker\AppInfo\Application;
17-
use OCP\Accounts\IAccountManager;
1816
use OCP\IUserManager;
19-
use Psr\Log\LoggerInterface;
17+
use OCP\Profile\IProfileManager;
2018

2119
class ProfilePickerReferenceProvider extends ADiscoverableReferenceProvider {
22-
23-
private const RICH_OBJECT_TYPE = Application::APP_ID . '_profile';
24-
25-
private ?string $userId;
26-
private IL10N $l10n;
27-
private IURLGenerator $urlGenerator;
28-
private LinkReferenceProvider $linkReferenceProvider;
29-
private IUserManager $userManager;
30-
private IAccountManager $accountManager;
31-
private IManager $contactsManager;
20+
public const RICH_OBJECT_TYPE = 'users_picker_profile';
3221

3322
public function __construct(
34-
IL10N $l10n,
35-
IURLGenerator $urlGenerator,
36-
LinkReferenceProvider $linkReferenceProvider,
37-
IUserManager $userManager,
38-
IAccountManager $accountManager,
39-
IManager $contactsManager,
40-
?string $userId,
41-
private LoggerInterface $logger,
23+
private IL10N $l10n,
24+
private IURLGenerator $urlGenerator,
25+
private IUserManager $userManager,
26+
private IAccountManager $accountManager,
27+
private IProfileManager $profileManager,
28+
private ?string $userId,
4229
) {
43-
$this->userId = $userId;
44-
$this->l10n = $l10n;
45-
$this->urlGenerator = $urlGenerator;
46-
$this->linkReferenceProvider = $linkReferenceProvider;
47-
$this->userManager = $userManager;
48-
$this->accountManager = $accountManager;
49-
$this->contactsManager = $contactsManager;
5030
}
5131

5232
/**
5333
* @inheritDoc
5434
*/
55-
public function getId(): string {
35+
public function getId(): string {
5636
return 'profile_picker';
5737
}
5838

@@ -66,7 +46,7 @@ public function getTitle(): string {
6646
/**
6747
* @inheritDoc
6848
*/
69-
public function getOrder(): int {
49+
public function getOrder(): int {
7050
return 10;
7151
}
7252

@@ -94,32 +74,46 @@ public function resolveReference(string $referenceText): ?IReference {
9474

9575
$userId = $this->getObjectId($referenceText);
9676
$user = $this->userManager->get($userId);
97-
$contacts = $this->contactsManager->search($userId, ['UID', 'FN', 'EMAIL'], ['types' => true]);
98-
$this->logger->error('Contancts: ' . json_encode($contacts));
99-
10077
if ($user === null) {
101-
return $this->linkReferenceProvider->resolveReference($referenceText);
78+
return null;
79+
}
80+
if (!$this->profileManager->isProfileEnabled($user)) {
81+
return null;
10282
}
83+
$account = $this->accountManager->getAccount($user);
84+
85+
$currentUser = $this->userManager->get($this->userId);
10386

10487
$reference = new Reference($referenceText);
10588

10689
$userDisplayName = $user->getDisplayName();
10790
$userEmail = $user->getEMailAddress();
10891
$userAvatarUrl = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $userId, 'size' => '64']);
10992

110-
$bio = $this->accountManager->getAccount($user)->getProperty(IAccountManager::PROPERTY_BIOGRAPHY);
111-
$bio = $bio->getScope() !== IAccountManager::SCOPE_PRIVATE ? $bio->getValue() : null;
112-
$headline = $this->accountManager->getAccount($user)->getProperty(IAccountManager::PROPERTY_HEADLINE);
113-
$location = $this->accountManager->getAccount($user)->getProperty(IAccountManager::PROPERTY_ADDRESS);
114-
$website = $this->accountManager->getAccount($user)->getProperty(IAccountManager::PROPERTY_WEBSITE);
115-
$organisation = $this->accountManager->getAccount($user)->getProperty(IAccountManager::PROPERTY_ORGANISATION);
116-
$role = $this->accountManager->getAccount($user)->getProperty(IAccountManager::PROPERTY_ROLE);
93+
$bioProperty = $account->getProperty(IAccountManager::PROPERTY_BIOGRAPHY);
94+
$bio = null;
95+
$fullBio = null;
96+
if ($this->profileManager->isProfileFieldVisible(IAccountManager::PROPERTY_BIOGRAPHY, $user, $currentUser)) {
97+
$fullBio = $bioProperty->getValue();
98+
$bio = $fullBio !== ''
99+
? (mb_strlen($fullBio) > 80
100+
? (mb_substr($fullBio, 0, 80) . '...')
101+
: $fullBio)
102+
: null;
103+
}
104+
$headline = $account->getProperty(IAccountManager::PROPERTY_HEADLINE);
105+
$location = $account->getProperty(IAccountManager::PROPERTY_ADDRESS);
106+
$website = $account->getProperty(IAccountManager::PROPERTY_WEBSITE);
107+
$organisation = $account->getProperty(IAccountManager::PROPERTY_ORGANISATION);
108+
$role = $account->getProperty(IAccountManager::PROPERTY_ROLE);
117109

118110
// for clients who can't render the reference widgets
119111
$reference->setTitle($userDisplayName);
120112
$reference->setDescription($userEmail ?? $userDisplayName);
121113
$reference->setImageUrl($userAvatarUrl);
122114

115+
$isLocationVisible = $this->profileManager->isProfileFieldVisible(IAccountManager::PROPERTY_ADDRESS, $user, $currentUser);
116+
123117
// for the Vue reference widget
124118
$reference->setRichObject(
125119
self::RICH_OBJECT_TYPE,
@@ -128,20 +122,21 @@ public function resolveReference(string $referenceText): ?IReference {
128122
'title' => $userDisplayName,
129123
'subline' => $userEmail ?? $userDisplayName,
130124
'email' => $userEmail,
131-
'bio' => isset($bio) && $bio !== '' ? substr_replace($bio, '...', 80, strlen($bio)) : null,
132-
'headline' => $headline->getScope() !== IAccountManager::SCOPE_PRIVATE ? $headline->getValue() : null,
133-
'location' => $location->getScope() !== IAccountManager::SCOPE_PRIVATE ? $location->getValue() : null,
134-
'location_url' => $location->getScope() !== IAccountManager::SCOPE_PRIVATE ? $this->getOpenStreetLocationUrl($location->getValue()) : null,
135-
'website' => $website->getScope() !== IAccountManager::SCOPE_PRIVATE ? $website->getValue() : null,
136-
'organisation' => $organisation->getScope() !== IAccountManager::SCOPE_PRIVATE ? $organisation->getValue() : null,
137-
'role' => $role->getScope() !== IAccountManager::SCOPE_PRIVATE ? $role->getValue() : null,
125+
'bio' => $bio,
126+
'full_bio' => $fullBio,
127+
'headline' => $this->profileManager->isProfileFieldVisible(IAccountManager::PROPERTY_HEADLINE, $user, $currentUser) ? $headline->getValue() : null,
128+
'location' => $isLocationVisible ? $location->getValue() : null,
129+
'location_url' => $isLocationVisible ? $this->getOpenStreetLocationUrl($location->getValue()) : null,
130+
'website' => $this->profileManager->isProfileFieldVisible(IAccountManager::PROPERTY_WEBSITE, $user, $currentUser) ? $website->getValue() : null,
131+
'organisation' => $this->profileManager->isProfileFieldVisible(IAccountManager::PROPERTY_ORGANISATION, $user, $currentUser) ? $organisation->getValue() : null,
132+
'role' => $this->profileManager->isProfileFieldVisible(IAccountManager::PROPERTY_ROLE, $user, $currentUser) ? $role->getValue() : null,
138133
'url' => $referenceText,
139134
]
140135
);
141136
return $reference;
142137
}
143138

144-
private function getObjectId(string $url): ?string {
139+
public function getObjectId(string $url): ?string {
145140
$baseUrl = $this->urlGenerator->getBaseUrl();
146141
$baseWithIndex = $baseUrl . '/index.php';
147142

@@ -157,7 +152,7 @@ private function getObjectId(string $url): ?string {
157152
return null;
158153
}
159154

160-
private function getOpenStreetLocationUrl($location) {
155+
public function getOpenStreetLocationUrl($location): string {
161156
return 'https://www.openstreetmap.org/search?query=' . urlencode($location);
162157
}
163158

0 commit comments

Comments
 (0)