Compare commits

..

23 commits

Author SHA1 Message Date
Ben 4c226d8018
Revert unwanted doc change and add diagram 2023-10-11 21:57:18 +02:00
Ben 020f19123e
Update to new Nextcloud app template 2023-10-11 21:55:03 +02:00
Ben 39414f00dc
Add first draft for documentation (DE) 2023-07-19 17:32:47 +02:00
Ben ccd57b0517
run.sh: Expose ssh at port 2280 and increase PHP memory limit 2023-07-19 14:13:09 +02:00
Ben bf929327c2
Use command shell builtin instead of which 2023-07-19 14:12:31 +02:00
Ben e1d7f7c8d9
Add type annotations to MatrixTicket class 2023-07-19 14:11:47 +02:00
Ben 317630c054
Update packages 2022-07-21 15:32:52 +02:00
Ben b3619d3ae1
Exclude unresolvable tickets
Ticket's Matrix rooms could be missing for whatever reason. Errors are still logged.
2022-07-21 13:39:24 +02:00
Ben 6f855e22c4
Fix indentation/formatting 2022-07-21 13:00:12 +02:00
Ben c282b438e4
Update composer.lock 2022-07-21 13:00:03 +02:00
Ben e3bea945bf
Merge branch 'origin/ticketübersicht_frontend' 2022-07-21 12:54:16 +02:00
Ben 119c2251d2
Remove Element elements by CSS injection
instead of DOM manipulation.
React does not like external DOM manipulation.
2022-04-30 16:28:24 +02:00
Ben 95481a289b
Fix query for current MatrixChat for ticket 2022-04-30 16:03:39 +02:00
Ben 037b95aded
Remove left panel by DOM manipulation 2022-04-30 15:39:20 +02:00
Ben 10a54cf6ac
Create MatrixChat entity, chat rooms for clients 2022-04-30 14:52:32 +02:00
Ben 940c7bed6e
Start implementing matrix chat integration
Implement auto-login for element-web
2022-04-30 14:52:25 +02:00
Ben 33ca2c93db
Add element-web and nextcloud proxy on one origin
Note: continue to use http://localhost:8080 after run.sh
2022-04-30 14:52:24 +02:00
Ben 8fee4d9785
Update dependencies 2022-04-30 14:51:45 +02:00
Ben fdd746de32
Add nextcloud logging config in run.sh 2022-04-23 14:00:56 +02:00
Ben 5a8c3920e1
Fetch tickets after creating example content 2022-04-23 13:59:10 +02:00
Ben 8ab2ccadbe
Add 'control' to the ticket's matrix room var name 2022-04-23 12:58:01 +02:00
Ben 8d6653fb41
Update JavaScript dependencies 2022-02-19 13:17:40 +01:00
Caluera b342f9f74a fill sidebar and add button for new ticket 2021-12-18 16:49:53 +01:00
83 changed files with 20102 additions and 29962 deletions

View file

@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
module.exports = {
extends: [
'@nextcloud',

3
.gitattributes vendored
View file

@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
/js/* binary
*.png -text
*.epgz -text
*.pdf binary

View file

@ -1,24 +0,0 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: weekly
day: saturday
time: "03:00"
timezone: Europe/Paris
open-pull-requests-limit: 10
labels:
- 3. to review
- dependencies
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
day: saturday
time: "03:00"
timezone: Europe/Paris
open-pull-requests-limit: 10
labels:
- 3. to review
- dependencies

View file

@ -1,117 +0,0 @@
name: Compile Command
on:
issue_comment:
types: [created]
jobs:
init:
runs-on: ubuntu-latest
# On pull requests and if the comment starts with `/compile`
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/compile')
outputs:
git_path: ${{ steps.git-path.outputs.path }}
arg1: ${{ steps.command.outputs.arg1 }}
arg2: ${{ steps.command.outputs.arg2 }}
head_ref: ${{ steps.comment-branch.outputs.head_ref }}
steps:
- name: Check actor permission
uses: skjnldsv/check-actor-permission@v2
with:
require: write
- name: Add reaction on start
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
repository: ${{ github.event.repository.full_name }}
comment-id: ${{ github.event.comment.id }}
reaction-type: "+1"
- name: Parse command
uses: skjnldsv/parse-command-comment@master
id: command
# Init path depending on which command is run
- name: Init path
id: git-path
run: |
if ${{ startsWith(steps.command.outputs.arg1, '/') }}; then
echo "::set-output name=path::${{ github.workspace }}${{steps.command.outputs.arg1}}"
else
echo "::set-output name=path::${{ github.workspace }}${{steps.command.outputs.arg2}}"
fi
- name: Init branch
uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch
process:
runs-on: ubuntu-latest
needs: init
steps:
- name: Checkout ${{ needs.init.outputs.head_ref }}
uses: actions/checkout@v2
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
fetch-depth: 0
ref: ${{ needs.init.outputs.head_ref }}
- name: Setup git
run: |
git config --local user.email "nextcloud-command@users.noreply.github.com"
git config --local user.name "nextcloud-command"
- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@v1
id: package-engines-versions
with:
fallbackNode: '^12'
fallbackNpm: '^6'
- name: Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.package-engines-versions.outputs.nodeVersion }}
cache: npm
- name: Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
run: npm i -g npm@"${{ steps.package-engines-versions.outputs.npmVersion }}"
- name: Install dependencies & build
run: |
npm ci
npm run build --if-present
- name: Commit and push default
if: ${{ needs.init.outputs.arg1 != 'fixup' && needs.init.outputs.arg1 != 'amend' }}
run: |
git add ${{ needs.init.outputs.git_path }}
git commit --signoff -m 'Compile assets'
git push origin ${{ needs.init.outputs.head_ref }}
- name: Commit and push fixup
if: ${{ needs.init.outputs.arg1 == 'fixup' }}
run: |
git add ${{ needs.init.outputs.git_path }}
git commit --fixup=HEAD --signoff
git push origin ${{ needs.init.outputs.head_ref }}
- name: Commit and push amend
if: ${{ needs.init.outputs.arg1 == 'amend' }}
run: |
git add ${{ needs.init.outputs.git_path }}
git commit --amend --no-edit --signoff
git push --force origin ${{ needs.init.outputs.head_ref }}
- name: Add reaction on failure
uses: peter-evans/create-or-update-comment@v1
if: failure()
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
repository: ${{ github.event.repository.full_name }}
comment-id: ${{ github.event.comment.id }}
reaction-type: "-1"

View file

@ -1,46 +0,0 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
name: Rebase command
on:
issue_comment:
types: created
jobs:
rebase:
runs-on: ubuntu-latest
# On pull requests and if the comment starts with `/rebase`
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/rebase')
steps:
- name: Add reaction on start
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
repository: ${{ github.event.repository.full_name }}
comment-id: ${{ github.event.comment.id }}
reaction-type: "+1"
- name: Checkout the latest code
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.COMMAND_BOT_PAT }}
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.5
env:
GITHUB_TOKEN: ${{ secrets.COMMAND_BOT_PAT }}
- name: Add reaction on failure
uses: peter-evans/create-or-update-comment@v1
if: failure()
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
repository: ${{ github.event.repository.full_name }}
comment-id: ${{ github.event.comment.id }}
reaction-type: "-1"

View file

@ -1,29 +0,0 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
name: Dependabot
on:
pull_request_target:
branches:
- master
- stable*
jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
# Default github action approve
- uses: hmarr/auto-approve-action@v2
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Nextcloud bot approve and merge request
- uses: ahmadnassri/action-dependabot-auto-merge@v2
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
with:
target: minor
github-token: ${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}

View file

@ -1,12 +0,0 @@
name: Pull request checks
on: pull_request
jobs:
commit-message-check:
name: Block fixup and squash commits
runs-on: ubuntu-latest
steps:
- name: Run check
uses: xt0rted/block-autosquash-commits-action@main
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

47
.github/workflows/lint-eslint.yml vendored Normal file
View file

@ -0,0 +1,47 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
# SPDX-FileCopyrightText: Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Lint
on:
pull_request:
push:
branches:
- main
- master
- stable*
jobs:
lint:
runs-on: ubuntu-latest
name: eslint
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@v1.2
id: versions
with:
fallbackNode: '^16'
fallbackNpm: '^7'
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@v3
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint

33
.github/workflows/lint-info-xml.yml vendored Normal file
View file

@ -0,0 +1,33 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
# SPDX-FileCopyrightText: Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Lint
on:
pull_request:
push:
branches:
- master
- stable*
jobs:
xml-linters:
runs-on: ubuntu-latest
name: info.xml lint
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download schema
run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd
- name: Lint info.xml
uses: ChristophWurst/xmllint-action@v1
with:
xml-file: ./appinfo/info.xml
xml-schema-file: ./info.xsd

37
.github/workflows/lint-php-cs.yml vendored Normal file
View file

@ -0,0 +1,37 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
# SPDX-FileCopyrightText: Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Lint
on:
pull_request:
push:
branches:
- master
- stable*
jobs:
lint:
runs-on: ubuntu-latest
name: php-cs
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
coverage: none
- name: Install dependencies
run: composer i
- name: Lint
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )

49
.github/workflows/lint-php.yml vendored Normal file
View file

@ -0,0 +1,49 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
# SPDX-FileCopyrightText: Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Lint
on:
pull_request:
push:
branches:
- master
- stable*
jobs:
php-lint:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ["7.4", "8.0", "8.1"]
name: php-lint
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
- name: Lint
run: composer run lint
summary:
runs-on: ubuntu-latest
needs: php-lint
if: always()
name: php-lint-summary
steps:
- name: Summary status
run: if ${{ needs.php-lint.result != 'success' && needs.php-lint.result != 'skipped' }}; then exit 1; fi

View file

@ -2,8 +2,10 @@
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
# SPDX-FileCopyrightText: Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Node
name: Lint
on:
pull_request:
@ -13,20 +15,21 @@ on:
- stable*
jobs:
build:
lint:
runs-on: ubuntu-latest
name: node
name: stylelint
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@v1.1
id: versions
with:
fallbackNode: '^12'
fallbackNpm: '^6'
fallbackNode: '^16'
fallbackNpm: '^7'
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@v2
@ -36,17 +39,8 @@ jobs:
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
- name: Install dependencies & build
run: |
npm ci
npm run build --if-present
- name: Install dependencies
run: npm ci
- name: Check webpack build changes
run: |
bash -c "[[ ! \"`git status --porcelain `\" ]] || exit 1"
- name: Show changes on failure
if: failure()
run: |
git status
git --no-pager diff
- name: Lint
run: npm run stylelint

View file

@ -1,111 +0,0 @@
name: Lint
on:
pull_request:
push:
branches:
- master
- stable*
jobs:
php:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ["7.3", "7.4", "8.0"]
name: php${{ matrix.php-versions }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
- name: Lint
run: composer run lint
php-cs-fixer:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ["7.4"]
name: cs php${{ matrix.php-versions }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
- name: Install dependencies
run: composer i
- name: Run coding standards check
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
node:
runs-on: ubuntu-latest
name: eslint node
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Set up npm7
run: npm i -g npm@7
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
stylelint:
runs-on: ubuntu-latest
name: stylelint node
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Set up npm7
run: npm i -g npm@7
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run stylelint
xml-linters:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Download schema
run: wget https://apps.nextcloud.com/schema/apps/info.xsd
- name: Lint info.xml
uses: ChristophWurst/xmllint-action@v1
with:
xml-file: ./appinfo/info.xml
xml-schema-file: ./info.xsd

115
.github/workflows/phpunit-mysql.yml vendored Normal file
View file

@ -0,0 +1,115 @@
# SPDX-FileCopyrightText: Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: PHPUnit
on:
pull_request:
push:
branches:
- master
- stable*
env:
# Location of the phpunit.xml and phpunit.integration.xml files
PHPUNIT_CONFIG: ./tests/phpunit.xml
PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml
jobs:
phpunit-mysql:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.4', '8.0', '8.1']
server-versions: ['master']
services:
mysql:
image: mariadb:10.5
ports:
- 4444:3306/tcp
env:
MYSQL_ROOT_PASSWORD: rootpassword
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
steps:
- name: Set app env
run: |
# Split and keep last
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
- name: Enable ONLY_FULL_GROUP_BY MySQL option
run: |
echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
- name: Checkout server
uses: actions/checkout@v3
with:
submodules: true
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
- name: Checkout app
uses: actions/checkout@v3
with:
path: apps/${{ env.APP_NAME }}
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql
coverage: none
- name: Set up PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: composer i
- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
./occ app:enable ${{ env.APP_NAME }}
- name: Check PHPUnit config file existence
id: check_phpunit
uses: andstor/file-existence-action@v1
with:
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }}
- name: Run Nextcloud
run: php -S localhost:8080 &
- name: PHPUnit
# Only run if phpunit config file exists
if: steps.check_phpunit.outputs.files_exists == 'true'
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
- name: Check PHPUnit integration config file existence
id: check_integration
uses: andstor/file-existence-action@v1
with:
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }}
- name: PHPUnit integration
# Only run if phpunit integration config file exists
if: steps.check_integration.outputs.files_exists == 'true'
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
summary:
runs-on: ubuntu-latest
needs: phpunit-mysql
if: always()
name: phpunit-mysql-summary
steps:
- name: Summary status
run: if ${{ needs.phpunit-mysql.result != 'success' }}; then exit 1; fi

109
.github/workflows/phpunit-oci.yml vendored Normal file
View file

@ -0,0 +1,109 @@
# SPDX-FileCopyrightText: Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: PHPUnit
on:
pull_request:
push:
branches:
- master
- stable*
env:
# Location of the phpunit.xml and phpunit.integration.xml files
PHPUNIT_CONFIG: ./tests/phpunit.xml
PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml
jobs:
phpunit-oci:
runs-on: ubuntu-20.04
strategy:
matrix:
php-versions: ['8.0']
server-versions: ['master']
services:
oracle:
image: deepdiver/docker-oracle-xe-11g # 'wnameless/oracle-xe-11g-r2'
ports:
- 1521:1521/tcp
steps:
- name: Set app env
run: |
# Split and keep last
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
- name: Checkout server
uses: actions/checkout@v3
with:
submodules: true
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
- name: Checkout app
uses: actions/checkout@v3
with:
path: apps/${{ env.APP_NAME }}
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, oci8
tools: phpunit
coverage: none
- name: Set up PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: composer i
- name: Set up Nextcloud
env:
DB_PORT: 1521
run: |
mkdir data
./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin
./occ app:enable ${{ env.APP_NAME }}
- name: Check PHPUnit config file existence
id: check_phpunit
uses: andstor/file-existence-action@v1
with:
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }}
- name: PHPUnit
# Only run if phpunit config file exists
if: steps.check_phpunit.outputs.files_exists == 'true'
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
- name: Check PHPUnit integration config file existence
id: check_integration
uses: andstor/file-existence-action@v1
with:
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }}
- name: Run Nextcloud
# Only run if phpunit integration config file exists
if: steps.check_integration.outputs.files_exists == 'true'
run: php -S localhost:8080 &
- name: PHPUnit integration
# Only run if phpunit integration config file exists
if: steps.check_integration.outputs.files_exists == 'true'
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
summary:
runs-on: ubuntu-latest
needs: phpunit-oci
if: always()
name: phpunit-oci-summary
steps:
- name: Summary status
run: if ${{ needs.phpunit-oci.result != 'success' }}; then exit 1; fi

114
.github/workflows/phpunit-pgsql.yml vendored Normal file
View file

@ -0,0 +1,114 @@
# SPDX-FileCopyrightText: Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: PHPUnit
on:
pull_request:
push:
branches:
- master
- stable*
env:
# Location of the phpunit.xml and phpunit.integration.xml files
PHPUNIT_CONFIG: ./tests/phpunit.xml
PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml
jobs:
phpunit-pgsql:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0']
server-versions: ['master']
services:
postgres:
image: postgres
ports:
- 4444:5432/tcp
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: rootpassword
POSTGRES_DB: nextcloud
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
steps:
- name: Set app env
run: |
# Split and keep last
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
- name: Checkout server
uses: actions/checkout@v3
with:
submodules: true
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
- name: Checkout app
uses: actions/checkout@v3
with:
path: apps/${{ env.APP_NAME }}
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, pgsql, pdo_pgsql
coverage: none
- name: Set up PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: composer i
- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
./occ app:enable ${{ env.APP_NAME }}
- name: Check PHPUnit config file existence
id: check_phpunit
uses: andstor/file-existence-action@v1
with:
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }}
- name: PHPUnit
# Only run if phpunit config file exists
if: steps.check_phpunit.outputs.files_exists == 'true'
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
- name: Check PHPUnit integration config file existence
id: check_integration
uses: andstor/file-existence-action@v1
with:
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }}
- name: Run Nextcloud
# Only run if phpunit integration config file exists
if: steps.check_integration.outputs.files_exists == 'true'
run: php -S localhost:8080 &
- name: PHPUnit integration
# Only run if phpunit integration config file exists
if: steps.check_integration.outputs.files_exists == 'true'
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
summary:
runs-on: ubuntu-latest
needs: phpunit-pgsql
if: always()
name: phpunit-pgsql-summary
steps:
- name: Summary status
run: if ${{ needs.phpunit-pgsql.result != 'success' }}; then exit 1; fi

103
.github/workflows/phpunit-sqlite.yml vendored Normal file
View file

@ -0,0 +1,103 @@
# SPDX-FileCopyrightText: Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: PHPUnit
on:
pull_request:
push:
branches:
- master
- stable*
env:
# Location of the phpunit.xml and phpunit.integration.xml files
PHPUNIT_CONFIG: ./tests/phpunit.xml
PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml
jobs:
phpunit-sqlite:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0']
server-versions: ['master']
steps:
- name: Set app env
run: |
# Split and keep last
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
- name: Checkout server
uses: actions/checkout@v3
with:
submodules: true
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
- name: Checkout app
uses: actions/checkout@v3
with:
path: apps/${{ env.APP_NAME }}
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite
coverage: none
- name: Set up PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: composer i
- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
./occ app:enable ${{ env.APP_NAME }}
- name: Check PHPUnit config file existence
id: check_phpunit
uses: andstor/file-existence-action@v1
with:
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }}
- name: PHPUnit
# Only run if phpunit config file exists
if: steps.check_phpunit.outputs.files_exists == 'true'
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
- name: Check PHPUnit integration config file existence
id: check_integration
uses: andstor/file-existence-action@v1
with:
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }}
- name: Run Nextcloud
# Only run if phpunit integration config file exists
if: steps.check_integration.outputs.files_exists == 'true'
run: php -S localhost:8080 &
- name: PHPUnit integration
# Only run if phpunit integration config file exists
if: steps.check_integration.outputs.files_exists == 'true'
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
summary:
runs-on: ubuntu-latest
needs: phpunit-sqlite
if: always()
name: phpunit-sqlite-summary
steps:
- name: Summary status
run: if ${{ needs.phpunit-sqlite.result != 'success' }}; then exit 1; fi

View file

@ -1,215 +0,0 @@
name: PHPUnit
on:
pull_request:
push:
branches:
- master
- stable*
env:
APP_NAME: upschooling
jobs:
php:
runs-on: ubuntu-latest
strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
php-versions: ['7.4']
databases: ['sqlite']
server-versions: ['master']
name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}
steps:
- name: Checkout server
uses: actions/checkout@v2
with:
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Checkout app
uses: actions/checkout@v2
with:
path: apps/${{ env.APP_NAME }}
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite
coverage: none
- name: Set up PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: composer i
- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
./occ app:enable --force ${{ env.APP_NAME }}
php -S localhost:8080 &
- name: PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c phpunit.xml
- name: PHPUnit integration
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml
mysql:
runs-on: ubuntu-latest
strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
php-versions: ['7.3', '7.4']
databases: ['mysql']
server-versions: ['master']
name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}
services:
mysql:
image: mariadb:10.5
ports:
- 4444:3306/tcp
env:
MYSQL_ROOT_PASSWORD: rootpassword
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
steps:
- name: Checkout server
uses: actions/checkout@v2
with:
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Checkout app
uses: actions/checkout@v2
with:
path: apps/${{ env.APP_NAME }}
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql
coverage: none
- name: Set up PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: composer i
- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
./occ app:enable --force ${{ env.APP_NAME }}
php -S localhost:8080 &
- name: PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c phpunit.xml
- name: PHPUnit integration
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml
pgsql:
runs-on: ubuntu-latest
strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
php-versions: ['7.4']
databases: ['pgsql']
server-versions: ['master']
name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}
services:
postgres:
image: postgres
ports:
- 4444:5432/tcp
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: rootpassword
POSTGRES_DB: nextcloud
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
steps:
- name: Checkout server
uses: actions/checkout@v2
with:
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Checkout app
uses: actions/checkout@v2
with:
path: apps/${{ env.APP_NAME }}
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, pgsql, pdo_pgsql
coverage: none
- name: Set up PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: composer i
- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
./occ app:enable --force ${{ env.APP_NAME }}
php -S localhost:8080 &
- name: PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c phpunit.xml
- name: PHPUnit integration
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml

15
.github/workflows/reuse.yml vendored Normal file
View file

@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V. <https://fsfe.org>
#
# SPDX-License-Identifier: CC0-1.0
name: REUSE Compliance Check
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1

214
.gitignore vendored
View file

@ -1,207 +1,11 @@
# Created by https://www.toptal.com/developers/gitignore/api/phpstorm+all,phpunit,composer,node,vue
# Edit at https://www.toptal.com/developers/gitignore?templates=phpstorm+all,phpunit,composer,node,vue
### Composer ###
composer.phar
/vendor/
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
### Node ###
# Logs
logs
*.log
npm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# webpack output
js/
### PhpStorm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### PhpStorm+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
.idea/
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
# SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
.idea
*.iml
modules.xml
.idea/misc.xml
*.ipr
# Sonarlint plugin
.idea/sonarlint
### PHPUnit ###
# Covers PHPUnit
# Reference: https://phpunit.de/
# Generated files
.phpunit.result.cache
.phpunit.cache
# PHPUnit
/app/phpunit.xml
/phpunit.xml
# Build data
/vendor/
/build/
### Vue ###
# gitignore template for Vue.js projects
#
# Recommended template: Node.gitignore
# TODO: where does this rule come from?
docs/_book
# TODO: where does this rule come from?
test/
# End of https://www.toptal.com/developers/gitignore/api/phpstorm+all,phpunit,composer,node,vue
node_modules/
/.php_cs.cache
js/*hot-update.*
/tests/.phpunit.result.cache
/js/

View file

@ -1,6 +1,8 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
require_once './vendor/autoload.php';
@ -9,6 +11,7 @@ use Nextcloud\CodingStandard\Config;
$config = new Config();
$config
->getFinder()
->ignoreVCSIgnored(true)
->notPath('build')
->notPath('l10n')
->notPath('src')

12
.reuse/dep5 Normal file
View file

@ -0,0 +1,12 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: U Pschooling
Upstream-Contact: BVSC e.V. <no@example.com>
Source: https://github.com/nextcloud/profiler
Files: package-lock.json package.json composer.json composer.lock
Copyright: BVSC e.V. <no@example.com>
License: AGPL-3.0-or-later
Files: l10n/*.js l10n/*.json
Copyright: Nextcloud translators <https://www.transifex.com/nextcloud/>
License: AGPL-3.0-or-later

View file

@ -1,12 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [0.0.2] - 2017-07-31
### Added
- First release

661
COPYING
View file

@ -1,661 +0,0 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

View file

@ -0,0 +1,235 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the Program.
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.

121
LICENSES/CC0-1.0.txt Normal file
View file

@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

184
Makefile
View file

@ -1,17 +1,71 @@
# This file is licensed under the Affero General Public License version 3 or
# later. See the COPYING file.
# SPDX-FileCopyrightText: Bernhard Posselt <dev@bernhard-posselt.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
# Generic Makefile for building and packaging a Nextcloud app which uses npm and
# Composer.
#
# Dependencies:
# * make
# * which
# * curl: used if phpunit and composer are not installed to fetch them from the web
# * tar: for building the archive
# * npm: for building and testing everything JS
#
# If no composer.json is in the app root directory, the Composer step
# will be skipped. The same goes for the package.json which can be located in
# the app root or the js/ directory.
#
# The npm command by launches the npm build script:
#
# npm run build
#
# The npm test command launches the npm test script:
#
# npm run test
#
# The idea behind this is to be completely testing and build tool agnostic. All
# build tools and additional package managers should be installed locally in
# your project, since this won't pollute people's global namespace.
#
# The following npm scripts in your package.json install and update the bower
# and npm dependencies and use gulp as build system (notice how everything is
# run from the node_modules folder):
#
# "scripts": {
# "test": "node node_modules/gulp-cli/bin/gulp.js karma",
# "prebuild": "npm install && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update",
# "build": "node node_modules/gulp-cli/bin/gulp.js"
# },
app_name=$(notdir $(CURDIR))
build_tools_directory=$(CURDIR)/build/tools
source_build_directory=$(CURDIR)/build/artifacts/source
source_package_name=$(source_build_directory)/$(app_name)
appstore_build_directory=$(CURDIR)/build/artifacts
appstore_package_name=$(appstore_build_directory)/$(app_name)
npm=$(shell which npm 2> /dev/null)
composer=$(shell which composer 2> /dev/null)
all: dev-setup lint build-js-production test
# Dev env management
dev-setup: clean clean-dev composer npm-init
all: build
# Fetches the PHP and JS dependencies and compiles the JS. If no composer.json
# is present, the composer step is skipped, if no package.json or js/package.json
# is present, the npm step is skipped
.PHONY: build
build:
ifneq (,$(wildcard $(CURDIR)/composer.json))
make composer
endif
ifneq (,$(wildcard $(CURDIR)/package.json))
make npm
endif
ifneq (,$(wildcard $(CURDIR)/js/package.json))
make npm
endif
# Installs and updates the composer dependencies. If composer is not installed
# a copy is fetched from the web
.PHONY: composer
composer:
ifeq (, $(composer))
@echo "No composer command available, downloading a copy from the web"
@ -19,53 +73,91 @@ ifeq (, $(composer))
curl -sS https://getcomposer.org/installer | php
mv composer.phar $(build_tools_directory)
php $(build_tools_directory)/composer.phar install --prefer-dist
php $(build_tools_directory)/composer.phar update --prefer-dist
else
composer install --prefer-dist
composer update --prefer-dist
endif
npm-init:
npm ci
npm-update:
npm update
# Building
build-js:
npm run dev
build-js-production:
# Installs npm dependencies
.PHONY: npm
npm:
ifeq (,$(wildcard $(CURDIR)/package.json))
cd js && $(npm) run build
else
npm run build
endif
watch-js:
npm run watch
serve-js:
npm run serve
# Linting
lint:
npm run lint
lint-fix:
npm run lint:fix
# Style linting
stylelint:
npm run stylelint
stylelint-fix:
npm run stylelint:fix
# Cleaning
# Removes the appstore build
.PHONY: clean
clean:
rm -rf js/*
rm -rf ./build
clean-dev:
# Same as clean but also removes dependencies installed by composer, bower and
# npm
.PHONY: distclean
distclean: clean
rm -rf vendor
rm -rf node_modules
rm -rf js/vendor
rm -rf js/node_modules
# Tests
test:
./vendor/phpunit/phpunit/phpunit -c phpunit.xml
./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml
# Builds the source and appstore package
.PHONY: dist
dist:
make source
make appstore
# Builds the source package
.PHONY: source
source:
rm -rf $(source_build_directory)
mkdir -p $(source_build_directory)
tar cvzf $(source_package_name).tar.gz \
--exclude-vcs \
--exclude="../$(app_name)/build" \
--exclude="../$(app_name)/js/node_modules" \
--exclude="../$(app_name)/node_modules" \
--exclude="../$(app_name)/*.log" \
--exclude="../$(app_name)/js/*.log" \
../$(app_name) \
# Builds the source package for the app store, ignores php tests, js tests
# and build related folders that are unnecessary for an appstore release
.PHONY: appstore
appstore:
rm -rf $(appstore_build_directory)
mkdir -p $(appstore_build_directory)
tar cvzf $(appstore_package_name).tar.gz \
--exclude-vcs \
--exclude="../$(app_name)/build" \
--exclude="../$(app_name)/tests" \
--exclude="../$(app_name)/Makefile" \
--exclude="../$(app_name)/*.log" \
--exclude="../$(app_name)/phpunit*xml" \
--exclude="../$(app_name)/composer.*" \
--exclude="../$(app_name)/node_modules" \
--exclude="../$(app_name)/js/node_modules" \
--exclude="../$(app_name)/js/tests" \
--exclude="../$(app_name)/js/test" \
--exclude="../$(app_name)/js/*.log" \
--exclude="../$(app_name)/js/package.json" \
--exclude="../$(app_name)/js/bower.json" \
--exclude="../$(app_name)/js/karma.*" \
--exclude="../$(app_name)/js/protractor.*" \
--exclude="../$(app_name)/package.json" \
--exclude="../$(app_name)/bower.json" \
--exclude="../$(app_name)/karma.*" \
--exclude="../$(app_name)/protractor\.*" \
--exclude="../$(app_name)/.*" \
--exclude="../$(app_name)/js/.*" \
--exclude="../$(app_name)/webpack.config.js" \
--exclude="../$(app_name)/stylelint.config.js" \
--exclude="../$(app_name)/CHANGELOG.md" \
--exclude="../$(app_name)/README.md" \
--exclude="../$(app_name)/package-lock.json" \
--exclude="../$(app_name)/LICENSES" \
../$(app_name) \
.PHONY: test
test: composer
$(CURDIR)/vendor/phpunit/phpunit/phpunit -c tests/phpunit.xml
$(CURDIR)/vendor/phpunit/phpunit/phpunit -c tests/phpunit.integration.xml

View file

@ -1,12 +1,61 @@
# UPschooling
<!--
SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
SPDX-License-Identifier: CC0-1.0
-->
# UPschooling
Place this app in **nextcloud/apps/**
[![PHPUnit GitHub Action](https://github.com/nextcloud/app-tutorial/workflows/PHPUnit/badge.svg)](https://github.com/nextcloud/app-tutorial/actions?query=workflow%3APHPUnit)
[![Node GitHub Action](https://github.com/nextcloud/app-tutorial/workflows/Node/badge.svg)](https://github.com/nextcloud/app-tutorial/actions?query=workflow%3ANode)
[![Lint GitHub Action](https://github.com/nextcloud/app-tutorial/workflows/Lint/badge.svg)](https://github.com/nextcloud/app-tutorial/actions?query=workflow%3ALint)
## Building the app
The app can be built by using the provided Makefile by running:
make
This requires the following things to be present:
* make
* which
* tar: for building the archive
* curl: used if phpunit and composer are not installed to fetch them from the web
* npm: for building and testing everything JS, only required if a package.json is placed inside the **js/** folder
The make command will install or update Composer dependencies if a composer.json is present and also **npm run build** if a package.json is present in the **js/** folder. The npm **build** script should use local paths for build systems and package managers, so people that simply want to build the app won't need to install npm libraries globally, e.g.:
**package.json**:
```json
"scripts": {
"test": "node node_modules/gulp-cli/bin/gulp.js karma",
"prebuild": "npm install && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update",
"build": "node node_modules/gulp-cli/bin/gulp.js"
}
```
## Publish to App Store
First get an account for the [App Store](http://apps.nextcloud.com/) then run:
make && make appstore
The archive is located in build/artifacts/appstore and can then be uploaded to the App Store.
## Running tests
You can use the provided Makefile to run all tests by using:
make test
This will run the PHP unit and integration tests and if a package.json is present in the **js/** folder will execute **npm run test**
Of course you can also install [PHPUnit](http://phpunit.de/getting-started.html) and use the configurations directly:
phpunit -c phpunit.xml
or:
phpunit -c phpunit.integration.xml
for integration tests
This is the [tutorial app](https://docs.nextcloud.com/server/latest/developer_manual/app_development/tutorial.html) which shows how to develop a very simple notes app.
## Development
@ -19,20 +68,13 @@ Other than that composer and npm/nodejs must be installed.
brew install coreutils
```
### All
```shell
npm install
make
```
### Start dev environment
Starting the development environment with your container runtime should be as easy as
```shell
./run.sh
make watch-js
docker/podman exec -it --user 33 nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && make watch-js'
```

View file

@ -1,21 +1,24 @@
<?xml version="1.0"?>
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<!--
SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
SPDX-License-Identifier: CC0-1.0
-->
<id>upschooling</id>
<name>UPschooling</name>
<summary>UPschooling Support Platform</summary>
<description><![CDATA[Ticketsystem für UPschooling]]></description>
<version>0.0.1</version>
<licence>agpl</licence>
<author mail="upschooling@rs485.network" >UPschooling</author>
<author mail="no@example.com" homepage="https://gitea.rs485.network/UPschooling/Nextcloud-App">BVSC e.V.</author>
<namespace>UPschooling</namespace>
<category>organization</category>
<category>social</category>
<category>tools</category>
<bugs>https://gitea.rs485.network/UPschooling/Nextcloud-App/issues</bugs>
<background-jobs>
<job>OCA\UPschooling\BackgroundJob\MatrixListener</job>
</background-jobs>
<dependencies>
<nextcloud min-version="20" max-version="22"/>
<nextcloud min-version="27" max-version="27"/>
</dependencies>
<navigations>
<navigation>

View file

@ -1,16 +1,33 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
/**
* Create your routes in here. The name is the lowercase name of the controller
* without the controller part, the stuff after the hash is the method.
* e.g. page#index -> OCA\UPschooling\Controller\PageController->index()
*
* The controller class has to be registered in the application.php file since
* it's instantiated in there
*/
return [
'resources' => [
// 'ticket' => ['url' => '/tickets'],
'ticket_api' => ['url' => '/api/v1/tickets']
],
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
[
'name' => 'ticket_api#preflighted_cors',
'url' => '/api/v1/tickets',
'url' => '/api/v1/{path}',
'verb' => 'OPTIONS',
'requirements' => ['path' => '.+'],
],
[
'name' => 'ticket_api#fetch_chat',
'url' => '/api/v1/tickets/{id}/chat',
'verb' => 'GET',
],
],
];

View file

@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
const babelConfig = require('@nextcloud/babel-config')
module.exports = babelConfig

View file

@ -1,6 +1,6 @@
{
"name": "upschooling/upschooling",
"description": "UPschooling Support Platform",
"name": "nextcloud/upschooling",
"description": "Nextcloud app for UPschooling Support Platform",
"type": "project",
"license": "AGPL-3.0-or-later",
"authors": [
@ -15,23 +15,35 @@
}
],
"require": {
"php": ">=7.4",
"aryess/php-matrix-sdk": "dev-feature/guzzle7-update",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"nextcloud/coding-standard": "^0.5.0"
},
"config": {
"optimize-autoloader": true,
"classmap-authoritative": true,
"platform": {
"php": "7.2.5"
}
"phpunit/phpunit": "^9",
"sabre/dav": "^4.1",
"sabre/xml": "^2.2",
"symfony/event-dispatcher": "^5.3.11",
"nextcloud/ocp": "dev-stable27",
"psalm/phar": "^4.10",
"nextcloud/coding-standard": "^1.0"
},
"scripts": {
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l",
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix"
"cs:fix": "php-cs-fixer fix",
"psalm": "psalm.phar --threads=1",
"psalm:update-baseline": "psalm.phar --threads=1 --update-baseline",
"psalm:update-baseline:force": "psalm.phar --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml",
"psalm:clear": "psalm.phar --clear-cache && psalm --clear-global-cache",
"psalm:fix": "psalm.phar --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true
},
"platform": {
"php": "7.4"
}
}
}

3552
composer.lock generated

File diff suppressed because it is too large Load diff

Binary file not shown.

19
doc/doc.tex Normal file
View file

@ -0,0 +1,19 @@
\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\title{UPschooling Ticket System Technische Dokumentation}
\author{Benedikt Ziemons}
\begin{document}
\maketitle
\tableofcontents
\begin{abstract}
\end{abstract}
\section{}
\end{document}

65
doc/index.md Normal file
View file

@ -0,0 +1,65 @@
---
title: UPschooling Ticket System
subtitle: Technische Dokumentation
author:
- Benedikt Ziemons
---
# Einleitung
Das UPschooling Ticket System ist ein Hilfstool für die Umsetzung
des UPschooling Projekts an Schulen.
Das System soll, vereinfacht, eine Möglichkeit für Schüler\*innen bieten,
technische Fragen zu Hardware zu stellen und von kompetenten
Helfenden Antworten zu bekommen.
Zuerst werden in diesem Dokument die in der Planung festgehaltenen wichtigen
Zielsetzungen beschrieben, welche die Auswahl der verwendeten Software und
die notwendige Programmierung maßgeblich bestimmten. Anschließend wird die
bisherige Umsetzung (Stand August 2023) dieser und weitere geplante
Umsetzungen erläutert.
# Zielstellungen
1. __Keine persönlichen Daten der Schüler\*innen werden auf externe Server übertragen__
Die einzigen zu speichernden und zu übertragenden Daten werden durch
die Kommunikation mit der Helfer\*in bestimmt. Für einen zusätzlichen Schutz
empfiehlt sich das Gespräch zusammen mit einer Aufsichtsperson oder einer
erziehungsberechtigten Person.
2. __Helfende benötigen keinen Zugriff auf das System in der Schule__
Die Kommunikation mit Helfenden aus der Zivilgesellschaft soll über eine
bestimmte und sichere Schnittstelle erfolgen. Diese Bestimmtheit lässt sich
besser Überwachen und durch eine einzige Freigabe in Firewalls einrichten.
3. __Kommunikation erfolgt verschlüsselt und über erprobte Software__
Die Kommunikation erfolgt über eine extern entwickelte Software,
welche gängige Sicherheitsstandards erfüllt und für die es
kommerziellen Support gibt.
# Umsetzung
Die genannten [Zielstellungen] grenzen die Auswahl der Software für
die Umsetzung des geplanten Ticketsystems ein. Weitere Auswahlkriterien
umfassen die Modularität des entstehenden Systems sowie existierende
Erfahrungen mit bestimmten Systemen seitens der Entwickelnden.
Die Anfangsplanung sieht die Nutzung von [Nextcloud](https://nextcloud.com/de/)
als Platform und Oberfläche für die Anwendung vor. Nextcloud ist
eine modulbasierte Lösung für sogenannte "Cloud-Services".
Die Basisversion enthält bereits Funktionen wie eine Dateiablage,
Kalender und Kontaktverzeichnisse (siehe ähnliche Services großer Anbieter wie Google und Co.)
und deren Anbindung über generische Protokolle wie WebDAV oder CalDAV (welche auch von Thunderbird, Apple iPhones als Kalender-/Kontaktsynchronisation unterstützt werden).
Nextcloud wird außerdem bereits in manchen Schulen eingesetzt und dient dort
bspw. als Platform für eLearning. Die existierende Erfahrung von Schulen
mit Nextcloud als Platform und Systemadministrator\*innen der Schulen
mit dem System bestärkt die Entscheidung für Nextcloud. Der Datenschutz wird bei der
schuleigenen Nextcloud durch die Schule sichergestellt.
Weitere Auswahl von Software für die Umsetzung ergibt sich durch
die Anforderungspunkte 2 und 3 der [Zielstellungen].
Anforderung 2 schützt die Nextcloud (und Authentifikationssysteme)
der Schule und ließe zu diese Systeme mit Daten der Schüler\*innen
nur aus internen Netzen der Schule erreichbar zu machen.
Bedingt dadurch ist allerdings eine technische Kommunikationsschnittstelle
notwendig, welche den weiteren technischen Anforderungen genügt und
eine sichere Kommunikation zwischen Helfenden und Schüler\*innen zulässt.

BIN
doc/index.pdf Normal file

Binary file not shown.

40
extra/element-config.json Normal file
View file

@ -0,0 +1,40 @@
{
"default_server_config": {
"m.homeserver": {
"base_url": "http://localhost:8008",
"server_name": "synapse"
},
"m.identity_server": {
}
},
"disable_custom_urls": false,
"disable_guests": true,
"disable_login_language_selector": false,
"disable_3pid_login": false,
"brand": "Element",
"integrations_ui_url": "",
"integrations_rest_url": "",
"integrations_widgets_urls": [],
"bug_report_endpoint_url": "https://element.io/bugreports/submit",
"uisi_autorageshake_app": "element-auto-uisi",
"defaultCountryCode": "DE",
"showLabsSettings": false,
"features": {},
"default_federate": true,
"default_theme": "light",
"roomDirectory": {
"servers": [
]
},
"piwik": {
},
"enable_presence_by_hs_url": {
},
"settingDefaults": {
"breadcrumbs": true
},
"jitsi": {
"preferredDomain": "meet.element.io"
},
"map_style_url": "https://api.maptiler.com/maps/streets/style.json?key=fU3vlMsMn4Jb6dnEIFsx"
}

View file

@ -0,0 +1,68 @@
server {
listen 8080;
listen [::]:8080;
server_name localhost;
root /var/empty;
index index.html;
log_not_found on;
access_log /dev/stderr combined;
error_log /dev/stderr info;
location /upschooling/element-web {
rewrite ^/upschooling/element-web/(.*)$ /$1 break;
proxy_set_header Host localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass "http://127.0.0.1:8082";
}
location /.well-known/matrix {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET;
default_type application/json;
# TODO: Add missing matrix well-known files
proxy_set_header Host localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_redirect http://localhost:8008/.well-known/matrix http://localhost:8080/.well-known/matrix;
proxy_pass "http://127.0.0.1:8008$request_uri";
}
location / {
proxy_set_header Host localhost:8080;
proxy_pass "http://127.0.0.1:80$request_uri";
}
}
server {
listen 8082;
listen [::]:8082;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
set_real_ip_from 127.0.0.1;
set_real_ip_from ::1;
# Set no-cache for the version, config and index.html
# so that browsers always check for a new copy of Element Web.
# NB http://your-domain/ and http://your-domain/? are also covered by this
location = /index.html {
add_header Cache-Control "no-cache";
}
location = /version {
add_header Cache-Control "no-cache";
}
# covers config.json and config.hostname.json requests as it is prefix.
location /config {
add_header Cache-Control "no-cache";
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
}

2
img/app.svg.license Normal file
View file

@ -0,0 +1,2 @@
SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
SPDX-License-Identifier: AGPL-3.0-or-later

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\AppInfo;
@ -10,7 +13,8 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext;
class Application extends App implements IBootstrap {
public const APP_ID = 'upschooling';
public function __construct() {
public function __construct()
{
parent::__construct(self::APP_ID);
}

View file

@ -1,28 +0,0 @@
<?php
namespace OCA\UPschooling\BackgroundJob;
use OCA\UPschooling\Service\MatrixListenerService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use Psr\Log\LoggerInterface;
class MatrixListener extends TimedJob {
/** @var MatrixListenerService */
private $matrixListenerService;
/** @var LoggerInterface */
private $logger;
public function __construct(ITimeFactory $time, MatrixListenerService $matrixListenerService, LoggerInterface $logger) {
parent::__construct($time);
parent::setInterval(1);
$this->logger = $logger;
$this->matrixListenerService = $matrixListenerService;
}
protected function run($argument) {
$this->matrixListenerService->listen();
}
}

View file

@ -1,8 +1,12 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\Controller;
use Closure;
use OCA\UPschooling\Exceptions\RoomNotFoundException;
use OCA\UPschooling\Exceptions\TicketNotFoundException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@ -11,9 +15,9 @@ trait Errors {
protected function handleNotFound(Closure $callback): DataResponse {
try {
return new DataResponse($callback());
} catch (TicketNotFoundException $e) {
$message = ['message' => $e->getMessage()];
return new DataResponse($message, Http::STATUS_NOT_FOUND);
} catch (TicketNotFoundException|RoomNotFoundException $e) {
$result = $e->getResult();
return new DataResponse($result->getMeta(), $result->getStatusCode());
}
}
}

View file

@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\Controller;
use OCA\UPschooling\AppInfo\Application;
use OCA\UPschooling\Service\NoteService;
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
class NoteApiController extends ApiController {
private NoteService $service;
private ?string $userId;
use Errors;
public function __construct(IRequest $request,
NoteService $service,
?string $userId) {
parent::__construct(Application::APP_ID, $request);
$this->service = $service;
$this->userId = $userId;
}
/**
* @CORS
* @NoCSRFRequired
* @NoAdminRequired
*/
public function index(): DataResponse {
return new DataResponse($this->service->findAll($this->userId));
}
/**
* @CORS
* @NoCSRFRequired
* @NoAdminRequired
*/
public function show(int $id): DataResponse {
return $this->handleNotFound(function () use ($id) {
return $this->service->find($id, $this->userId);
});
}
/**
* @CORS
* @NoCSRFRequired
* @NoAdminRequired
*/
public function create(string $title, string $content): DataResponse {
return new DataResponse($this->service->create($title, $content,
$this->userId));
}
/**
* @CORS
* @NoCSRFRequired
* @NoAdminRequired
*/
public function update(int $id, string $title,
string $content): DataResponse {
return $this->handleNotFound(function () use ($id, $title, $content) {
return $this->service->update($id, $title, $content, $this->userId);
});
}
/**
* @CORS
* @NoCSRFRequired
* @NoAdminRequired
*/
public function destroy(int $id): DataResponse {
return $this->handleNotFound(function () use ($id) {
return $this->service->delete($id, $this->userId);
});
}
}

View file

@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\Controller;
use OCA\UPschooling\AppInfo\Application;
use OCA\UPschooling\Service\NoteService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
class NoteController extends Controller {
private NoteService $service;
private ?string $userId;
use Errors;
public function __construct(IRequest $request,
NoteService $service,
?string $userId) {
parent::__construct(Application::APP_ID, $request);
$this->service = $service;
$this->userId = $userId;
}
/**
* @NoAdminRequired
*/
public function index(): DataResponse {
return new DataResponse($this->service->findAll($this->userId));
}
/**
* @NoAdminRequired
*/
public function show(int $id): DataResponse {
return $this->handleNotFound(function () use ($id) {
return $this->service->find($id, $this->userId);
});
}
/**
* @NoAdminRequired
*/
public function create(string $title, string $content): DataResponse {
return new DataResponse($this->service->create($title, $content,
$this->userId));
}
/**
* @NoAdminRequired
*/
public function update(int $id, string $title,
string $content): DataResponse {
return $this->handleNotFound(function () use ($id, $title, $content) {
return $this->service->update($id, $title, $content, $this->userId);
});
}
/**
* @NoAdminRequired
*/
public function destroy(int $id): DataResponse {
return $this->handleNotFound(function () use ($id) {
return $this->service->delete($id, $this->userId);
});
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\Controller;
@ -19,7 +22,7 @@ class PageController extends Controller {
*
* Render default template
*/
public function index() {
public function index(): TemplateResponse {
Util::addScript(Application::APP_ID, 'upschooling-main');
return new TemplateResponse(Application::APP_ID, 'main');

View file

@ -3,66 +3,124 @@
namespace OCA\UPschooling\Controller;
use OCA\UPschooling\AppInfo\Application;
use OCA\UPschooling\Db\TicketMapper;
use OCA\UPschooling\Exceptions\RoomNotFoundException;
use OCA\UPschooling\Service\ChatService;
use OCA\UPschooling\Service\MatrixService;
use OCA\UPschooling\Service\TicketService;
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
use Psr\Log\LoggerInterface;
class TicketApiController extends ApiController
{
/** @var TicketService */
private $service;
/** @var string */
private $userId;
/** @var LoggerInterface */
private $logger;
/** @var TicketService */
private $ticketService;
/** @var MatrixService */
private $matrixService;
/** @var ChatService */
private $chatService;
/** @var TicketMapper */
private $ticketMapper;
private ?string $userId;
use Errors;
public function __construct(IRequest $request, TicketService $service, $userId)
{
public function __construct(
IRequest $request,
LoggerInterface $logger,
TicketService $ticketService,
TicketMapper $ticketMapper,
MatrixService $matrixService,
ChatService $chatService,
?string $userId
) {
parent::__construct(Application::APP_ID, $request);
$this->service = $service;
$this->logger = $logger;
$this->ticketService = $ticketService;
$this->ticketMapper = $ticketMapper;
$this->matrixService = $matrixService;
$this->chatService = $chatService;
$this->userId = $userId;
}
/**
* @CORS
* @NoCSRFRequired
* @NoAdminRequired
*/
public function index(): DataResponse
{
return new DataResponse($this->service->findAll($this->userId));
return new DataResponse($this->ticketService->findAll($this->userId));
}
/**
* @CORS
* @NoCSRFRequired
* @NoAdminRequired
*/
public function show(int $id): DataResponse
{
return $this->handleNotFound(function () use ($id) {
return $this->service->find($id, $this->userId);
return $this->ticketService->find($id, $this->userId);
});
}
/**
* @CORS
* @NoCSRFRequired
* @NoAdminRequired
*/
public function fetchChat(int $id): DataResponse
{
return $this->handleNotFound(function () use ($id) {
$matrixUser = $this->ticketService->getOrCreateUser($this->userId);
$ticket = $this->ticketMapper->findForUser($id, $matrixUser);
$this->logger->debug("fetchChat found matrix data for ticket " . print_r($ticket->jsonSerialize(), true));
// returns 404 RoomNotFoundException if no room could/should be created
$chatRoom = $this->chatService->getOrCreateChatRoom($ticket);
$this->logger->debug("fetchChat got chat room " . print_r($chatRoom->jsonSerialize(), true));
return array(
'matrixChatRoom' => $chatRoom->getMatrixRoomId(),
'matrixAccessToken' => $matrixUser->getMatrixToken(),
'matrixServerUrl' => $this->matrixService->getServerUrl(),
);
});
}
/**
* @CORS
* @NoCSRFRequired
* @NoAdminRequired
*/
public function create(string $title, string $content): DataResponse
{
return new DataResponse($this->service->create($title, $content, $this->userId));
return new DataResponse($this->ticketService->create($title, $content, $this->userId));
}
/**
* @CORS
* @NoCSRFRequired
* @NoAdminRequired
*/
public function update(int $id): DataResponse
{
return new DataResponse($this->service->assign($id, $this->userId));
return new DataResponse($this->ticketService->assign($id, $this->userId));
}
public function destroy(int $id): DataResponse
{
return $this->handleNotFound(function () use ($id) {
return $this->service->delete($id, $this->userId);
return $this->ticketService->delete($id, $this->userId);
});
}
}

63
lib/Db/ChatMapper.php Normal file
View file

@ -0,0 +1,63 @@
<?php
namespace OCA\UPschooling\Db;
use Doctrine\DBAL\Types\Type;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\Entity;
use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
class ChatMapper extends QBMapper
{
public function __construct(IDBConnection $db)
{
parent::__construct($db, 'upschooling_chats', MatrixChat::class);
}
/**
* @param int $ticketId
* @return array array of Entity|MatrixChat
*/
public function findForTicket(int $ticketId): array
{
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('upschooling_chats')
->where($qb->expr()->eq('ticket_id', $qb->createNamedParameter($ticketId, IQueryBuilder::PARAM_INT)));
return $this->findEntities($qb);
}
/**
* @param int $ticketId
* @return Entity|MatrixChat
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws DoesNotExistException
*/
public function findCurrent(int $ticketId): MatrixChat
{
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('upschooling_chats')
->where(
$qb->expr()->eq('ticket_id', $qb->createNamedParameter($ticketId, IQueryBuilder::PARAM_INT)),
$qb->expr()->isNull('date_end')
);
return $this->findEntity($qb);
}
/**
* @param \DateTime $dateTime
* @return mixed The database representation of the datetime with timezone.
* @throws \Doctrine\DBAL\Exception
* @throws \Doctrine\DBAL\Types\ConversionException
*/
public function convertDateTimeTz(\DateTime $dateTime)
{
$dateTimeTzType = Type::getType("datetimetz");
return $dateTimeTzType->convertToDatabaseValue($dateTime, $this->db->getDatabasePlatform());
}
}

29
lib/Db/MatrixChat.php Normal file
View file

@ -0,0 +1,29 @@
<?php
namespace OCA\UPschooling\Db;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
class MatrixChat extends Entity implements JsonSerializable
{
protected $ticketId;
protected $matrixRoomId;
protected $matrixHelperUser;
protected $dateStart;
protected $dateEnd;
protected $version;
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'ticketId' => $this->ticketId,
'matrixRoomId' => $this->matrixRoomId,
'matrixHelperUser' => $this->matrixHelperUser,
'dateStart' => $this->dateStart,
'dateEnd' => $this->dateEnd,
'version' => $this->version,
];
}
}

View file

@ -1,23 +1,40 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\Db;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
/**
* @method getId(): int
* @method getMatrixControlRoom(): string
* @method setMatrixControlRoom(string $roomId): void
* @method getMatrixAssistedUser(): string
* @method setMatrixAssistedUser(string $userId): void
* @method getMatrixHelperUser(): ?string
* @method setMatrixHelperUser(?string $userId): void
* @method getStatus(): string
* @method setStatus(string $status): void
* @method getVersion(): int
* @method setVersion(int $version): void
*/
class MatrixTicket extends Entity implements JsonSerializable
{
protected $matrixRoom;
protected $matrixAssistedUser; // The ID of the person who created the Ticked. Usually the person who needs help.
protected $matrixHelperUser;
protected $status;
protected $version;
protected string $matrixControlRoom = '';
protected string $matrixAssistedUser = ''; // The ID of the person who created the ticket. Usually the person who needs help.
protected ?string $matrixHelperUser = null;
protected string $status = '';
protected int $version = 0;
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'matrixRoom' => $this->matrixRoom,
'matrixControlRoom' => $this->matrixControlRoom,
'matrixAssistedUser' => $this->matrixAssistedUser,
'matrixHelperUser' => $this->matrixHelperUser,
'status' => $this->status,

View file

@ -1,16 +1,29 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\Db;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
/**
* @method getId(): int
* @method getUserId(): string
* @method setUserId(string $userId): void
* @method getMatrixUser(): string
* @method setMatrixUser(string $matrixUser): void
* @method getMatrixToken(): string
* @method setMatrixToken(string $matrixToken): void
*/
class MatrixUser extends Entity implements JsonSerializable {
protected $userId;
protected $matrixUser;
protected $matrixToken;
protected string $userId = "";
protected string $matrixUser = "";
protected string $matrixToken = "";
public function jsonSerialize(): array {
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'userId' => $this->userId,

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\Db;
@ -8,6 +11,9 @@ use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
/**
* @template-extends QBMapper<MatrixTicket>
*/
class TicketMapper extends QBMapper
{
public function __construct(IDBConnection $db)
@ -16,8 +22,6 @@ class TicketMapper extends QBMapper
}
/**
* @param int $id
* @return Entity|MatrixTicket
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws DoesNotExistException
*/
@ -32,9 +36,6 @@ class TicketMapper extends QBMapper
}
/**
* @param int $id
* @param string $userId
* @return Entity|MatrixTicket
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws DoesNotExistException
*/

View file

@ -1,14 +0,0 @@
<?php
namespace OCA\UPschooling\Events;
use OCP\EventDispatcher\Event;
class NewMessageEvent extends Event {
public function __construct()
{
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\Exceptions;
@ -7,7 +10,7 @@ use OC\OCS\Result;
class TicketNotFoundException extends Exception
{
public function __construct($ticketId)
public function __construct(int $ticketId)
{
parent::__construct(new Result(null, 404, 'Ticket with id ' . $ticketId . ' not found'));
}

View file

@ -27,7 +27,7 @@ class Version000000Date20210918151800 extends SimpleMigrationStep {
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('matrix_room', 'string', [
$table->addColumn('matrix_control_room', 'string', [
'notnull' => true,
'length' => 200,
]);
@ -38,9 +38,9 @@ class Version000000Date20210918151800 extends SimpleMigrationStep {
$table->addColumn('matrix_helper_user', 'string', [
'notnull' => false,
'length' => 200,
]);
// could be optimized by having a "localUser" with foreign key to users.id,
// but that would create consistency issues
// but that could create consistency issues
]);
$table->addColumn('status', 'string', [
'notnull' => true,
@ -51,8 +51,8 @@ class Version000000Date20210918151800 extends SimpleMigrationStep {
]);
$table->setPrimaryKey(['id']);
$table->addUniqueConstraint(['matrix_room'], 'upschooling_mx_room_id_uniq');
$table->addIndex(['matrix_room'], 'upschooling_mx_room_id_idx');
$table->addUniqueConstraint(['matrix_control_room'], 'upschooling_mx_room_id_uniq');
$table->addIndex(['matrix_control_room'], 'upschooling_mx_room_id_idx');
}
if (!$schema->hasTable('upschooling_users')) {
@ -79,6 +79,37 @@ class Version000000Date20210918151800 extends SimpleMigrationStep {
$table->addUniqueConstraint(['matrix_user'], 'upschooling_mx_user_mx_uniq');
$table->addForeignKeyConstraint('users', ['user_id'], ['uid'], [], 'upschooling_mx_user_nc_fk');
}
if (!$schema->hasTable('upschooling_chats')) {
$table = $schema->createTable('upschooling_chats');
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('ticket_id', 'integer', [
'notnull' => true,
]);
$table->addColumn('matrix_room_id', 'string', [
'notnull' => true,
'length' => 200,
]);
$table->addColumn('matrix_helper_user', 'string', [
'notnull' => true,
'length' => 200,
]);
$table->addColumn('date_start', 'datetimetz', [
'notnull' => true,
]);
$table->addColumn('date_end', 'datetimetz', [
'notnull' => false,
]);
$table->addColumn('version', 'integer', [
'notnull' => true,
]);
$table->setPrimaryKey(['id']);
$table->addForeignKeyConstraint('upschooling_tickets', ['ticket_id'], ['id'], [], 'upschooling_tckt_id_fk');
}
return $schema;
}
}

View file

@ -0,0 +1,62 @@
<?php
namespace OCA\UPschooling\Service;
use Aryess\PhpMatrixSdk\Room;
use OCA\UPschooling\Db\ChatMapper;
use OCA\UPschooling\Db\MatrixChat;
use OCA\UPschooling\Db\MatrixTicket;
use OCA\UPschooling\Db\TicketMapper;
use OCA\UPschooling\Exceptions\RoomNotFoundException;
use OCP\AppFramework\Db\DoesNotExistException;
use Psr\Log\LoggerInterface;
class ChatService
{
/** @var ChatMapper */
private $chatMapper;
/** @var MatrixService */
private $matrixService;
/** @var LoggerInterface */
private $logger;
public function __construct(ChatMapper $chatMapper, MatrixService $matrixService, LoggerInterface $logger)
{
$this->chatMapper = $chatMapper;
$this->matrixService = $matrixService;
$this->logger = $logger;
}
/**
* @param $ticket MatrixTicket Support ticket
* @throws RoomNotFoundException
*/
public function getOrCreateChatRoom(MatrixTicket $ticket): MatrixChat
{
try {
return $this->chatMapper->findCurrent($ticket->getId());
} catch (DoesNotExistException $e) {
if ($ticket->getMatrixHelperUser() == null) {
$this->logger->debug("No helper assigned to ticket " . $ticket->getId() . ". Not creating chat room");
throw new RoomNotFoundException();
}
$this->logger->debug("Chat room for ticket " . $ticket->getId() . " does not exist. Creating room..");
$roomId = $this->matrixService->createRoom();
$startDate = new \DateTime('now', new \DateTimeZone("utc"));
$matrixChat = new MatrixChat();
$matrixChat->setTicketId($ticket->getId());
$matrixChat->setMatrixRoomId($roomId);
$matrixChat->setMatrixHelperUser($ticket->getMatrixHelperUser());
$matrixChat->setDateStart($this->chatMapper->convertDateTimeTz($startDate));
$matrixChat->setVersion(1);
$this->matrixService->inviteUser($roomId, $ticket->getMatrixHelperUser());
$this->matrixService->inviteUser($roomId, $ticket->getMatrixAssistedUser());
return $this->chatMapper->insert($matrixChat);
}
}
}

View file

@ -1,107 +0,0 @@
<?php
namespace OCA\UPschooling\Service;
use Aryess\PhpMatrixSdk\Exceptions\MatrixException;
use Aryess\PhpMatrixSdk\Exceptions\MatrixHttpLibException;
use Aryess\PhpMatrixSdk\Exceptions\MatrixRequestException;
use Aryess\PhpMatrixSdk\Exceptions\ValidationException;
use Aryess\PhpMatrixSdk\MatrixClient;
use OCA\UPschooling\Exceptions\RoomNotFoundException;
use Psr\Log\LoggerInterface;
/**
* This service will be used by the matrix listener background job to execute events and handle incoming 'matrix requests'
*/
class MatrixListenerService {
/** @var LoggerInterface */
private $logger;
/** @var MatrixClient */
private $client;
/** @var MatrixService */
private $matrixService;
/** @var token */
private $token;
/** @var string */
private $registrationSecret = "oyYh_iEJ7Aim.iB+ye.Xk;Gl3iHFab5*8K,zv~IulT85P=c-38";
/**
* @param LoggerInterface $logger
* @param MatrixService $matrixService
* @throws MatrixException
* @throws MatrixHttpLibException
* @throws MatrixRequestException
* @throws ValidationException
*/
public function __construct(LoggerInterface $logger, MatrixService $matrixService) {
$this->logger = $logger;
$this->matrixService = $matrixService;
$serverUrl = "http://synapse:8008";
$user = "upschooling";
$this->client = new MatrixClient($serverUrl);
//TODO: Replace hard coded pw
$this->token = $this->client->login($user, "secret", true);
$this->logger->debug("Logged in as " . $user . " on server " . $serverUrl);
}
/**
* listens on all sorts of incoming matrix requests
*
* @return void
* @throws MatrixException
* @throws MatrixHttpLibException
* @throws MatrixRequestException
* @throws RoomNotFoundException
*/
public function listen() {
$syncResponse = $this->client->api()->sync();
$nextBatch = $syncResponse['next_batch'];
foreach (array_get($syncResponse, 'rooms.invite', []) as $roomId => $inviteRoom) {
$this->handleInvite($roomId);
}
$rooms = $this->client->getRooms();
foreach ($rooms as $roomId => $room) {
$messages = $this->client->api()->getRoomMessages($roomId, $nextBatch, "b", 100)["chunk"];
foreach ($messages as $message) {
if ($message["type"] == "m.room.message" && $message["content"]["msgtype"] == "m.text")
var_dump($message["content"]["body"]);
}
}
}
/**
* TBD: Check if the user on the other side is actually allowed to talk to this matrix instance
* @return void
*/
private function auth() {
}
/**
* Given invitation object it'll enter the room
*
* @param int $roomId the roomID
* @return void
* @throws MatrixException|RoomNotFoundException
*/
private function handleInvite(int $roomId) {
try {
$this->client->joinRoom($roomId);
$this->client->api()->sendMessageEvent($roomId, "upschooling.matrix.accepted", []);
} catch (\Exception $e) {
$this->logger->info("Join for room: " . $roomId . " failed.");
}
$this->matrixService->setProperty($roomId, "upschooling.s2s", ["approved" => true]);
$this->logger->debug("joined " . $roomId);
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\Service;
@ -56,7 +59,7 @@ class MatrixService
);
$this->serverUrl = $this->config->getSystemValueString(
"upschooling.matrix_server_url",
"http://synapse:8008"
"http://localhost:8008"
);
$this->server = $this->config->getSystemValueString(
"upschooling.matrix_server",
@ -216,6 +219,14 @@ class MatrixService
return $roomId;
}
/**
* @return string the public matrix server url.
*/
public function getServerUrl(): string
{
return $this->serverUrl;
}
private function checkRateLimit()
{
$fullSuperuserId = "@" . $this->superuser . ":" . $this->server;
@ -247,4 +258,10 @@ class MatrixService
$this->logger->debug("No ratelimiting for " . $this->superuser);
}
}
public function inviteUser(string $roomId, string $matrixUserId)
{
$room = $this->client->joinRoom($roomId);
$room->inviteUser($matrixUserId);
}
}

View file

@ -15,6 +15,7 @@ use OCA\UPschooling\Exceptions\TicketNotFoundException;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
class TicketService {
@ -30,21 +31,30 @@ class TicketService {
/** @var UserMapper */
private $userMapper;
/** @var LoggerInterface */
private $logger;
public function __construct(
IUserManager $userManager,
MatrixService $matrix,
TicketMapper $ticketMapper,
UserMapper $userMapper
UserMapper $userMapper,
LoggerInterface $logger
) {
$this->userManager = $userManager;
$this->matrix = $matrix;
$this->ticketMapper = $ticketMapper;
$this->userMapper = $userMapper;
$this->logger = $logger;
}
public function findAll(string $userId): array {
$dbTickets = $this->ticketMapper->findAllForUser($this->getOrCreateUser($userId));
return array_map(function ($ticket) { return $this->resolveTicket($ticket); }, $dbTickets);
return array_filter(array_map(function ($ticket) {
return $this->resolveTicket($ticket);
}, $dbTickets), function ($resolvedTicket) {
return $resolvedTicket['status'] !== "error";
});
}
/**
@ -75,7 +85,7 @@ class TicketService {
"version" => "1",
));
$ticket = new MatrixTicket();
$ticket->setMatrixRoom($roomId);
$ticket->setMatrixControlRoom($roomId);
$ticket->setMatrixAssistedUser($matrixUser->getMatrixUser());
$ticket->setStatus("open");
$ticket->setVersion(1);
@ -83,9 +93,10 @@ class TicketService {
}
public function assign($id, $userId): array{
$this->logger->debug("Assigning $userId to ticket $id..");
$matrixUser = $this->getOrCreateUser($userId);
$ticket = $this->ticketMapper->findTicket($id);
$roomID = $ticket->getMatrixRoom();
$roomID = $ticket->getMatrixControlRoom();
$helperName = $this->userManager->get($userId)->getDisplayName();
$this->matrix->setProperty($roomID, "upschooling.ticket", array(
"matrixHelperUser" => $matrixUser->getMatrixUser(),
@ -104,18 +115,18 @@ class TicketService {
}
/**
* matrixTicketContent has all the syncronized data
* matrixTicketContent has all the synchronized data
* @param MatrixTicket $ticket the database object.
* @return array a JSON serializable representation of the resolved ticket, for the frontend.
*/
private function resolveTicket(MatrixTicket $ticket): array
{
try {
$matrixTicketContent = $this->matrix->getProperty($ticket->getMatrixRoom(), "upschooling.ticket");
$matrixTicketContent = $this->matrix->getProperty($ticket->getMatrixControlRoom(), "upschooling.ticket");
$ticketId = array_get($matrixTicketContent, "id", $ticket->getId());
$title = array_get($matrixTicketContent, "title", "Untitled");
$description = array_get($matrixTicketContent, "description", "");
$lastModified = $this->matrix->getLastEventDate($ticket->getMatrixRoom());
$lastModified = $this->matrix->getLastEventDate($ticket->getMatrixControlRoom());
$matrixHelperUser = array_get($matrixTicketContent, "matrixHelperUser", "nicht zugewiesen");
$matrixHelperName = array_get($matrixTicketContent, "matrixHelperName", $matrixHelperUser);
$expirationDate = array_get($matrixTicketContent, "expirationDate", "");
@ -144,7 +155,7 @@ class TicketService {
* @throws MultipleObjectsReturnedException
* @throws \OCP\DB\Exception
*/
private function getOrCreateUser(string $userId): MatrixUser
public function getOrCreateUser(string $userId): MatrixUser
{
try {
return $this->userMapper->find($userId);

27996
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,12 @@
{
"name": "upschooling",
"description": "A simple Nextcloud app tutorial for building a notes app",
"version": "19.0.0",
"author": "UPschooling",
"version": "27.0.0",
"author": "BVSC e.V. <no@example.com>",
"contributors": [
"Finn",
"Ben"
"Ben",
"Caluera"
],
"bugs": {
"url": "https://gitea.rs485.network/UPschooling/Nextcloud-App/issues"
@ -15,37 +16,37 @@
"type": "git"
},
"homepage": "https://gitea.rs485.network/UPschooling/Nextcloud-App",
"license": "AGPL-3.0-or-later",
"license": "agpl",
"private": true,
"scripts": {
"build": "NODE_ENV=production webpack --progress --config webpack.js",
"dev": "NODE_ENV=development webpack --progress --config webpack.js",
"watch": "NODE_ENV=development webpack --progress --watch --config webpack.js",
"serve": "NODE_ENV=development webpack serve --progress --config webpack.js",
"build": "NODE_ENV=production webpack --progress --config webpack.config.js",
"dev": "NODE_ENV=development webpack --progress --config webpack.config.js",
"watch": "NODE_ENV=development webpack --progress --watch --config webpack.config.js",
"serve": "NODE_ENV=development webpack serve --progress --config webpack.config.js",
"lint": "eslint --ext .js,.vue src",
"lint:fix": "eslint --ext .js,.vue src --fix",
"stylelint": "stylelint css/*.css css/*.scss src/**/*.scss src/**/*.vue",
"stylelint:fix": "stylelint css/*.css css/*.scss src/**/*.scss src/**/*.vue --fix"
},
"dependencies": {
"@nextcloud/axios": "^1.6.0",
"@nextcloud/dialogs": "^3.1.2",
"@nextcloud/router": "^1.2.0",
"@nextcloud/vue": "^3.10.1",
"vue": "^2.6.14"
"@nextcloud/axios": "^1.10.0",
"@nextcloud/dialogs": "^3.1.4",
"@nextcloud/router": "^2.0.0",
"@nextcloud/vue": "^5.4.0",
"vue": "^2.7.0"
},
"browserslist": [
"extends @nextcloud/browserslist-config"
],
"engines": {
"node": ">=14.0.0",
"npm": ">=7.0.0"
"node": "^16.0.0 || ^18.0.0",
"npm": "^7.0.0 || ^8.0.0 || ^9.0.0"
},
"devDependencies": {
"@nextcloud/babel-config": "^1.0.0",
"@nextcloud/browserslist-config": "^2.1.0",
"@nextcloud/eslint-config": "^6.1.0",
"@nextcloud/stylelint-config": "^1.0.0-beta.0",
"@nextcloud/webpack-vue-config": "^4.1.0"
"@nextcloud/browserslist-config": "^2.2.0",
"@nextcloud/eslint-config": "^8.0.0",
"@nextcloud/stylelint-config": "^2.1.2",
"@nextcloud/webpack-vue-config": "^5.2.1"
}
}

View file

@ -1,7 +0,0 @@
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="integration">
<directory>./tests/Integration</directory>
</testsuite>
</testsuites>
</phpunit>

View file

@ -1,7 +0,0 @@
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="unit">
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>
</phpunit>

38
psalm.xml Normal file
View file

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="tests/psalm-baseline.xml"
>
<!--
SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
SPDX-License-Identifier: CC0-1.0
-->
<projectFiles>
<directory name="lib" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<extraFiles>
<directory name="vendor" />
<ignoreFiles>
<directory name="vendor/phpunit/php-code-coverage" />
<directory name="vendor/psalm" />
</ignoreFiles>
</extraFiles>
<issueHandlers>
<UndefinedDocblockClass>
<errorLevel type="suppress">
<referencedClass name="OC\AppFramework\OCS\BaseResponse"/>
<referencedClass name="Doctrine\DBAL\Schema\Schema" />
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
<referencedClass name="Doctrine\DBAL\Driver\Statement" />
<referencedClass name="Doctrine\DBAL\Schema\Table" />
</errorLevel>
</UndefinedDocblockClass>
</issueHandlers>
</psalm>

83
run.sh
View file

@ -5,11 +5,11 @@ IFS=$'\n\t'
DIR="$(realpath ${0%/*})"
RUNTIME_IS_PODMAN="false"
if [[ -x "$(which podman)" ]]; then
CONTAINER_RUNTIME="$(which podman 2> /dev/null)"
if [[ -x "$(command -v podman)" ]]; then
CONTAINER_RUNTIME="$(command -v podman 2> /dev/null)"
RUNTIME_IS_PODMAN="true"
elif [[ -x "$(which docker)" ]]; then
CONTAINER_RUNTIME="$(which docker 2> /dev/null)"
elif [[ -x "$(command -v docker)" ]]; then
CONTAINER_RUNTIME="$(command -v docker 2> /dev/null)"
else
echo "Container runtime (docker/podman) not found!"
exit 1
@ -18,36 +18,58 @@ fi
# replace containers
if $CONTAINER_RUNTIME inspect --type container synapse 1> /dev/null; then
$CONTAINER_RUNTIME rm -f synapse
sleep 0.5
fi
if $CONTAINER_RUNTIME inspect --type container elementweb 1> /dev/null; then
$CONTAINER_RUNTIME rm -f elementweb
sleep 0.5
fi
if $CONTAINER_RUNTIME inspect --type container nextcloud 1> /dev/null; then
$CONTAINER_RUNTIME rm -f nextcloud
fi
if [[ ! -d vendor ]]; then
make composer
fi
$CONTAINER_RUNTIME run -d \
--name=nextcloud \
-p 8080:80 \
-p 8080:8080 \
-p 8081:80 \
-p 8082:8082 \
-p 8008:8008 \
-p 2280:22 \
-e PHP_MEMORY_LIMIT=512M \
-e APACHE_RUN_USER=www-data \
-e APACHE_RUN_GROUP=root \
-v "$DIR:/var/www/html/custom_apps/upschooling" \
--add-host "synapse:127.0.0.1" \
docker.io/nextcloud
docker.io/nextcloud:stable
$CONTAINER_RUNTIME exec nextcloud bash -c 'apt-get update && apt-get install -y git'
$CONTAINER_RUNTIME exec nextcloud chown -R 33 /var/www/html/custom_apps
export APACHE_RUN_USER=33 # uid of www-data, as selected above
export APACHE_RUN_GROUP=0 # gid of root, as selected above
echo -e "Nextcloud has started. \e[1;38;5;2mOK\033[0m"
$CONTAINER_RUNTIME exec nextcloud bash -c 'apt-get update && apt-get upgrade -y && apt-get install --no-install-recommends -y debianutils bash vim git openssh-server make curl tar npm'
# sets www-data password to extrasecret
$CONTAINER_RUNTIME exec nextcloud usermod \
--password '$6$bpNXAZwf$Xt.BzPV.mNTx5qVJQLK9Lut4VqMcrotgDHdcSZ0SwMxz2k9KVMSpAU7QmCv5vqj87ykIErYGpj9.Hb0A/XpX81' \
--shell '/bin/bash' \
www-data
$CONTAINER_RUNTIME exec nextcloud /etc/init.d/ssh start
$CONTAINER_RUNTIME exec nextcloud chown -R "$APACHE_RUN_USER" /var/www/html/custom_apps
if [[ $(id -u) -ne 0 && $RUNTIME_IS_PODMAN == "true" ]]; then
$CONTAINER_RUNTIME unshare -- chown -R 33 "$DIR"
$CONTAINER_RUNTIME unshare -- chgrp -R 0 "$DIR"
$CONTAINER_RUNTIME unshare -- chmod -R ug+rw "$DIR"
$CONTAINER_RUNTIME unshare -- chown -R "$APACHE_RUN_USER" "$DIR"
$CONTAINER_RUNTIME unshare -- chgrp -R "$APACHE_RUN_GROUP" "$DIR"
$CONTAINER_RUNTIME unshare -- chmod -R ug+rwX "$DIR"
fi
$CONTAINER_RUNTIME exec --user 33 nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && make composer'
$CONTAINER_RUNTIME exec --user 33 nextcloud php occ maintenance:install --database sqlite --admin-user admin --admin-pass admin
$CONTAINER_RUNTIME exec --user 33 nextcloud php occ config:system:set --value=true --type=boolean debug
$CONTAINER_RUNTIME exec --user 33 nextcloud php occ app:enable --force upschooling
$CONTAINER_RUNTIME exec --user "${APACHE_RUN_USER}:${APACHE_RUN_GROUP}" nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && npm install && make'
$CONTAINER_RUNTIME exec --user "${APACHE_RUN_USER}:${APACHE_RUN_GROUP}" nextcloud ./occ maintenance:install --verbose --database sqlite --admin-user admin --admin-pass admin
$CONTAINER_RUNTIME exec --user "${APACHE_RUN_USER}:${APACHE_RUN_GROUP}" nextcloud ./occ config:system:set --value=true --type=boolean debug
$CONTAINER_RUNTIME exec --user "${APACHE_RUN_USER}:${APACHE_RUN_GROUP}" nextcloud ./occ log:manage --level=debug
$CONTAINER_RUNTIME exec --user "${APACHE_RUN_USER}:${APACHE_RUN_GROUP}" nextcloud ./occ app:disable firstrunwizard
$CONTAINER_RUNTIME exec --user "${APACHE_RUN_USER}:${APACHE_RUN_GROUP}" nextcloud ./occ app:enable --force upschooling
echo -e "Nextcloud and app was configured. \e[1;38;5;2mOK\033[0m"
SYNAPSE_DATA_VOLUME_EXISTS="false"
if [[ $RUNTIME_IS_PODMAN == "true" ]]; then
@ -77,9 +99,9 @@ fi
LOCAL_SYNAPSE_DATA_PATH="$($CONTAINER_RUNTIME volume inspect --format "{{.Mountpoint}}" synapse-data)"
SED_ARGS=(-i 's|registration_shared_secret: .*|registration_shared_secret: "oyYh_iEJ7Aim.iB+ye.Xk;Gl3iHFab5*8K,zv~IulT85P=c-38"|' "$LOCAL_SYNAPSE_DATA_PATH/homeserver.yaml")
if [[ $(id -u) -eq 0 || $RUNTIME_IS_PODMAN != "true" ]]; then
sed ${SED_ARGS[@]}
sed "${SED_ARGS[@]}"
else
podman unshare -- sed ${SED_ARGS[@]}
podman unshare -- sed "${SED_ARGS[@]}"
fi
$CONTAINER_RUNTIME run -d \
@ -101,7 +123,7 @@ for ((i = 0 ; i < $MAX_TRIES ; i++)); do
done
if [[ $i -ge $MAX_TRIES ]]; then
echo "Synapse did not start in time! Use \`$CONTAINER_RUNTIME logs synapse\` to investigate"
echo "Synapse did not start in time! Use '$CONTAINER_RUNTIME logs synapse' to investigate"
exit 1
fi
@ -121,3 +143,20 @@ if [[ "$REGISTER_USER_SUCCESS" != "0" ]]; then
else
echo -e "Matrix user @upschooling:synapse created. \e[1;38;5;2mOK\033[0m"
fi
$CONTAINER_RUNTIME run -d \
--log-driver "k8s-file" \
--name=elementweb \
"--network=container:$($CONTAINER_RUNTIME inspect --format "{{.Id}}" nextcloud)" \
-v "$DIR/extra/element-web-nginx.conf:/etc/nginx/conf.d/default.conf" \
-v "$DIR/extra/element-config.json:/app/config.json" \
--hostname elementweb \
docker.io/vectorim/element-web
set +x
echo -e "Element Web has started. \e[1;38;5;2mOK\033[0m"
echo
echo "To view Nextcloud logs, use '$CONTAINER_RUNTIME exec --user "'"'"${APACHE_RUN_USER}:${APACHE_RUN_GROUP}"'"'" -it nextcloud ./occ log:watch'"
echo "To view Nginx logs of the reverse proxy, use '$CONTAINER_RUNTIME logs -f elementweb'"
echo "Run 'xdg-open "'"'"http://localhost:8080/apps/upschooling/"'"'"' to open the Nextcloud app in your default browser"

View file

@ -1,12 +1,22 @@
<template>
<!--
SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
SPDX-License-Identifier: AGPL-3.0-or-later
-->
<div id="content" class="app-upschooling">
<AppNavigation />
<AppNavigation>
<AppNavigationCaption title="Meine Support-Tickets" />
<template v-for="item in tickets">
<AppNavigationItem :key="item.ticketId" :title="item.title" @click="openTicket(item.ticketId)" />
<!-- TODO: show only proper tickets -->
</template>
</AppNavigation>
<AppContent>
<div v-if="currentTicket">
<Ticket :ticket="currentTicket" @save-ticket="saveTicket" @show-ticket-list="deselectTicket" />
</div>
<div v-else>
<TicketList :tickets="tickets" @open-ticket="openTicket" />
<TicketList :tickets="tickets" @open-ticket="openTicket" @new-ticket="newTicket" />
</div>
</AppContent>
</div>
@ -14,7 +24,9 @@
<script>
import AppContent from '@nextcloud/vue/dist/Components/AppContent'
import AppNavigation from '@nextcloud/vue/dist/Components/AppNavigation'
import { AppNavigation } from '@nextcloud/vue'
import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem'
import AppNavigationCaption from '@nextcloud/vue/dist/Components/AppNavigationCaption'
import TicketList from './components/TicketList'
import Ticket from './Ticket'
import '@nextcloud/dialogs/styles/toast.scss'
@ -27,6 +39,8 @@ export default {
TicketList,
AppContent,
AppNavigation,
AppNavigationItem,
AppNavigationCaption,
},
data() {
@ -46,15 +60,16 @@ export default {
$route: 'fetchTickets',
},
created() {
this.createExampleContent()
this.createExampleContent().finally(() => {
this.fetchTickets()
})
},
methods: {
createExampleContent() {
async createExampleContent() {
// this obviously shouldn't survive version 1.0
axios.post(
await axios.post(
'api/v1/tickets',
{ title: 'Erstes Ticket', content: 'Erstes Beispiel' },
{ title: 'Ein Ticket', content: 'Ein Beispiel' },
{ headers: { 'Content-Type': 'application/json', Accept: 'application/json' } },
).then((response) => {
if (this.ticketsFetched === false) {
@ -63,7 +78,7 @@ export default {
}).catch(console.error)
axios.get(
'api/v1/tickets/1',
{ headers: { 'Content-Type': 'application/json', Accept: 'application/json' } },
{ headers: { Accept: 'application/json' } },
).catch(console.error)
axios.put(
'api/v1/tickets/1',
@ -99,6 +114,9 @@ export default {
deselectTicket() {
this.currentTicket = null
},
newTicket() {
// TODO: generate new empty ticket
},
},
}
</script>

View file

@ -2,7 +2,7 @@
<div class="single-ticket">
<div class="header-bar">
<button @click="back">
{{ t('upschooling', 'Ticket Schließen') }}
{{ t('upschooling', 'Zurück') }}
</button>
<button @click="save">
{{ t('upschooling', 'Speichern') }}
@ -18,12 +18,19 @@
{{ t('upschooling', 'Speichern') }}
</button>
<hr>
<div class="placeholder" />
<iframe id="element-web-frame"
src="about:blank"
title="Embedded Element Web"
width="100%"
height="400" />
</div>
</template>
<script>
import KeyValueTable from './components/KeyValueTable'
import axios from '@nextcloud/axios'
export default {
name: 'Ticket',
components: { KeyValueTable },
@ -40,6 +47,31 @@ export default {
description: this.ticket.description,
}
},
mounted() {
/** @type {HTMLIFrameElement} */
const elementWebFrame = document.getElementById('element-web-frame')
this.loadChat(elementWebFrame).catch((err) => {
if (err.message === 'Room not found') {
console.debug('No chat room assigned to ticket')
elementWebFrame.src = 'about:blank'
elementWebFrame.onload = function() {
const textElement = elementWebFrame.contentDocument.createElement('strong')
textElement.innerText = 'Textchat nicht verfügbar. Es ist noch kein(e) Helfer*in zugewiesen.'
elementWebFrame.contentDocument.body.appendChild(textElement)
elementWebFrame.onload = undefined
}
} else {
console.error('Could not load Element Web in iframe', err)
elementWebFrame.src = 'about:blank'
elementWebFrame.onload = function() {
const textElement = elementWebFrame.contentDocument.createElement('strong')
textElement.innerText = 'Element Web konnte nicht geladen werden.'
elementWebFrame.contentDocument.body.appendChild(textElement)
elementWebFrame.onload = undefined
}
}
})
},
methods: {
toLocaleDate(timestamp) {
const date = new Date(timestamp)
@ -53,6 +85,73 @@ export default {
back() {
this.$emit('show-ticket-list')
},
async loadChat(elementWebFrame) {
const matrixInfoResponse = await axios.get(
`api/v1/tickets/${this.ticket.ticketId}/chat`,
{ headers: { Accept: 'application/json' }, validateStatus: status => status === 200 || status === 404 },
)
if (matrixInfoResponse.status === 404 && matrixInfoResponse.data.message === 'Room not found') {
throw Error(matrixInfoResponse.data.message)
}
if (matrixInfoResponse.status !== 200) {
throw Error(`Received unexpected status code ${matrixInfoResponse.status} for fetching matrix chat data`)
}
if (!matrixInfoResponse.data) {
throw Error('Did not receive any matrix chat data')
}
if (typeof matrixInfoResponse.data !== 'object') {
throw Error('Unexpected return value for fetching matrix chat data')
}
const loginPromise = new Promise(function(resolve, reject) {
const tryLogin = (elementWebFrame, matrixInfo, round) => {
if (elementWebFrame.contentWindow.mxLoginWithAccessToken === undefined) {
console.warn('Couldn\'t login in round ' + round)
setTimeout(() => {
tryLogin(elementWebFrame, matrixInfo, round + 1)
}, 1000)
} else {
elementWebFrame.contentWindow.mxLoginWithAccessToken(
matrixInfo.matrixServerUrl,
matrixInfo.matrixAccessToken,
).then(resolve).catch(reject)
}
}
elementWebFrame.onload = function() {
elementWebFrame.onload = undefined
tryLogin(elementWebFrame, matrixInfoResponse.data, 1)
}
})
// load Element Web
elementWebFrame.src = '/upschooling/element-web/'
loginPromise.then(async () => {
const matrixClient = elementWebFrame.contentWindow.mxMatrixClientPeg.get()
await matrixClient.joinRoom(matrixInfoResponse.data.matrixChatRoom)
elementWebFrame.contentWindow.mxDispatcher.dispatch({
action: 'view_room',
room_id: matrixInfoResponse.data.matrixChatRoom,
}, true)
// remove elements by CSS injection
const styleElement = elementWebFrame.contentDocument.createElement('style')
styleElement.innerText = `
.mx_LeftPanel_outerWrapper {
display: none !important;
}
.mx_NewRoomIntro {
display: none !important;
}
.mx_ToastContainer {
display: none !important;
}
`
elementWebFrame.contentDocument.head.appendChild(styleElement)
}).catch(console.error)
},
},
}
</script>

View file

@ -1,4 +1,10 @@
<template>
<div class="ticketlist">
<div class="header-bar">
<button @click="newTicket">
{{ t('upschooling', 'Neues Ticket') }}
</button>
</div>
<table
id="ticketlist"
class="list-container has-controls">
@ -51,6 +57,7 @@
</tr>
</tbody>
</table>
</div>
</template>
<script>
@ -72,32 +79,37 @@ export default {
openTicket(ticketId) {
this.$emit('open-ticket', ticketId)
},
newTicket() {
this.$emit('new-ticket')
},
},
}
</script>
<style scoped>
#ticketlist {
margin-top: 4rem;
}
table {
table {
width: 100%;
}
}
td {
td {
border-bottom: solid #000 1px;
}
}
tr:nth-child(2n) {
tr:nth-child(2n) {
background: #f0f0f0;
}
}
a .ticket-number {
a .ticket-number {
opacity: 0.5;
}
}
a:hover .ticket-number, a:focus .ticket-number, a:active .ticket-number {
a:hover .ticket-number, a:focus .ticket-number, a:active .ticket-number {
opacity: 1;
}
}
.header-bar {
display: flex;
width: 100%;
flex-direction: row-reverse;
}
</style>

View file

@ -1,24 +1,8 @@
/**
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.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/>.
*
* SPDX-FileCopyrightText: 2018 John Molakvoæ <skjnldsv@protonmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { generateFilePath } from '@nextcloud/router'
import Vue from 'vue'

View file

@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: Nextcloud contributors
// SPDX-License-Identifier: AGPL-3.0-or-later
const stylelintConfig = require('@nextcloud/stylelint-config')
module.exports = stylelintConfig

View file

@ -1 +1,6 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
?>
<div id="content"></div>

16
test.sh
View file

@ -3,16 +3,16 @@
set -xeuo pipefail
IFS=$'\n\t'
DIR="$(realpath ${0%/*})"
RUNTIME_IS_PODMAN="false"
if [[ -x "$(which podman)" ]]; then
CONTAINER_RUNTIME="$(which podman 2> /dev/null)"
RUNTIME_IS_PODMAN="true"
elif [[ -x "$(which docker)" ]]; then
CONTAINER_RUNTIME="$(which docker 2> /dev/null)"
if [[ -x "$(command -v podman)" ]]; then
CONTAINER_RUNTIME="$(command -v podman 2> /dev/null)"
elif [[ -x "$(command -v docker)" ]]; then
CONTAINER_RUNTIME="$(command -v docker 2> /dev/null)"
else
echo "Container runtime (docker/podman) not found!"
exit 1
fi
$CONTAINER_RUNTIME exec --user 33 nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && make test'
export APACHE_RUN_USER=33
export APACHE_RUN_GROUP=0
$CONTAINER_RUNTIME exec --user "${APACHE_RUN_USER}:${APACHE_RUN_GROUP}" nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && make test'

View file

@ -1,59 +0,0 @@
<?php
namespace OCA\UPschooling\Tests\Integration\Controller;
use OCA\UPschooling\Controller\TicketApiController;
use OCA\UPschooling\Db\MatrixTicket;
use OCA\UPschooling\Db\TicketMapper;
use OCP\AppFramework\App;
use OCP\IRequest;
use PHPUnit\Framework\TestCase;
class MatrixTicketIntegrationTest extends TestCase {
private $controller;
private $mapper;
private $userId = 'john';
public function setUp(): void {
$app = new App('upschooling');
$container = $app->getContainer();
// only replace the user id
$container->registerService('userId', function () {
return $this->userId;
});
// we do not care about the request but the controller needs it
$container->registerService(IRequest::class, function () {
return $this->createMock(IRequest::class);
});
$this->controller = $container->query(TicketApiController::class);
$this->mapper = $container->query(TicketMapper::class);
}
public function testUpdate() {
// create a new note that should be updated
$note = new MatrixTicket();
$note->setTitle('old_title');
$note->setContent('old_content');
$note->setUserId($this->userId);
$id = $this->mapper->insert($note)->getId();
// fromRow does not set the fields as updated
$updatedNote = MatrixTicket::fromRow([
'id' => $id,
'user_id' => $this->userId
]);
$updatedNote->setContent('content');
$updatedNote->setTitle('title');
$result = $this->controller->update($id, 'title', 'content');
$this->assertEquals($updatedNote, $result->getData());
// clean up
$this->mapper->delete($result->getData());
}
}

View file

@ -1,48 +0,0 @@
<?php
namespace OCA\UPschooling\Tests\Integration\Controller;
use OCA\UPschooling\Db\MatrixUser;
use OCA\UPschooling\Db\UserMapper;
use OCP\AppFramework\App;
use OCP\IRequest;
use PHPUnit\Framework\TestCase;
class MatrixUserIntegrationTest extends TestCase {
private $mapper;
private $userId = 'john';
private $matrixUserId = '@john:synapse';
public function setUp(): void {
$app = new App('upschooling');
$container = $app->getContainer();
// only replace the user id
$container->registerService('userId', function () {
return $this->userId;
});
// we do not care about the request but the controller needs it
$container->registerService(IRequest::class, function () {
return $this->createMock(IRequest::class);
});
$this->mapper = $container->query(UserMapper::class);
}
public function testUpdate() {
// create a new user
$user = new MatrixUser();
$user->setMatrixUser($this->matrixUserId);
$user->setUserId($this->userId);
$this->mapper->insert($user);
// test that user is in database
$result = $this->mapper->find($this->userId);
$this->assertEquals($user, $result->getData());
// clean up
$this->mapper->delete($result->getData());
}
}

View file

@ -3,41 +3,72 @@
namespace OCA\UPschooling\Tests\Unit\Controller;
use OCA\UPschooling\Controller\TicketApiController;
use OCA\UPschooling\Db\TicketMapper;
use OCA\UPschooling\Service\ChatService;
use OCA\UPschooling\Service\MatrixService;
use OCA\UPschooling\Service\TicketService;
use OCP\AppFramework\Http;
use OCP\IRequest;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
class TicketApiControllerTest extends TestCase
{
protected $controller;
protected $service;
protected $userId = 'john';
protected $request;
protected TicketApiController $controller;
protected string $userId = 'john';
protected TicketService $ticketService;
protected TicketMapper $ticketMapper;
protected MatrixService $matrixService;
protected ChatService $chatService;
protected IRequest $request;
public function setUp(): void
{
$this->request = $this->getMockBuilder(IRequest::class)->getMock();
$this->service = $this->getMockBuilder(TicketService::class)
$this->ticketService = $this->getMockBuilder(TicketService::class)
->disableOriginalConstructor()
->getMock();
$this->controller = new TicketApiController($this->request, $this->service, $this->userId);
$this->ticketMapper = $this->getMockBuilder(TicketMapper::class)
->disableOriginalConstructor()
->getMock();
$this->matrixService = $this->getMockBuilder(MatrixService::class)
->disableOriginalConstructor()
->getMock();
$this->chatService = $this->getMockBuilder(ChatService::class)
->disableOriginalConstructor()
->getMock();
$this->controller = new TicketApiController(
$this->request,
new NullLogger(),
$this->ticketService,
$this->ticketMapper,
$this->matrixService,
$this->chatService,
$this->userId,
);
}
public function testUpdate()
public function testCreate()
{
$note = 'just check if this value is returned correctly';
$this->service->expects($this->once())
->method('update')
->with($this->equalTo(3),
$this->equalTo('title'),
$this->equalTo('content'),
$this->equalTo($this->userId))
->will($this->returnValue($note));
$title = 'title here';
$content = 'just check if this value is returned correctly';
$ticketId = 1;
$result = $this->controller->update(3);
$this->ticketService->expects($this->once())
->method('create')
->with($this->equalTo($title), $this->equalTo($content), $this->equalTo($this->userId))
->willReturn(array(
'ticketId' => $ticketId,
'status' => "open",
'lastModified' => $this->any(),
'title' => $title,
'description' => $content,
'matrixHelperName' => null,
'expirationDate' => $this->any(),
));
$this->assertEquals($note, $result->getData());
$response = $this->controller->create($title, $content);
$responseData = $response->getData();
$this->assertEquals($ticketId, $responseData['ticketId']);
}
/*

View file

@ -1,20 +1,27 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCA\UPschooling\Tests\Unit\Service;
use OCA\UPschooling\Db\MatrixTicket;
use OCA\UPschooling\Db\MatrixUser;
use OCA\UPschooling\Db\TicketMapper;
use OCA\UPschooling\Db\UserMapper;
use OCA\UPschooling\Exceptions\TicketNotFoundException;
use OCA\UPschooling\Service\MatrixService;
use OCA\UPschooling\Service\TicketService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\IUser;
use OCP\IUserManager;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
class TicketServiceTest extends TestCase {
/** @var TicketService */
private $service;
private $ticketService;
/** @var MatrixService */
private $matrixService;
@ -29,46 +36,80 @@ class TicketServiceTest extends TestCase {
private $userId = 'john';
public function setUp(): void {
$this->userManager = $this->getMockBuilder(IUserManager::class)->getMock();
$this->ticketMapper = $this->getMockBuilder(TicketMapper::class)
->disableOriginalConstructor()
->getMock();
$this->userMapper = $this->getMockBuilder(UserMapper::class)
->disableOriginalConstructor()
->getMock();
$this->matrixService = new MatrixService(new NullLogger());
$this->service = new TicketService($this->matrixService, $this->ticketMapper, $this->userMapper);
$this->matrixService = $this->getMockBuilder(MatrixService::class)
->disableOriginalConstructor()
->getMock();
$this->ticketService = new TicketService(
$this->userManager,
$this->matrixService,
$this->ticketMapper,
$this->userMapper,
new NullLogger(),
);
}
public function testUpdate() {
// the existing note
$note = MatrixTicket::fromRow([
'id' => 3,
public function testAssign() {
$ticketId = 3;
$matrixControlRoom = "!room:server";
$assistedUserMatrixId = "@user:server";
$ticket = MatrixTicket::fromRow([
'id' => $ticketId,
'matrixControlRoom' => $matrixControlRoom,
'matrixAssistedUser' => $assistedUserMatrixId,
'matrixHelperUser' => null,
'status' => "open",
'version' => 1,
]);
$this->ticketMapper->expects($this->once())
->method('find')
->with($this->equalTo(3))
->will($this->returnValue($note));
// the note when updated
$updatedNote = MatrixTicket::fromRow(['id' => 3]);
->method('findTicket')
->with($this->equalTo($ticketId))
->willReturn($ticket);
$stubTicket = new MatrixTicket();
$stubTicket->setId($ticketId);
$stubTicket->setMatrixControlRoom($matrixControlRoom);
$this->ticketMapper->expects($this->once())
->method('update')
->with($this->equalTo($updatedNote))
->will($this->returnValue($updatedNote));
->willReturn($stubTicket);
$result = $this->service->update(3, 'title', 'content', $this->userId);
$this->assertEquals($updatedNote, $result);
}
public function testUpdateNotFound() {
// $this->expectException(NoteNotFound::class);
// test the correct status code if no note is found
$this->ticketMapper->expects($this->once())
$helperUserMatrixId = "@helper:server";
$helperUserName = "Expected Helper User Name";
$mockUser = $this->getMockBuilder(IUser::class)->getMock();
$mockUser->expects($this->once())
->method('getDisplayName')
->willReturn($helperUserName);
$this->userManager->expects($this->once())
->method('get')
->with($this->equalTo($this->userId))
->willReturn($mockUser);
$helperMatrixUser = new MatrixUser();
$helperMatrixUser->setUserId($helperUserMatrixId);
$this->userMapper->expects($this->once())
->method('find')
->with($this->equalTo(3))
->will($this->throwException(new DoesNotExistException('')));
->with($this->equalTo($this->userId))
->willReturn($helperMatrixUser);
$this->service->update(3, 'title', 'content', $this->userId);
$this->matrixService->expects($this->once())
->method('getProperty')
->with($this->equalTo($matrixControlRoom))
->willReturn(array(
'id' => $ticketId,
'title' => $this->any(),
'description' => $this->any(),
'matrixControlRoom' => $matrixControlRoom,
'matrixAssistedUser' => $assistedUserMatrixId,
'matrixHelperUser' => $helperUserMatrixId,
'matrixHelperName' => $helperUserName,
'expirationDate' => $this->any(),
));
$result = $this->ticketService->assign($ticketId, $this->userId);
$this->assertEquals($helperUserName, $result['matrixHelperName']);
}
}

View file

@ -1,5 +1,9 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
require_once __DIR__ . '/../tests/bootstrap.php';
define('PHPUNIT_RUN', 1);
$configDir = getenv('CONFIG_DIR');

View file

@ -0,0 +1,9 @@
<phpunit bootstrap="bootstrap.php" colors="true">
<!--
SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
SPDX-License-Identifier: AGPL-3.0-or-later
-->
<testsuites>
</testsuites>
</phpunit>

11
tests/phpunit.xml Normal file
View file

@ -0,0 +1,11 @@
<phpunit bootstrap="bootstrap.php" colors="true">
<!--
SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
SPDX-License-Identifier: AGPL-3.0-or-later
-->
<testsuites>
<testsuite name="unit">
<directory>./Unit</directory>
</testsuite>
</testsuites>
</phpunit>

3
tests/psalm-baseline.xml Normal file
View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
</files>

View file

@ -0,0 +1,2 @@
SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
SPDX-License-Identifier: CC0-1.0

5
webpack.config.js Normal file
View file

@ -0,0 +1,5 @@
// SPDX-FileCopyrightText: BVSC e.V. <no@example.com>
// SPDX-License-Identifier: AGPL-3.0-or-later
const webpackConfig = require('@nextcloud/webpack-vue-config')
module.exports = webpackConfig

View file

@ -1,3 +0,0 @@
const webpackConfig = require('@nextcloud/webpack-vue-config')
module.exports = webpackConfig