diff options
-rw-r--r-- | .drone.yml | 10 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | composer.json | 1 | ||||
-rw-r--r-- | cypress/integration/0.setup.spec.js | 10 | ||||
-rw-r--r-- | cypress/integration/post.spec.js | 30 | ||||
-rw-r--r-- | cypress/support/commands.js | 7 | ||||
-rw-r--r-- | lib/AppInfo/Application.php | 1 | ||||
-rw-r--r-- | lib/Db/SocialLimitsQueryBuilder.php | 4 | ||||
-rw-r--r-- | lib/Db/StreamRequest.php | 3 | ||||
-rw-r--r-- | lib/Migration/Version0003Date20200611000001.php | 2 | ||||
-rw-r--r-- | lib/hostmeta.php | 2 | ||||
-rw-r--r-- | lib/webfinger.php | 2 | ||||
-rw-r--r-- | package-lock.json | 49 | ||||
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | tests/bootstrap.php | 2 |
16 files changed, 93 insertions, 39 deletions
@@ -27,12 +27,12 @@ steps: image: nextcloudci/php7.2:php7.2-9 commands: - composer install - - ./composer/bin/parallel-lint --exclude ./composer/ . + - ./vendor/bin/parallel-lint --exclude ./vendor/ . - name: syntax-php7.3 image: nextcloudci/php7.3:php7.3-5 commands: - composer install - - ./composer/bin/parallel-lint --exclude ./composer/ . + - ./vendor/bin/parallel-lint --exclude ./vendor/ . trigger: branch: - master @@ -50,9 +50,9 @@ steps: CORE_BRANCH: stable20 DB: sqlite commands: + - composer install - bash ./tests/drone-server-setup.sh $APP_NAME $CORE_BRANCH $DB - cd ../server/apps/$APP_NAME - - composer install - phpunit -c tests/phpunit.xml --coverage-clover build/php-unit.coverage.xml trigger: branch: @@ -71,9 +71,9 @@ steps: CORE_BRANCH: stable20 DB: mysql commands: + - composer install - bash ./tests/drone-server-setup.sh $APP_NAME $CORE_BRANCH $DB - cd ../server/apps/$APP_NAME - - composer install - phpunit -c tests/phpunit.xml --coverage-clover build/php-unit.coverage.xml services: - name: mysql @@ -101,9 +101,9 @@ steps: CORE_BRANCH: stable20 DB: postgres commands: + - composer install - bash ./tests/drone-server-setup.sh $APP_NAME $CORE_BRANCH $DB - cd ../server/apps/$APP_NAME - - composer install - phpunit -c tests/phpunit.xml --coverage-clover build/php-unit.coverage.xml services: - name: postgres @@ -3,7 +3,6 @@ js/ node_modules/ vendor/ img/twemoji/ -composer/ cypress/screenshots cypress/snapshots @@ -64,7 +64,7 @@ clean: clean-dev: rm -rf node_modules -build-composer: +composer: composer install --prefer-dist composer update --prefer-dist @@ -88,7 +88,7 @@ github-upload: --file $(build_dir)/$(app_name)-$(version).tar.gz # creating .tar.gz + signature -appstore: dev-setup lint build-js-production build-composer +appstore: dev-setup lint build-js-production composer mkdir -p $(sign_dir) rsync -a \ --exclude=/build \ diff --git a/composer.json b/composer.json index a2b5143e..2a6532ba 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,6 @@ "platform": { "php": "7.0.0" }, - "vendor-dir": "composer/", "optimize-autoloader": true, "classmap-authoritative": true, "autoloader-suffix": "Social" diff --git a/cypress/integration/0.setup.spec.js b/cypress/integration/0.setup.spec.js index 4c60f8bb..7c05bebb 100644 --- a/cypress/integration/0.setup.spec.js +++ b/cypress/integration/0.setup.spec.js @@ -1,7 +1,13 @@ -describe('Social app setup', function() { +let userId = 'janedoe' + Date.now(); +describe('Social app setup', function() { before(function() { - cy.login('admin', 'admin') + cy.nextcloudCreateUser(userId, 'p4ssw0rd') + cy.login(userId, 'p4ssw0rd') + }) + + beforeEach(() => { + Cypress.Cookies.preserveOnce('nc_username', 'nc_token', 'nc_session_id', 'oc_sessionPassphrase'); }) it('See the welcome message', function() { diff --git a/cypress/integration/post.spec.js b/cypress/integration/post.spec.js index 1de7688f..5257b91f 100644 --- a/cypress/integration/post.spec.js +++ b/cypress/integration/post.spec.js @@ -20,15 +20,16 @@ * */ +let userId = 'janedoe' + Date.now(); + describe('Create posts', function() { before(function() { - cy.visit('/apps/social/') - cy.logout() - cy.login('admin', 'admin') - cy.nextcloudCreateUser('janedoe', 'p4ssw0rd') - cy.logout() - cy.login('janedoe', 'p4ssw0rd', '/apps/social/') + // ensure that the admin account is initialized for social + cy.login('admin', 'admin', '/apps/social/') + + cy.nextcloudCreateUser(userId, 'p4ssw0rd') + cy.login(userId, 'p4ssw0rd', '/apps/social/') cy.get('.app-content').should('be.visible') }) @@ -36,7 +37,12 @@ describe('Create posts', function() { cy.screenshot() }) + beforeEach(() => { + Cypress.Cookies.preserveOnce('nc_username', 'nc_token', 'nc_session_id', 'oc_sessionPassphrase'); + }) + it('Write a post to followers', function() { + cy.visit('/apps/social/') cy.server() cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage') cy.get('.new-post input[type=submit]') @@ -51,6 +57,7 @@ describe('Create posts', function() { }) it('Write a post to followers with shift enter', function() { + cy.visit('/apps/social/') cy.server() cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage') cy.get('.new-post').find('[contenteditable]').type('Hello world 2{shift}{enter}') @@ -59,8 +66,10 @@ describe('Create posts', function() { }) it('Write a post to @admin', function() { + cy.visit('/apps/social/') cy.server() cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage') + cy.route('GET', '/index.php/apps/social/api/v1/global/accounts/search') cy.get('.new-post').find('[contenteditable]').type('@adm', {delay: 500}) cy.get('.tribute-container').should('be.visible') cy.get('.tribute-container ul li:first').contains('admin') @@ -68,10 +77,14 @@ describe('Create posts', function() { cy.get('.new-post input[type=submit]') .click() cy.wait('@postMessage') - cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'admin@localhost') + cy.get('.social__timeline div.timeline-entry:first-child').should('contain', '@admin') }) it('Opens the menu and shows that followers is selected by default', function() { + cy.visit('/apps/social/') + cy.server() + cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage') + cy.route('GET', '/index.php/apps/social/api/v1/global/accounts/search') cy.get('.new-post').find('[contenteditable]').click({force: true}).type('@adm{enter} Hello world', {delay: 500, force: true}) cy.wait(500) cy.get('.new-post input[type=submit]').should('not.be.disabled') @@ -86,7 +99,8 @@ describe('Create posts', function() { cy.get('.new-post input[type=submit]') .click() - cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'Hello there').should('contain', 'admin@localhost') + cy.wait('@postMessage') + cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'Hello world').should('contain', '@admin') }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 283f3a19..7b65139a 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -29,10 +29,7 @@ const url = Cypress.config('baseUrl').replace(/\/index.php\/?$/g, '') Cypress.env('baseUrl', url) Cypress.Commands.add('login', (user, password, route = '/apps/files') => { - cy.clearCookies() - Cypress.Cookies.defaults({ - preserve: /^(oc|nc)/, - }) + cy.clearCookies(); cy.visit(route) cy.get('input[name=user]').type(user) cy.get('input[name=password]').type(password) @@ -53,7 +50,7 @@ Cypress.Commands.add('logout', () => { }) Cypress.Commands.add('nextcloudCreateUser', (user, password) => { - cy.clearCookies() + cy.clearCookies(); cy.request({ method: 'POST', url: `${Cypress.env('baseUrl')}/ocs/v1.php/cloud/users?format=json`, diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 87301824..0f7eab91 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -46,6 +46,7 @@ use OCP\AppFramework\QueryException; use OCP\IServerContainer; use Throwable; +require_once __DIR__ . '/../../vendor/autoload.php'; /** * Class Application diff --git a/lib/Db/SocialLimitsQueryBuilder.php b/lib/Db/SocialLimitsQueryBuilder.php index d3249fc7..d3a4ff47 100644 --- a/lib/Db/SocialLimitsQueryBuilder.php +++ b/lib/Db/SocialLimitsQueryBuilder.php @@ -408,7 +408,9 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder { $andX = $expr->andX(); $andX->add($expr->eq($alias . '.stream_id', $this->getDefaultSelectAlias() . '.id_prim')); - $andX->add($this->exprLimitToDBField('actor_id', $this->prim($actorId), true, true, $alias)); + if ($actorId) { + $andX->add($this->exprLimitToDBField('actor_id', $this->prim($actorId), true, true, $alias)); + } $andX->add($this->exprLimitToDBField('type', $type, true, true, $alias)); if ($subType !== '') { diff --git a/lib/Db/StreamRequest.php b/lib/Db/StreamRequest.php index 1e40fbdb..f9d86249 100644 --- a/lib/Db/StreamRequest.php +++ b/lib/Db/StreamRequest.php @@ -489,7 +489,8 @@ class StreamRequest extends StreamRequestBuilder { $qb->selectDestFollowing('sd', ''); $qb->innerJoinSteamDest('recipient', 'id_prim', 'sd', 's'); - $qb->limitToDest(ACore::CONTEXT_PUBLIC, 'recipient', '', 'sd'); + $accountIsViewer = ($qb->hasViewer()) ? ($qb->getViewer()->getId() === $actorId) : false; + $qb->limitToDest($accountIsViewer ? '' : ACore::CONTEXT_PUBLIC, 'recipient', '', 'sd'); $qb->linkToCacheActors('ca', 's.attributed_to_prim'); $qb->leftJoinStreamAction(); diff --git a/lib/Migration/Version0003Date20200611000001.php b/lib/Migration/Version0003Date20200611000001.php index 1202a4a1..e430b3bf 100644 --- a/lib/Migration/Version0003Date20200611000001.php +++ b/lib/Migration/Version0003Date20200611000001.php @@ -1046,7 +1046,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ); $table->setPrimaryKey(['id_prim']); - $table->addUniqueIndex(['url'], 'unique_url'); +// $table->addUniqueIndex(['url'], 'unique_url'); } /** diff --git a/lib/hostmeta.php b/lib/hostmeta.php index 00e56d94..ef130a3f 100644 --- a/lib/hostmeta.php +++ b/lib/hostmeta.php @@ -34,7 +34,7 @@ use OC; use OCA\Social\Service\ConfigService; use OCA\Social\Service\FediverseService; -require_once(__DIR__ . '/../composer/autoload.php'); +require_once(__DIR__ . '/../vendor/autoload.php'); try { $fediverseService = OC::$server->query(FediverseService::class); diff --git a/lib/webfinger.php b/lib/webfinger.php index ba5849e2..2c65be71 100644 --- a/lib/webfinger.php +++ b/lib/webfinger.php @@ -37,7 +37,7 @@ use OCA\Social\Service\ConfigService; use OCA\Social\Service\FediverseService; use OCP\AppFramework\QueryException; -require_once(__DIR__ . '/../composer/autoload.php'); +require_once(__DIR__ . '/../vendor/autoload.php'); if (!array_key_exists('resource', $_GET)) { echo 'missing resource'; diff --git a/package-lock.json b/package-lock.json index 61e66368..3dd774cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14059,15 +14059,39 @@ } }, "raw-loader": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-4.0.1.tgz", - "integrity": "sha512-baolhQBSi3iNh1cglJjA0mYzga+wePk7vdEX//1dTFd+v4TsQlQE0jitJSNF1OIP82rdYulH7otaVmdlDaJ64A==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-4.0.2.tgz", + "integrity": "sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA==", "dev": true, "requires": { "loader-utils": "^2.0.0", - "schema-utils": "^2.6.5" + "schema-utils": "^3.0.0" }, "dependencies": { + "@types/json-schema": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz", + "integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==", + "dev": true + }, + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", + "dev": true + }, "loader-utils": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", @@ -14078,6 +14102,17 @@ "emojis-list": "^3.0.0", "json5": "^2.1.2" } + }, + "schema-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.0.0.tgz", + "integrity": "sha512-6D82/xSzO094ajanoOSbe4YvXWMfn2A//8Y1+MUqFAJul5Bs+yn36xbK9OtNDcRVSBJ9jjeoXftM6CfztsjOAA==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.6", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + } } } }, @@ -16683,9 +16718,9 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==" + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz", + "integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==" }, "v-click-outside": { "version": "3.1.2", diff --git a/package.json b/package.json index cdf9c46d..b218a2f9 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "linkifyjs": "^2.1.8", "tributejs": "^3.7.3", "twemoji": "12.0.1", - "uuid": "^8.3.0", + "uuid": "^8.3.1", "v-tooltip": "^3.0.0-alpha.11", "vue": "^2.6.12", "vue-click-outside": "^1.0.7", @@ -92,7 +92,7 @@ "jest-serializer-vue": "^2.0.2", "node-sass": "^4.14.1", "prettier-eslint": "^11.0.0", - "raw-loader": "^4.0.1", + "raw-loader": "^4.0.2", "sass-loader": "^10.0.2", "style-loader": "^1.3.0", "stylelint": "^8.4.0", diff --git a/tests/bootstrap.php b/tests/bootstrap.php index bf2dc153..0db0e40a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,7 +1,7 @@ <?php require_once __DIR__ . '/../../../tests/bootstrap.php'; -require_once __DIR__.'/../composer/autoload.php'; +require_once __DIR__.'/../vendor/autoload.php'; OC_App::loadApp('social'); OC_Hook::clear(); |