зеркало из https://github.com/nextcloud/server.git
Add mastodon personal info field
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
Родитель
d0c72cc11a
Коммит
86d9626901
|
@ -621,6 +621,7 @@ class UsersController extends AUserData {
|
|||
$permittedFields[] = IAccountManager::PROPERTY_ADDRESS;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_WEBSITE;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_TWITTER;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_MASTODON;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_ORGANISATION;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_ROLE;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_HEADLINE;
|
||||
|
@ -782,6 +783,7 @@ class UsersController extends AUserData {
|
|||
$permittedFields[] = IAccountManager::PROPERTY_ADDRESS;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_WEBSITE;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_TWITTER;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_MASTODON;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_ORGANISATION;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_ROLE;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_HEADLINE;
|
||||
|
@ -791,6 +793,7 @@ class UsersController extends AUserData {
|
|||
$permittedFields[] = IAccountManager::PROPERTY_ADDRESS . self::SCOPE_SUFFIX;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_WEBSITE . self::SCOPE_SUFFIX;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_TWITTER . self::SCOPE_SUFFIX;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_MASTODON . self::SCOPE_SUFFIX;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_ORGANISATION . self::SCOPE_SUFFIX;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_ROLE . self::SCOPE_SUFFIX;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_HEADLINE . self::SCOPE_SUFFIX;
|
||||
|
@ -827,6 +830,7 @@ class UsersController extends AUserData {
|
|||
$permittedFields[] = IAccountManager::PROPERTY_ADDRESS;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_WEBSITE;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_TWITTER;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_MASTODON;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_ORGANISATION;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_ROLE;
|
||||
$permittedFields[] = IAccountManager::PROPERTY_HEADLINE;
|
||||
|
@ -955,6 +959,7 @@ class UsersController extends AUserData {
|
|||
case IAccountManager::PROPERTY_ADDRESS:
|
||||
case IAccountManager::PROPERTY_WEBSITE:
|
||||
case IAccountManager::PROPERTY_TWITTER:
|
||||
case IAccountManager::PROPERTY_MASTODON:
|
||||
case IAccountManager::PROPERTY_ORGANISATION:
|
||||
case IAccountManager::PROPERTY_ROLE:
|
||||
case IAccountManager::PROPERTY_HEADLINE:
|
||||
|
@ -999,6 +1004,7 @@ class UsersController extends AUserData {
|
|||
case IAccountManager::PROPERTY_ADDRESS . self::SCOPE_SUFFIX:
|
||||
case IAccountManager::PROPERTY_WEBSITE . self::SCOPE_SUFFIX:
|
||||
case IAccountManager::PROPERTY_TWITTER . self::SCOPE_SUFFIX:
|
||||
case IAccountManager::PROPERTY_MASTODON . self::SCOPE_SUFFIX:
|
||||
case IAccountManager::PROPERTY_ORGANISATION . self::SCOPE_SUFFIX:
|
||||
case IAccountManager::PROPERTY_ROLE . self::SCOPE_SUFFIX:
|
||||
case IAccountManager::PROPERTY_HEADLINE . self::SCOPE_SUFFIX:
|
||||
|
|
|
@ -102,8 +102,7 @@ input#openid, input#webdav {
|
|||
|
||||
.profile-settings-container {
|
||||
display: inline-grid;
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: 1fr 1fr 1fr 2fr;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
|
||||
.personal-show-container {
|
||||
|
@ -128,7 +127,7 @@ select#timezone {
|
|||
display: grid;
|
||||
padding: 20px;
|
||||
max-width: 1500px;
|
||||
grid-template-columns: 1fr 2fr 1fr;
|
||||
grid-template-columns: 1fr 3fr;
|
||||
}
|
||||
#personal-settings .section {
|
||||
padding: 10px 10px;
|
||||
|
@ -233,8 +232,7 @@ select#timezone {
|
|||
}
|
||||
.personal-settings-container {
|
||||
display: inline-grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-template-rows: 1fr 1fr 1fr 1fr 1fr;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
.personal-settings-container:after {
|
||||
clear: both;
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -45,8 +45,7 @@ input {
|
|||
|
||||
.profile-settings-container {
|
||||
display: inline-grid;
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: 1fr 1fr 1fr 2fr;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
|
||||
.personal-show-container {
|
||||
|
@ -79,7 +78,7 @@ select {
|
|||
display: grid;
|
||||
padding: 20px;
|
||||
max-width: 1500px;
|
||||
grid-template-columns: 1fr 2fr 1fr;
|
||||
grid-template-columns: 1fr 3fr;
|
||||
|
||||
.section {
|
||||
padding: 10px 10px;
|
||||
|
@ -208,8 +207,7 @@ select {
|
|||
|
||||
.personal-settings-container {
|
||||
display: inline-grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-template-rows: 1fr 1fr 1fr 1fr 1fr;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
|
||||
&:after {
|
||||
clear: both;
|
||||
|
|
|
@ -358,6 +358,8 @@ class UsersController extends Controller {
|
|||
* @param string|null $addressScope
|
||||
* @param string|null $twitter
|
||||
* @param string|null $twitterScope
|
||||
* @param string|null $mastodon
|
||||
* @param string|null $mastodonScope
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
|
@ -372,8 +374,8 @@ class UsersController extends Controller {
|
|||
?string $websiteScope = null,
|
||||
?string $address = null,
|
||||
?string $addressScope = null,
|
||||
?string $twitter = null,
|
||||
?string $twitterScope = null
|
||||
?string $mastodon = null,
|
||||
?string $mastodonScope = null
|
||||
) {
|
||||
$user = $this->userSession->getUser();
|
||||
if (!$user instanceof IUser) {
|
||||
|
@ -412,6 +414,7 @@ class UsersController extends Controller {
|
|||
IAccountManager::PROPERTY_ADDRESS => ['value' => $address, 'scope' => $addressScope],
|
||||
IAccountManager::PROPERTY_PHONE => ['value' => $phone, 'scope' => $phoneScope],
|
||||
IAccountManager::PROPERTY_TWITTER => ['value' => $twitter, 'scope' => $twitterScope],
|
||||
IAccountManager::PROPERTY_MASTODON => ['value' => $mastodon, 'scope' => $mastodonScope],
|
||||
];
|
||||
$allowUserToChangeDisplayName = $this->config->getSystemValueBool('allow_user_to_change_display_name', true);
|
||||
foreach ($updatable as $property => $data) {
|
||||
|
@ -451,6 +454,8 @@ class UsersController extends Controller {
|
|||
'addressScope' => $userAccount->getProperty(IAccountManager::PROPERTY_ADDRESS)->getScope(),
|
||||
'twitter' => $userAccount->getProperty(IAccountManager::PROPERTY_TWITTER)->getValue(),
|
||||
'twitterScope' => $userAccount->getProperty(IAccountManager::PROPERTY_TWITTER)->getScope(),
|
||||
'mastodon' => $userAccount->getProperty(IAccountManager::PROPERTY_TWITTER)->getValue(),
|
||||
'mastodonScope' => $userAccount->getProperty(IAccountManager::PROPERTY_MASTODON)->getScope(),
|
||||
'message' => $this->l10n->t('Settings saved'),
|
||||
],
|
||||
],
|
||||
|
|
|
@ -157,6 +157,7 @@ class PersonalInfo implements ISettings {
|
|||
'location' => $this->getProperty($account, IAccountManager::PROPERTY_ADDRESS),
|
||||
'website' => $this->getProperty($account, IAccountManager::PROPERTY_WEBSITE),
|
||||
'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
|
||||
'mastodon' => $this->getProperty($account, IAccountManager::PROPERTY_MASTODON),
|
||||
'languageMap' => $this->getLanguageMap($user),
|
||||
'localeMap' => $this->getLocaleMap($user),
|
||||
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<!--
|
||||
- @copyright 2022 Christopher Ng <chrng8@gmail.com>
|
||||
-
|
||||
- @author Christopher Ng <chrng8@gmail.com>
|
||||
-
|
||||
- @license AGPL-3.0-or-later
|
||||
-
|
||||
- This program is free software: you can redistribute it and/or modify
|
||||
- it under the terms of the GNU Affero General Public License as
|
||||
- published by the Free Software Foundation, either version 3 of the
|
||||
- License, or (at your option) any later version.
|
||||
-
|
||||
- This program is distributed in the hope that it will be useful,
|
||||
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
- GNU Affero General Public License for more details.
|
||||
-
|
||||
- You should have received a copy of the GNU Affero General Public License
|
||||
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-
|
||||
-->
|
||||
|
||||
<template>
|
||||
<AccountPropertySection v-bind.sync="mastodon"
|
||||
:placeholder="t('settings', 'Your Mastodon handle')" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { loadState } from '@nextcloud/initial-state'
|
||||
|
||||
import AccountPropertySection from './shared/AccountPropertySection.vue'
|
||||
|
||||
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
|
||||
|
||||
const { mastodon } = loadState('settings', 'personalInfoParameters', {})
|
||||
|
||||
export default {
|
||||
name: 'TwitterSection',
|
||||
|
||||
components: {
|
||||
AccountPropertySection,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
mastodon: { ...mastodon, readable: NAME_READABLE_ENUM[mastodon.name] },
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
|
@ -36,6 +36,7 @@ export const ACCOUNT_PROPERTY_ENUM = Object.freeze({
|
|||
EMAIL: 'email',
|
||||
HEADLINE: 'headline',
|
||||
NOTIFICATION_EMAIL: 'notify_email',
|
||||
MASTODON: 'mastodon',
|
||||
ORGANISATION: 'organisation',
|
||||
PHONE: 'phone',
|
||||
PROFILE_ENABLED: 'profile_enabled',
|
||||
|
@ -58,6 +59,7 @@ export const ACCOUNT_PROPERTY_READABLE_ENUM = Object.freeze({
|
|||
PROFILE_ENABLED: t('settings', 'Profile'),
|
||||
ROLE: t('settings', 'Role'),
|
||||
TWITTER: t('settings', 'Twitter'),
|
||||
MASTODON: t('settings', 'Mastodon'),
|
||||
WEBSITE: t('settings', 'Website'),
|
||||
})
|
||||
|
||||
|
@ -74,6 +76,7 @@ export const NAME_READABLE_ENUM = Object.freeze({
|
|||
[ACCOUNT_PROPERTY_ENUM.PROFILE_ENABLED]: ACCOUNT_PROPERTY_READABLE_ENUM.PROFILE_ENABLED,
|
||||
[ACCOUNT_PROPERTY_ENUM.ROLE]: ACCOUNT_PROPERTY_READABLE_ENUM.ROLE,
|
||||
[ACCOUNT_PROPERTY_ENUM.TWITTER]: ACCOUNT_PROPERTY_READABLE_ENUM.TWITTER,
|
||||
[ACCOUNT_PROPERTY_ENUM.MASTODON]: ACCOUNT_PROPERTY_READABLE_ENUM.MASTODON,
|
||||
[ACCOUNT_PROPERTY_ENUM.WEBSITE]: ACCOUNT_PROPERTY_READABLE_ENUM.WEBSITE,
|
||||
})
|
||||
|
||||
|
@ -96,6 +99,7 @@ export const PROPERTY_READABLE_KEYS_ENUM = Object.freeze({
|
|||
[ACCOUNT_PROPERTY_READABLE_ENUM.PROFILE_ENABLED]: ACCOUNT_PROPERTY_ENUM.PROFILE_ENABLED,
|
||||
[ACCOUNT_PROPERTY_READABLE_ENUM.ROLE]: ACCOUNT_PROPERTY_ENUM.ROLE,
|
||||
[ACCOUNT_PROPERTY_READABLE_ENUM.TWITTER]: ACCOUNT_PROPERTY_ENUM.TWITTER,
|
||||
[ACCOUNT_PROPERTY_READABLE_ENUM.MASTODON]: ACCOUNT_PROPERTY_ENUM.MASTODON,
|
||||
[ACCOUNT_PROPERTY_READABLE_ENUM.WEBSITE]: ACCOUNT_PROPERTY_ENUM.WEBSITE,
|
||||
})
|
||||
|
||||
|
@ -137,6 +141,7 @@ export const PROPERTY_READABLE_SUPPORTED_SCOPES_ENUM = Object.freeze({
|
|||
[ACCOUNT_PROPERTY_READABLE_ENUM.PROFILE_ENABLED]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
|
||||
[ACCOUNT_PROPERTY_READABLE_ENUM.ROLE]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
|
||||
[ACCOUNT_PROPERTY_READABLE_ENUM.TWITTER]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
|
||||
[ACCOUNT_PROPERTY_READABLE_ENUM.MASTODON]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
|
||||
[ACCOUNT_PROPERTY_READABLE_ENUM.WEBSITE]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
|
||||
})
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import PhoneSection from './components/PersonalInfo/PhoneSection.vue'
|
|||
import LocationSection from './components/PersonalInfo/LocationSection.vue'
|
||||
import WebsiteSection from './components/PersonalInfo/WebsiteSection.vue'
|
||||
import TwitterSection from './components/PersonalInfo/TwitterSection.vue'
|
||||
import MastodonSection from './components/PersonalInfo/MastodonSection.vue'
|
||||
import LanguageSection from './components/PersonalInfo/LanguageSection/LanguageSection.vue'
|
||||
import LocaleSection from './components/PersonalInfo/LocaleSection/LocaleSection.vue'
|
||||
import ProfileSection from './components/PersonalInfo/ProfileSection/ProfileSection.vue'
|
||||
|
@ -61,6 +62,7 @@ const PhoneView = Vue.extend(PhoneSection)
|
|||
const LocationView = Vue.extend(LocationSection)
|
||||
const WebsiteView = Vue.extend(WebsiteSection)
|
||||
const TwitterView = Vue.extend(TwitterSection)
|
||||
const MastodonView = Vue.extend(MastodonSection)
|
||||
const LanguageView = Vue.extend(LanguageSection)
|
||||
const LocaleView = Vue.extend(LocaleSection)
|
||||
|
||||
|
@ -72,6 +74,7 @@ new PhoneView().$mount('#vue-phone-section')
|
|||
new LocationView().$mount('#vue-location-section')
|
||||
new WebsiteView().$mount('#vue-website-section')
|
||||
new TwitterView().$mount('#vue-twitter-section')
|
||||
new MastodonView().$mount('#vue-mastodon-section')
|
||||
new LanguageView().$mount('#vue-language-section')
|
||||
new LocaleView().$mount('#vue-locale-section')
|
||||
|
||||
|
|
|
@ -59,6 +59,11 @@ script('settings', [
|
|||
<div class="personal-settings-setting-box">
|
||||
<div id="vue-email-section"></div>
|
||||
</div>
|
||||
<?php if ($_['profileEnabledGlobally']) : ?>
|
||||
<div class="personal-settings-setting-box">
|
||||
<div id="vue-profile-section"></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="personal-settings-setting-box">
|
||||
<div id="vue-phone-section"></div>
|
||||
</div>
|
||||
|
@ -71,6 +76,9 @@ script('settings', [
|
|||
<div class="personal-settings-setting-box">
|
||||
<div id="vue-twitter-section"></div>
|
||||
</div>
|
||||
<div class="personal-settings-setting-box">
|
||||
<div id="vue-mastodon-section"></div>
|
||||
</div>
|
||||
<?php if ($_['profileEnabledGlobally']) : ?>
|
||||
<div class="personal-settings-setting-box">
|
||||
<div id="vue-organisation-section"></div>
|
||||
|
@ -85,14 +93,6 @@ script('settings', [
|
|||
<div id="vue-biography-section"></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="profile-settings-container">
|
||||
<?php if ($_['profileEnabledGlobally']) : ?>
|
||||
<div class="personal-settings-setting-box">
|
||||
<div id="vue-profile-section"></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="personal-settings-setting-box personal-settings-language-box">
|
||||
<div id="vue-language-section"></div>
|
||||
</div>
|
||||
|
|
|
@ -216,7 +216,7 @@ class ClientFlowLoginV2Controller extends Controller {
|
|||
return $response;
|
||||
}
|
||||
|
||||
$result = $this->loginFlowV2Service->flowDoneWithAppPassword($loginToken, $this->getServerPath(), $this->userId, $password);
|
||||
$result = $this->loginFlowV2Service->flowDoneWithAppPassword($loginToken, $this->getServerPath(), $user, $password);
|
||||
return $this->handleFlowDone($result);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
fill="#000000"
|
||||
viewBox="0 0 32 32"
|
||||
width="32px"
|
||||
height="32px"
|
||||
version="1.1"
|
||||
id="svg4"
|
||||
sodipodi:docname="mastodon.svg"
|
||||
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs8" />
|
||||
<sodipodi:namedview
|
||||
id="namedview6"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
showgrid="false"
|
||||
inkscape:zoom="27.21875"
|
||||
inkscape:cx="23.990815"
|
||||
inkscape:cy="11.646383"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1007"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg4" />
|
||||
<path
|
||||
d="M 16.092108,4.0424002e-4 C 12.062352,0.01674741 8.0611741,0.52836757 5.9792557,1.4882781 c 0,0 -4.4792557,2.0390593 -4.4792557,8.9845679 0,8.267636 -0.006,18.650381 7.4211287,20.658254 2.8443783,0.76446 5.2904523,0.928996 7.2569683,0.815594 3.568811,-0.201455 5.333936,-1.295049 5.333936,-1.295049 l -0.119865,-2.637001 c 0,0 -2.313201,0.815177 -5.177591,0.721787 -2.837706,-0.100064 -5.827232,-0.31302 -6.2928463,-3.856484 -0.042694,-0.329532 -0.063873,-0.663192 -0.062538,-0.995391 6.0129483,1.492897 11.1403013,0.650223 12.5518183,0.479455 3.941035,-0.478955 7.371787,-2.95017 7.809382,-5.208861 0.685746,-3.559473 0.627983,-8.682304 0.627983,-8.682304 0,-6.9455086 -4.47144,-8.9845679 -4.47144,-8.9845679 C 24.181616,0.4629949 20.121863,-0.01593892 16.092108,4.0424002e-4 Z M 11.779618,5.2978601 c 1.380664,0.037022 2.744984,0.6547271 3.585489,1.9595116 l 0.81299,1.3810381 0.810383,-1.3810381 c 1.687681,-2.6242446 5.470248,-2.4605003 7.269996,-0.429946 1.659664,1.9318288 1.289838,3.1786613 1.289838,11.8091823 v 0.0025 H 22.28333 v -7.509723 c 0,-3.5154475 -4.481861,-3.6512167 -4.481861,0.487271 v 4.351575 H 14.55733 V 11.6167 c 0,-4.1384877 -4.479254,-4.0053242 -4.479254,-0.489878 v 7.509724 H 6.8052731 c 0,-8.6371452 -0.3631558,-9.8919821 1.2898381,-11.8091356 C 9.0016558,5.8054625 10.398956,5.2608226 11.779618,5.2978448 Z"
|
||||
id="path2"
|
||||
style="stroke-width:1.33413" />
|
||||
</svg>
|
После Ширина: | Высота: | Размер: 2.4 KiB |
|
@ -131,6 +131,7 @@ class AccountManager implements IAccountManager {
|
|||
self::PROPERTY_AVATAR => self::SCOPE_FEDERATED,
|
||||
self::PROPERTY_PHONE => self::SCOPE_LOCAL,
|
||||
self::PROPERTY_TWITTER => self::SCOPE_LOCAL,
|
||||
self::PROPERTY_MASTODON => self::SCOPE_LOCAL,
|
||||
self::PROPERTY_ORGANISATION => self::SCOPE_LOCAL,
|
||||
self::PROPERTY_ROLE => self::SCOPE_LOCAL,
|
||||
self::PROPERTY_HEADLINE => self::SCOPE_LOCAL,
|
||||
|
@ -525,6 +526,7 @@ class AccountManager implements IAccountManager {
|
|||
protected function updateVerificationStatus(IAccount $updatedAccount, array $oldData): void {
|
||||
static $propertiesVerifiableByLookupServer = [
|
||||
self::PROPERTY_TWITTER,
|
||||
self::PROPERTY_MASTODON,
|
||||
self::PROPERTY_WEBSITE,
|
||||
self::PROPERTY_EMAIL,
|
||||
];
|
||||
|
@ -723,6 +725,13 @@ class AccountManager implements IAccountManager {
|
|||
'verified' => self::NOT_VERIFIED,
|
||||
],
|
||||
|
||||
[
|
||||
'name' => self::PROPERTY_MASTODON,
|
||||
'value' => '',
|
||||
'scope' => $scopes[self::PROPERTY_MASTODON],
|
||||
'verified' => self::NOT_VERIFIED,
|
||||
],
|
||||
|
||||
[
|
||||
'name' => self::PROPERTY_ORGANISATION,
|
||||
'value' => '',
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2021 Christopher Ng <chrng8@gmail.com>
|
||||
*
|
||||
* @author Christopher Ng <chrng8@gmail.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Profile\Actions;
|
||||
|
||||
use function Safe\substr;
|
||||
use OCP\Accounts\IAccountManager;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUser;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\Profile\ILinkAction;
|
||||
|
||||
class MastodonAction implements ILinkAction {
|
||||
private ?string $value = null;
|
||||
private IAccountManager $accountManager;
|
||||
private IFactory $l10nFactory;
|
||||
private IURLGenerator $urlGenerator;
|
||||
|
||||
public function __construct(
|
||||
IAccountManager $accountManager,
|
||||
IFactory $l10nFactory,
|
||||
IURLGenerator $urlGenerator
|
||||
) {
|
||||
$this->accountManager = $accountManager;
|
||||
$this->l10nFactory = $l10nFactory;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
public function preload(IUser $targetUser): void {
|
||||
$account = $this->accountManager->getAccount($targetUser);
|
||||
$this->value = $account->getProperty(IAccountManager::PROPERTY_MASTODON)->getValue();
|
||||
}
|
||||
|
||||
public function getAppId(): string {
|
||||
return 'core';
|
||||
}
|
||||
|
||||
public function getId(): string {
|
||||
return IAccountManager::PROPERTY_MASTODON;
|
||||
}
|
||||
|
||||
public function getDisplayId(): string {
|
||||
return $this->l10nFactory->get('lib')->t('Mastodon');
|
||||
}
|
||||
|
||||
public function getTitle(): string {
|
||||
$displayUsername = $this->value[0] === '@' ? $this->value : '@' . $this->value;
|
||||
return $this->l10nFactory->get('lib')->t('View %s on Mastodon', [$displayUsername]);
|
||||
}
|
||||
|
||||
public function getPriority(): int {
|
||||
return 50;
|
||||
}
|
||||
|
||||
public function getIcon(): string {
|
||||
return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mastodon.svg'));
|
||||
}
|
||||
|
||||
public function getTarget(): ?string {
|
||||
if (empty($this->value)) {
|
||||
return null;
|
||||
}
|
||||
$username = $this->value[0] === '@' ? substr($this->value, 1) : $this->value;
|
||||
[$username, $instance] = explode('@', $username);
|
||||
return 'https://' . $instance . '/@' . $username;
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ use OC\KnownUser\KnownUserService;
|
|||
use OC\Profile\Actions\EmailAction;
|
||||
use OC\Profile\Actions\PhoneAction;
|
||||
use OC\Profile\Actions\TwitterAction;
|
||||
use OC\Profile\Actions\MastodonAction;
|
||||
use OC\Profile\Actions\WebsiteAction;
|
||||
use OCP\Accounts\IAccountManager;
|
||||
use OCP\Accounts\PropertyDoesNotExistException;
|
||||
|
@ -95,6 +96,7 @@ class ProfileManager {
|
|||
PhoneAction::class,
|
||||
WebsiteAction::class,
|
||||
TwitterAction::class,
|
||||
MastodonAction::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -112,6 +112,7 @@ interface IAccountManager {
|
|||
public const PROPERTY_WEBSITE = 'website';
|
||||
public const PROPERTY_ADDRESS = 'address';
|
||||
public const PROPERTY_TWITTER = 'twitter';
|
||||
public const PROPERTY_MASTODON = 'mastodon';
|
||||
|
||||
/**
|
||||
* @since 23.0.0
|
||||
|
@ -151,6 +152,7 @@ interface IAccountManager {
|
|||
self::PROPERTY_WEBSITE,
|
||||
self::PROPERTY_ADDRESS,
|
||||
self::PROPERTY_TWITTER,
|
||||
self::PROPERTY_MASTODON,
|
||||
self::PROPERTY_ORGANISATION,
|
||||
self::PROPERTY_ROLE,
|
||||
self::PROPERTY_HEADLINE,
|
||||
|
|
Загрузка…
Ссылка в новой задаче