Merge branch 'master' into fill-follows-table

pull/184/head
Maxence Lange 2018-12-18 15:24:51 -01:00 zatwierdzone przez GitHub
commit 428c14d37e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
14 zmienionych plików z 996 dodań i 1069 usunięć

Wyświetl plik

@ -4,6 +4,71 @@ clone:
depth: 1 depth: 1
pipeline: pipeline:
check-app-compatbility:
image: nextcloudci/php7.0:php7.0-17
environment:
- APP_NAME=social
- CORE_BRANCH=stable15
- DB=sqlite
commands:
# Pre-setup steps
- wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
- bash ./before_install.sh $APP_NAME $CORE_BRANCH $DB
- cd ../server
# Code checker
- ./occ app:check-code $APP_NAME -c strong-comparison
- ./occ app:check-code $APP_NAME -c deprecation
when:
matrix:
TESTS: check-app-compatbility
syntax-php7.0:
image: nextcloudci/php7.0:php7.0-17
environment:
- APP_NAME=social
- CORE_BRANCH=stable15
- DB=sqlite
commands:
- composer install
- ./vendor/bin/parallel-lint --exclude ./vendor/ .
when:
matrix:
TESTS: syntax-php7.0
syntax-php7.1:
image: nextcloudci/php7.1:php7.1-15
environment:
- APP_NAME=social
- CORE_BRANCH=stable15
- DB=sqlite
commands:
- composer install
- ./vendor/bin/parallel-lint --exclude ./vendor/ .
when:
matrix:
TESTS: syntax-php7.1
syntax-php7.2:
image: nextcloudci/php7.2:php7.2-9
environment:
- APP_NAME=social
- CORE_BRANCH=stable15
- DB=sqlite
commands:
- composer install
- ./vendor/bin/parallel-lint --exclude ./vendor/ .
when:
matrix:
TESTS: syntax-php7.2
syntax-php7.3:
image: nextcloudci/php7.3:php7.3-2
environment:
- APP_NAME=social
- CORE_BRANCH=stable15
- DB=sqlite
commands:
- composer install
- ./vendor/bin/parallel-lint --exclude ./vendor/ .
when:
matrix:
TESTS: syntax-php7.3
eslint: eslint:
image: nextcloudci/jsunit:jsunit-5 image: nextcloudci/jsunit:jsunit-5
commands: commands:
@ -12,7 +77,6 @@ pipeline:
when: when:
matrix: matrix:
TESTS: eslint TESTS: eslint
vue-build: vue-build:
image: nextcloudci/jsunit:jsunit-5 image: nextcloudci/jsunit:jsunit-5
commands: commands:
@ -20,10 +84,15 @@ pipeline:
- npm run build - npm run build
when: when:
matrix: matrix:
TESTS:vue-build TESTS: vue-build
matrix: matrix:
include: include:
- TESTS: check-app-compatbility
- TESTS: syntax-php7.0
- TESTS: syntax-php7.1
- TESTS: syntax-php7.2
- TESTS: syntax-php7.3
- TESTS: eslint - TESTS: eslint
- TESTS: vue-build - TESTS: vue-build

Wyświetl plik

@ -26,8 +26,8 @@
<namespace>Social</namespace> <namespace>Social</namespace>
<category>social</category> <category>social</category>
<website>https://github.com/nextcloud/social</website> <website>https://github.com/nextcloud/social</website>
<repository type="git">https://github.com/nextcloud/social.git</repository>
<bugs>https://github.com/nextcloud/social/issues</bugs> <bugs>https://github.com/nextcloud/social/issues</bugs>
<repository type="git">https://github.com/nextcloud/social.git</repository>
<screenshot>https://raw.githubusercontent.com/nextcloud/social/master/img/screenshot.png</screenshot> <screenshot>https://raw.githubusercontent.com/nextcloud/social/master/img/screenshot.png</screenshot>
<dependencies> <dependencies>
<nextcloud min-version="15" max-version="16"/> <nextcloud min-version="15" max-version="16"/>
@ -39,14 +39,6 @@
</post-migration> </post-migration>
</repair-steps> </repair-steps>
<navigations>
<navigation>
<name>Social</name>
<route>social.Navigation.navigate</route>
<order>6</order>
</navigation>
</navigations>
<background-jobs> <background-jobs>
<job>OCA\Social\Cron\Cache</job> <job>OCA\Social\Cron\Cache</job>
<job>OCA\Social\Cron\Queue</job> <job>OCA\Social\Cron\Queue</job>
@ -59,4 +51,11 @@
<command>OCA\Social\Command\QueueProcess</command> <command>OCA\Social\Command\QueueProcess</command>
</commands> </commands>
<navigations>
<navigation>
<name>Social</name>
<route>social.Navigation.navigate</route>
<order>6</order>
</navigation>
</navigations>
</info> </info>

Wyświetl plik

@ -11,5 +11,8 @@
], ],
"require": { "require": {
"daita/my-small-php-tools": "dev-master" "daita/my-small-php-tools": "dev-master"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "^1.0"
} }
} }

55
composer.lock wygenerowano
Wyświetl plik

@ -1,10 +1,10 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "02220c2a6087d409a5e53060ee20c47e", "content-hash": "17d7e7fc4c9cdd0ddc5d6166607fce8f",
"packages": [ "packages": [
{ {
"name": "daita/my-small-php-tools", "name": "daita/my-small-php-tools",
@ -43,7 +43,56 @@
"time": "2018-12-08T15:17:26+00:00" "time": "2018-12-08T15:17:26+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [
{
"name": "jakub-onderka/php-parallel-lint",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git",
"reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/04fbd3f5fb1c83f08724aa58a23db90bd9086ee8",
"reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"jakub-onderka/php-console-highlighter": "~0.3",
"nette/tester": "~1.3",
"squizlabs/php_codesniffer": "~2.7"
},
"suggest": {
"jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet"
},
"bin": [
"parallel-lint"
],
"type": "library",
"autoload": {
"classmap": [
"./"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Jakub Onderka",
"email": "ahoj@jakubonderka.cz"
}
],
"description": "This tool check syntax of PHP files about 20x faster than serial check.",
"homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint",
"time": "2018-02-24T15:31:20+00:00"
}
],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": {

Wyświetl plik

@ -148,9 +148,6 @@ class NavigationController extends Controller {
] ]
]; ];
$checks = $this->checkService->checkDefault();
$data['serverData']['checks'] = $checks;
try { try {
$data['serverData']['cloudAddress'] = $this->configService->getCloudAddress(); $data['serverData']['cloudAddress'] = $this->configService->getCloudAddress();
} catch (SocialAppConfigException $e) { } catch (SocialAppConfigException $e) {
@ -172,6 +169,11 @@ class NavigationController extends Controller {
} }
} }
if ($data['serverData']['isAdmin']) {
$checks = $this->checkService->checkDefault();
$data['serverData']['checks'] = $checks;
}
/* /*
* Create social user account if it doesn't exist yet * Create social user account if it doesn't exist yet
*/ */

Wyświetl plik

@ -93,19 +93,21 @@ class QueueController extends Controller {
* @param string $token * @param string $token
*/ */
public function asyncWithToken(string $token) { public function asyncWithToken(string $token) {
$this->async();
$requests = $this->queueService->getRequestFromToken($token, RequestQueue::STATUS_STANDBY); $requests = $this->queueService->getRequestFromToken($token, RequestQueue::STATUS_STANDBY);
$this->activityService->manageInit();
foreach ($requests as $request) { if (!empty($requests)) {
$request->setTimeout(ActivityService::TIMEOUT_ASYNC); $this->async();
try {
$this->activityService->manageRequest($request); $this->activityService->manageInit();
} catch (RequestException $e) { foreach ($requests as $request) {
} catch (SocialAppConfigException $e) { $request->setTimeout(ActivityService::TIMEOUT_ASYNC);
try {
$this->activityService->manageRequest($request);
} catch (RequestException $e) {
} catch (SocialAppConfigException $e) {
}
} }
} }
// or it will feed the logs. // or it will feed the logs.
exit(); exit();
} }

Wyświetl plik

@ -62,10 +62,13 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
* insert cache about an Actor in database. * insert cache about an Actor in database.
* *
* @param Person $actor * @param Person $actor
*
* @return int
*/ */
public function save(Person $actor): int { public function save(Person $actor) {
$source = $actor->getSource();
if (strlen($source) >= CoreRequestBuilder::SOURCE_LENGTH) {
$source = 'too_big';
}
$qb = $this->getCacheActorsInsertSql(); $qb = $this->getCacheActorsInsertSql();
$qb->setValue('id', $qb->createNamedParameter($actor->getId())) $qb->setValue('id', $qb->createNamedParameter($actor->getId()))
->setValue('account', $qb->createNamedParameter($actor->getAccount())) ->setValue('account', $qb->createNamedParameter($actor->getAccount()))
@ -84,7 +87,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
->setValue('name', $qb->createNamedParameter($actor->getName())) ->setValue('name', $qb->createNamedParameter($actor->getName()))
->setValue('summary', $qb->createNamedParameter($actor->getSummary())) ->setValue('summary', $qb->createNamedParameter($actor->getSummary()))
->setValue('public_key', $qb->createNamedParameter($actor->getPublicKey())) ->setValue('public_key', $qb->createNamedParameter($actor->getPublicKey()))
->setValue('source', $qb->createNamedParameter($actor->getSource())) ->setValue('source', $qb->createNamedParameter($source))
->setValue('details', $qb->createNamedParameter(json_encode($actor->getDetails()))) ->setValue('details', $qb->createNamedParameter(json_encode($actor->getDetails())))
->setValue( ->setValue(
'creation', 'creation',
@ -101,8 +104,6 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
$qb->setValue('icon_id', $qb->createNamedParameter($iconId)); $qb->setValue('icon_id', $qb->createNamedParameter($iconId));
$qb->execute(); $qb->execute();
return $qb->getLastInsertId();
} }

Wyświetl plik

@ -64,6 +64,9 @@ class CoreRequestBuilder {
const TABLE_CACHE_DOCUMENTS = 'social_cache_documents'; const TABLE_CACHE_DOCUMENTS = 'social_cache_documents';
const SOURCE_LENGTH = 10000;
/** @var IDBConnection */ /** @var IDBConnection */
protected $dbConnection; protected $dbConnection;

Wyświetl plik

@ -61,13 +61,16 @@ class NotesRequest extends NotesRequestBuilder {
* Insert a new Note in the database. * Insert a new Note in the database.
* *
* @param Note $note * @param Note $note
*
* @return int
*/ */
public function save(Note $note): int { public function save(Note $note) {
$dTime = new DateTime(); $dTime = new DateTime();
$dTime->setTimestamp($note->getPublishedTime()); $dTime->setTimestamp($note->getPublishedTime());
$source = $note->getSource();
if (strlen($source) >= CoreRequestBuilder::SOURCE_LENGTH) {
$source = 'too_big';
}
$qb = $this->getNotesInsertSql(); $qb = $this->getNotesInsertSql();
$qb->setValue('id', $qb->createNamedParameter($note->getId())) $qb->setValue('id', $qb->createNamedParameter($note->getId()))
->setValue('type', $qb->createNamedParameter($note->getType())) ->setValue('type', $qb->createNamedParameter($note->getType()))
@ -95,7 +98,7 @@ class NotesRequest extends NotesRequestBuilder {
) )
->setValue('attributed_to', $qb->createNamedParameter($note->getAttributedTo())) ->setValue('attributed_to', $qb->createNamedParameter($note->getAttributedTo()))
->setValue('in_reply_to', $qb->createNamedParameter($note->getInReplyTo())) ->setValue('in_reply_to', $qb->createNamedParameter($note->getInReplyTo()))
->setValue('source', $qb->createNamedParameter($note->getSource())) ->setValue('source', $qb->createNamedParameter($source))
->setValue( ->setValue(
'instances', $qb->createNamedParameter( 'instances', $qb->createNamedParameter(
json_encode($note->getInstancePaths(), JSON_UNESCAPED_SLASHES) json_encode($note->getInstancePaths(), JSON_UNESCAPED_SLASHES)
@ -108,8 +111,6 @@ class NotesRequest extends NotesRequestBuilder {
); );
$qb->execute(); $qb->execute();
return $qb->getLastInsertId();
} }

Wyświetl plik

@ -0,0 +1,88 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.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 OCA\Social\Migration;
use Closure;
use OCA\Social\Db\CoreRequestBuilder;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Class Version0001Date20181208185242
*
* @package OCA\Social\Migration
*/
class Version0001Date20181208185242 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return ISchemaWrapper
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options
): ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable(CoreRequestBuilder::TABLE_CACHE_ACTORS);
$table->changeColumn(
'source', [
'notnull' => true,
'length' => CoreRequestBuilder::SOURCE_LENGTH,
]
);
$table = $schema->getTable(CoreRequestBuilder::TABLE_SERVER_NOTES);
$table->changeColumn(
'source', [
'notnull' => true,
'length' => CoreRequestBuilder::SOURCE_LENGTH,
]
);
$table = $schema->getTable(CoreRequestBuilder::TABLE_REQUEST_QUEUE);
$table->changeColumn(
'activity', [
'notnull' => true,
'length' => CoreRequestBuilder::SOURCE_LENGTH,
]
);
return $schema;
}
}

Wyświetl plik

@ -45,7 +45,6 @@ use OCA\Social\Model\ActivityPub\Person;
use OCA\Social\Service\ActivityPub\DocumentService; use OCA\Social\Service\ActivityPub\DocumentService;
use OCA\Social\Service\ActivityPub\PersonService; use OCA\Social\Service\ActivityPub\PersonService;
use OCP\Accounts\IAccountManager; use OCP\Accounts\IAccountManager;
use OCP\Accounts\PropertyDoesNotExistException;
use OCP\IUserManager; use OCP\IUserManager;
@ -264,6 +263,12 @@ class ActorService {
try { try {
$actor = $this->getActor($username); $actor = $this->getActor($username);
try {
$this->updateCacheLocalActorName($actor);
} catch (NoUserException $e) {
return;
}
$iconId = $this->documentService->cacheLocalAvatarByUsername($actor); $iconId = $this->documentService->cacheLocalAvatarByUsername($actor);
$actor->setIconId($iconId); $actor->setIconId($iconId);
@ -274,7 +279,6 @@ class ActorService {
]; ];
$actor->addDetailArray('count', $count); $actor->addDetailArray('count', $count);
$this->updateCacheLocalActorName($actor);
$this->personService->cacheLocalActor($actor, $refresh); $this->personService->cacheLocalActor($actor, $refresh);
} catch (ActorDoesNotExistException $e) { } catch (ActorDoesNotExistException $e) {
@ -284,17 +288,25 @@ class ActorService {
/** /**
* @param Person $actor * @param Person $actor
*
* @throws NoUserException
*/ */
private function updateCacheLocalActorName(Person &$actor) { private function updateCacheLocalActorName(Person &$actor) {
$user = $this->userManager->get($actor->getUserId()); $user = $this->userManager->get($actor->getUserId());
$account = $this->accountManager->getAccount($user); if ($user === null) {
throw new NoUserException();
}
try { try {
$account = $this->accountManager->getAccount($user);
$displayNameProperty = $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME); $displayNameProperty = $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME);
if ($displayNameProperty->getScope() === IAccountManager::VISIBILITY_PUBLIC) { if ($displayNameProperty->getScope() === IAccountManager::VISIBILITY_PUBLIC) {
$actor->setName($displayNameProperty->getValue()); $actor->setName($displayNameProperty->getValue());
} }
} catch (PropertyDoesNotExistException $e) { } catch (Exception $e) {
$this->miscService->log(
'Issue while trying to updateCacheLocalActorName: ' . $e->getMessage(), 1
);
} }
} }
@ -335,7 +347,6 @@ class ActorService {
*/ */
public function manageCacheLocalActors(): int { public function manageCacheLocalActors(): int {
$update = $this->actorsRequest->getAll(); $update = $this->actorsRequest->getAll();
foreach ($update as $item) { foreach ($update as $item) {
try { try {
$this->cacheLocalActorByUsername($item->getPreferredUsername(), true); $this->cacheLocalActorByUsername($item->getPreferredUsername(), true);

Wyświetl plik

@ -235,7 +235,7 @@ class ImportService {
$service->parse($activity); $service->parse($activity);
} catch (Exception $e) { } catch (Exception $e) {
$this->miscService->log( $this->miscService->log(
2, 'Cannot parse ' . $activity->getType() . ': ' . $e->getMessage() 'Cannot parse ' . $activity->getType() . ': ' . $e->getMessage()
); );
} }
} }

1717
package-lock.json wygenerowano

Plik diff jest za duży Load Diff

Wyświetl plik

@ -29,17 +29,17 @@
"dependencies": { "dependencies": {
"@babel/polyfill": "^7.0.0", "@babel/polyfill": "^7.0.0",
"linkifyjs": "^2.1.7", "linkifyjs": "^2.1.7",
"nextcloud-axios": "^0.1.2", "nextcloud-axios": "^0.1.3",
"nextcloud-vue": "^0.4.6", "nextcloud-vue": "^0.4.6",
"tributejs": "^3.3.5", "tributejs": "^3.3.5",
"twemoji": "^11.2.0", "twemoji": "^11.2.0",
"uuid": "^3.3.2", "uuid": "^3.3.2",
"v-tooltip": "^2.0.0-rc.33", "v-tooltip": "^2.0.0-rc.33",
"vue": "^2.5.16", "vue": "^2.5.21",
"vue-click-outside": "^1.0.7", "vue-click-outside": "^1.0.7",
"vue-contenteditable-directive": "^1.2.0", "vue-contenteditable-directive": "^1.2.0",
"vue-emoji-picker": "^1.0.1", "vue-emoji-picker": "^1.0.1",
"vue-infinite-loading": "^2.4.1", "vue-infinite-loading": "^2.4.3",
"vue-router": "^3.0.2", "vue-router": "^3.0.2",
"vue-tribute": "^1.0.1", "vue-tribute": "^1.0.1",
"vue-twemoji": "^1.0.1", "vue-twemoji": "^1.0.1",
@ -54,40 +54,40 @@
"node": ">=10.0.0" "node": ">=10.0.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.1.2", "@babel/core": "^7.2.2",
"@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/preset-env": "^7.2.0", "@babel/preset-env": "^7.2.0",
"@vue/test-utils": "^1.0.0-beta.25", "@vue/test-utils": "^1.0.0-beta.27",
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0", "babel-jest": "^23.6.0",
"babel-loader": "^8.0.4", "babel-loader": "^8.0.4",
"css-loader": "^0.28.11", "css-loader": "^2.0.1",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0", "eslint-config-standard": "^11.0.0",
"eslint-friendly-formatter": "^4.0.1", "eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.1", "eslint-loader": "^2.1.1",
"eslint-plugin-import": "^2.13.0", "eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^7.0.1", "eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1", "eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^3.1.0", "eslint-plugin-standard": "^3.1.0",
"eslint-plugin-vue": "^4.5.0", "eslint-plugin-vue": "^4.5.0",
"extract-text-webpack-plugin": "^3.0.2", "extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.11", "file-loader": "^2.0.0",
"jest": "^23.6.0", "jest": "^23.6.0",
"jest-serializer-vue": "^2.0.2", "jest-serializer-vue": "^2.0.2",
"mini-css-extract-plugin": "^0.4.5", "mini-css-extract-plugin": "^0.5.0",
"prettier-eslint": "^8.8.2", "prettier-eslint": "^8.8.2",
"raw-loader": "^0.5.1", "raw-loader": "^1.0.0",
"stylelint": "^8.4.0", "stylelint": "^8.4.0",
"stylelint-config-recommended-scss": "^3.2.0", "stylelint-config-recommended-scss": "^3.2.0",
"stylelint-webpack-plugin": "^0.10.5", "stylelint-webpack-plugin": "^0.10.5",
"vue-jest": "^2.6.0", "vue-jest": "^3.0.2",
"vue-loader": "^15.4.2", "vue-loader": "^15.4.2",
"vue-style-loader": "^4.1.1", "vue-style-loader": "^4.1.1",
"vue-template-compiler": "^2.5.16", "vue-template-compiler": "^2.5.21",
"webpack": "^4.23.1", "webpack": "^4.27.1",
"webpack-cli": "^3.1.2", "webpack-cli": "^3.1.2",
"webpack-merge": "^4.1.2" "webpack-merge": "^4.1.5"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [