From 4c73c745875d4f3b0bf5bd221aa11ab7796da144 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 29 Aug 2024 16:15:28 +0200 Subject: [PATCH] chore(web): move web handler package to Vikunja (cherry picked from commit 2063da9eecf8d0980a62106a627d7f00da172138) --- go.mod | 9 +- go.sum | 28 -- pkg/files/files.go | 2 +- pkg/integrations/_test.go.tpl | 3 +- pkg/integrations/archived_test.go | 2 +- pkg/integrations/integrations.go | 4 +- pkg/integrations/kanban_test.go | 2 +- pkg/integrations/link_sharing_test.go | 2 +- pkg/integrations/project_test.go | 2 +- pkg/integrations/task_collection_test.go | 2 +- pkg/integrations/task_comment_test.go | 2 +- pkg/integrations/task_test.go | 2 +- pkg/metrics/active_users.go | 2 +- pkg/models/api_tokens.go | 2 +- pkg/models/api_tokens_rights.go | 2 +- pkg/models/bulk_task.go | 2 +- pkg/models/error.go | 2 +- pkg/models/events.go | 2 +- pkg/models/favorites.go | 2 +- pkg/models/kanban.go | 2 +- pkg/models/kanban_rights.go | 2 +- pkg/models/kanban_task_bucket.go | 2 +- pkg/models/label.go | 2 +- pkg/models/label_rights.go | 2 +- pkg/models/label_task.go | 2 +- pkg/models/label_task_rights.go | 2 +- pkg/models/label_task_test.go | 2 +- pkg/models/label_test.go | 2 +- pkg/models/link_sharing.go | 2 +- pkg/models/link_sharing_rights.go | 2 +- pkg/models/notifications_database.go | 2 +- pkg/models/project.go | 2 +- pkg/models/project_duplicate.go | 2 +- pkg/models/project_rights.go | 2 +- pkg/models/project_team.go | 2 +- pkg/models/project_team_rights.go | 2 +- pkg/models/project_team_test.go | 2 +- pkg/models/project_users.go | 2 +- pkg/models/project_users_rights.go | 2 +- pkg/models/project_users_rights_test.go | 2 +- pkg/models/project_users_test.go | 2 +- pkg/models/project_view.go | 2 +- pkg/models/project_view_rights.go | 2 +- pkg/models/reaction.go | 2 +- pkg/models/reaction_rights.go | 2 +- pkg/models/saved_filters.go | 2 +- pkg/models/saved_filters_rights.go | 2 +- pkg/models/subscription.go | 2 +- pkg/models/subscription_rights.go | 2 +- pkg/models/task_assignees.go | 2 +- pkg/models/task_assignees_rights.go | 2 +- pkg/models/task_attachment.go | 2 +- pkg/models/task_attachment_rights.go | 2 +- pkg/models/task_collection.go | 2 +- pkg/models/task_collection_test.go | 2 +- pkg/models/task_comment_rights.go | 2 +- pkg/models/task_comments.go | 2 +- pkg/models/task_position.go | 2 +- pkg/models/task_relation.go | 2 +- pkg/models/task_relation_rights.go | 2 +- pkg/models/task_search.go | 2 +- pkg/models/tasks.go | 2 +- pkg/models/tasks_rights.go | 2 +- pkg/models/team_members.go | 2 +- pkg/models/team_members_rights.go | 2 +- pkg/models/teams.go | 2 +- pkg/models/teams_rights.go | 2 +- pkg/models/teams_rights_test.go | 2 +- pkg/models/users.go | 2 +- pkg/models/webhooks.go | 2 +- pkg/models/webhooks_rights.go | 2 +- pkg/modules/auth/auth.go | 2 +- pkg/modules/auth/openid/openid.go | 2 +- pkg/modules/background/background.go | 2 +- pkg/modules/background/handler/background.go | 4 +- pkg/modules/background/unsplash/proxy.go | 2 +- pkg/modules/background/unsplash/unsplash.go | 2 +- pkg/modules/background/upload/upload.go | 2 +- pkg/modules/migration/handler/common.go | 2 +- pkg/modules/migration/handler/handler.go | 2 +- pkg/modules/migration/handler/handler_file.go | 2 +- pkg/routes/api/v1/avatar.go | 2 +- pkg/routes/api/v1/link_sharing_auth.go | 2 +- pkg/routes/api/v1/login.go | 2 +- pkg/routes/api/v1/task_attachment.go | 3 +- pkg/routes/api/v1/user_caldav_token.go | 2 +- pkg/routes/api/v1/user_confirm_email.go | 2 +- pkg/routes/api/v1/user_deletion.go | 2 +- pkg/routes/api/v1/user_export.go | 2 +- pkg/routes/api/v1/user_list.go | 2 +- pkg/routes/api/v1/user_password_reset.go | 2 +- pkg/routes/api/v1/user_register.go | 2 +- pkg/routes/api/v1/user_settings.go | 2 +- pkg/routes/api/v1/user_show.go | 2 +- pkg/routes/api/v1/user_totp.go | 2 +- pkg/routes/api/v1/user_update_email.go | 2 +- pkg/routes/api/v1/user_update_password.go | 2 +- pkg/routes/caldav/handler.go | 2 +- pkg/routes/caldav/listStorageProvider.go | 2 +- pkg/routes/routes.go | 4 +- pkg/user/error.go | 2 +- pkg/user/user.go | 2 +- pkg/web/handler/config.go | 57 ++++ pkg/web/handler/create.go | 89 ++++++ pkg/web/handler/delete.go | 87 ++++++ pkg/web/handler/helper.go | 46 ++++ pkg/web/handler/read_all.go | 129 +++++++++ pkg/web/handler/read_one.go | 90 +++++++ pkg/web/handler/update.go | 89 ++++++ pkg/web/readme.md | 253 ++++++++++++++++++ pkg/web/web.go | 67 +++++ 111 files changed, 1016 insertions(+), 136 deletions(-) create mode 100644 pkg/web/handler/config.go create mode 100644 pkg/web/handler/create.go create mode 100644 pkg/web/handler/delete.go create mode 100644 pkg/web/handler/helper.go create mode 100644 pkg/web/handler/read_all.go create mode 100644 pkg/web/handler/read_one.go create mode 100644 pkg/web/handler/update.go create mode 100644 pkg/web/readme.md create mode 100644 pkg/web/web.go diff --git a/go.mod b/go.mod index 4cb3513a8..89a77f641 100644 --- a/go.mod +++ b/go.mod @@ -1,23 +1,22 @@ // Vikunja is a to-do list application to facilitate your life. -// Copyright 2018 Vikunja and contributors. All rights reserved. +// Copyright 2018-present Vikunja and contributors. All rights reserved. // // This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by +// it under the terms of the GNU Affero General Public Licensee 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 General Public License for more details. +// GNU Affero General Public Licensee for more details. // -// You should have received a copy of the GNU General Public License +// You should have received a copy of the GNU Affero General Public Licensee // along with this program. If not, see . module code.vikunja.io/api require ( - code.vikunja.io/web v0.0.0-20210706160506-d85def955bd3 dario.cat/mergo v1.0.0 github.com/ThreeDotsLabs/watermill v1.3.5 github.com/adlio/trello v1.12.0 diff --git a/go.sum b/go.sum index 492b3c6ab..8921cfe28 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -code.vikunja.io/web v0.0.0-20210706160506-d85def955bd3 h1:MXl7Ff9a/ndTpuEmQKIGhqReE9hWhD4T/+AzK4AXUYc= -code.vikunja.io/web v0.0.0-20210706160506-d85def955bd3/go.mod h1:OgFO06HN1KpA4S7Dw/QAIeygiUPSeGJJn1ykz/sjZdU= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= @@ -18,7 +16,6 @@ github.com/ClickHouse/clickhouse-go/v2 v2.24.0/go.mod h1:iDTViXk2Fgvf1jn2dbJd1ys github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= @@ -28,7 +25,6 @@ github.com/adlio/trello v1.12.0 h1:JqOE2GFHQ9YtEviRRRSnicSxPbt4WFOxhqXzjMOw8lw= github.com/adlio/trello v1.12.0/go.mod h1:I4Lti4jf2KxjTNgTqs5W3lLuE78QZZdYbbPnQQGwjOo= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= -github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= github.com/arran4/golang-ical v0.3.1 h1:v13B3eQZ9VDHTAvT6M11vVzxYgcYmjyPBE2eAZl3VZk= @@ -77,10 +73,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/denisenkom/go-mssqldb v0.12.3 h1:pBSGx9Tq67pBOTLmxNuirNTeB8Vjmf886Kx+8Y+8shw= github.com/denisenkom/go-mssqldb v0.12.3/go.mod h1:k0mtMFOnU+AihqFxPMiF05rtiDrorD1Vrm1KEz5hxDo= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c= @@ -128,7 +122,6 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.22.8 h1:/9RjDSQ0vbFR+NyjGMkFTsA1IA0fmhKSThmfGZjicbw= github.com/go-openapi/swag v0.22.8/go.mod h1:6QT22icPLEqAM/z/TChgb4WAveCHF92+2gF0CNjHpPI= -github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= @@ -293,10 +286,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/labstack/echo-jwt/v4 v4.2.0 h1:odSISV9JgcSCuhgQSV/6Io3i7nUmfM/QkBeR5GVJj5c= github.com/labstack/echo-jwt/v4 v4.2.0/go.mod h1:MA2RqdXdEn4/uEglx0HcUOgQSyBaTh5JcaHIan3biwU= -github.com/labstack/echo/v4 v4.1.16/go.mod h1:awO+5TzAjvL8XpibdsfXxPgHr+orhtXZJZIQCVjogKI= github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0= github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM= -github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= github.com/laurent22/ical-go v0.1.1-0.20181107184520-7e5d6ade8eef h1:RZnRnSID1skF35j/15KJ6hKZkdIC/teQClJK5wP5LU4= @@ -304,7 +295,6 @@ github.com/laurent22/ical-go v0.1.1-0.20181107184520-7e5d6ade8eef/go.mod h1:4LAT github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= @@ -323,15 +313,11 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -339,7 +325,6 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= @@ -490,9 +475,6 @@ github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/fasttemplate v1.2.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/wneessen/go-mail v0.4.2 h1:wISuU9LOGqrA7pxy7OipRtwoExXTzuGKmAjb8gYwc00= @@ -531,14 +513,11 @@ go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -561,17 +540,13 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= @@ -607,7 +582,6 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200808120158-1030fc2bf1d9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -749,11 +723,9 @@ src.techknowlogick.com/xgo v1.7.1-0.20240403232151-e01c4fbef884 h1:Ttvt8FCpUXfC8 src.techknowlogick.com/xgo v1.7.1-0.20240403232151-e01c4fbef884/go.mod h1:31CE1YKtDOrKTk9PSnjTpe6YbO6W/0LTYZ1VskL09oU= src.techknowlogick.com/xormigrate v1.7.1 h1:RKGLLUAqJ+zO8iZ7eOc7oLH7f0cs2gfXSZSvBRBHnlY= src.techknowlogick.com/xormigrate v1.7.1/go.mod h1:YGNBdj8prENlySwIKmfoEXp7ILGjAltyKFXD0qLgD7U= -xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo= xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= -xorm.io/xorm v1.0.5/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4= xorm.io/xorm v1.3.3/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo= xorm.io/xorm v1.3.9 h1:TUovzS0ko+IQ1XnNLfs5dqK1cJl1H5uHpWbWqAQ04nU= xorm.io/xorm v1.3.9/go.mod h1:LsCCffeeYp63ssk0pKumP6l96WZcHix7ChpurcLNuMw= diff --git a/pkg/files/files.go b/pkg/files/files.go index b61f72308..033799f10 100644 --- a/pkg/files/files.go +++ b/pkg/files/files.go @@ -29,7 +29,7 @@ import ( "code.vikunja.io/api/pkg/metrics" "code.vikunja.io/api/pkg/modules/keyvalue" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "github.com/c2h5oh/datasize" "github.com/spf13/afero" "xorm.io/xorm" diff --git a/pkg/integrations/_test.go.tpl b/pkg/integrations/_test.go.tpl index cc2c97dd8..92c9ffef5 100644 --- a/pkg/integrations/_test.go.tpl +++ b/pkg/integrations/_test.go.tpl @@ -18,7 +18,8 @@ package integrations import ( "code.vikunja.io/api/pkg/models" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" + "github.com/labstack/echo" "github.com/stretchr/testify/assert" "net/url" diff --git a/pkg/integrations/archived_test.go b/pkg/integrations/archived_test.go index 86559259d..398e2c8f1 100644 --- a/pkg/integrations/archived_test.go +++ b/pkg/integrations/archived_test.go @@ -20,7 +20,7 @@ import ( "testing" "code.vikunja.io/api/pkg/models" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/integrations/integrations.go b/pkg/integrations/integrations.go index bd319925d..b8b837b21 100644 --- a/pkg/integrations/integrations.go +++ b/pkg/integrations/integrations.go @@ -35,8 +35,8 @@ import ( "code.vikunja.io/api/pkg/routes" "code.vikunja.io/api/pkg/routes/caldav" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web" + "code.vikunja.io/api/pkg/web/handler" "github.com/golang-jwt/jwt/v5" "github.com/labstack/echo/v4" diff --git a/pkg/integrations/kanban_test.go b/pkg/integrations/kanban_test.go index 41b5c1733..92cc319df 100644 --- a/pkg/integrations/kanban_test.go +++ b/pkg/integrations/kanban_test.go @@ -21,7 +21,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/models" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" diff --git a/pkg/integrations/link_sharing_test.go b/pkg/integrations/link_sharing_test.go index e144817b3..81f72206c 100644 --- a/pkg/integrations/link_sharing_test.go +++ b/pkg/integrations/link_sharing_test.go @@ -21,7 +21,7 @@ import ( "testing" "code.vikunja.io/api/pkg/models" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" diff --git a/pkg/integrations/project_test.go b/pkg/integrations/project_test.go index cb17df4f0..c8d538b8e 100644 --- a/pkg/integrations/project_test.go +++ b/pkg/integrations/project_test.go @@ -21,7 +21,7 @@ import ( "testing" "code.vikunja.io/api/pkg/models" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" diff --git a/pkg/integrations/task_collection_test.go b/pkg/integrations/task_collection_test.go index 6b7ea6b8e..76e0a9597 100644 --- a/pkg/integrations/task_collection_test.go +++ b/pkg/integrations/task_collection_test.go @@ -21,7 +21,7 @@ import ( "testing" "code.vikunja.io/api/pkg/models" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/integrations/task_comment_test.go b/pkg/integrations/task_comment_test.go index c09f4b085..cded8cb65 100644 --- a/pkg/integrations/task_comment_test.go +++ b/pkg/integrations/task_comment_test.go @@ -21,7 +21,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/models" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" diff --git a/pkg/integrations/task_test.go b/pkg/integrations/task_test.go index 9239e64e7..7e77020d0 100644 --- a/pkg/integrations/task_test.go +++ b/pkg/integrations/task_test.go @@ -21,7 +21,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/models" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" diff --git a/pkg/metrics/active_users.go b/pkg/metrics/active_users.go index a4d973b29..aa6a08a2d 100644 --- a/pkg/metrics/active_users.go +++ b/pkg/metrics/active_users.go @@ -22,7 +22,7 @@ import ( "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/modules/keyvalue" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" ) diff --git a/pkg/models/api_tokens.go b/pkg/models/api_tokens.go index eb4dc2931..b15abafaf 100644 --- a/pkg/models/api_tokens.go +++ b/pkg/models/api_tokens.go @@ -27,7 +27,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/utils" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "golang.org/x/crypto/pbkdf2" "xorm.io/xorm" ) diff --git a/pkg/models/api_tokens_rights.go b/pkg/models/api_tokens_rights.go index e687fd88b..b51f1cbd8 100644 --- a/pkg/models/api_tokens_rights.go +++ b/pkg/models/api_tokens_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/bulk_task.go b/pkg/models/bulk_task.go index 0697184dc..17896de35 100644 --- a/pkg/models/bulk_task.go +++ b/pkg/models/bulk_task.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "dario.cat/mergo" "xorm.io/xorm" diff --git a/pkg/models/error.go b/pkg/models/error.go index 5be530d99..e7b99d77b 100644 --- a/pkg/models/error.go +++ b/pkg/models/error.go @@ -22,7 +22,7 @@ import ( "strings" "code.vikunja.io/api/pkg/config" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" ) // Generic diff --git a/pkg/models/events.go b/pkg/models/events.go index de0427855..663c3c51f 100644 --- a/pkg/models/events.go +++ b/pkg/models/events.go @@ -18,7 +18,7 @@ package models import ( "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" ) ///////////////// diff --git a/pkg/models/favorites.go b/pkg/models/favorites.go index 6faec1385..00fab14d1 100644 --- a/pkg/models/favorites.go +++ b/pkg/models/favorites.go @@ -18,7 +18,7 @@ package models import ( "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/builder" "xorm.io/xorm" ) diff --git a/pkg/models/kanban.go b/pkg/models/kanban.go index 7b1fa207b..5ee58eed3 100644 --- a/pkg/models/kanban.go +++ b/pkg/models/kanban.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/kanban_rights.go b/pkg/models/kanban_rights.go index d3c3db0b1..ea08f4c03 100644 --- a/pkg/models/kanban_rights.go +++ b/pkg/models/kanban_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/kanban_task_bucket.go b/pkg/models/kanban_task_bucket.go index ae9e39176..868d22441 100644 --- a/pkg/models/kanban_task_bucket.go +++ b/pkg/models/kanban_task_bucket.go @@ -21,7 +21,7 @@ import ( "code.vikunja.io/api/pkg/events" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/label.go b/pkg/models/label.go index b6e473385..e06ca6208 100644 --- a/pkg/models/label.go +++ b/pkg/models/label.go @@ -22,7 +22,7 @@ import ( "code.vikunja.io/api/pkg/user" "code.vikunja.io/api/pkg/utils" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/label_rights.go b/pkg/models/label_rights.go index 941a7099f..df53c053f 100644 --- a/pkg/models/label_rights.go +++ b/pkg/models/label_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/builder" "xorm.io/xorm" ) diff --git a/pkg/models/label_task.go b/pkg/models/label_task.go index 63213d3a9..8386d36b1 100644 --- a/pkg/models/label_task.go +++ b/pkg/models/label_task.go @@ -24,7 +24,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/builder" "xorm.io/xorm" diff --git a/pkg/models/label_task_rights.go b/pkg/models/label_task_rights.go index 868bd95bb..261c4afcf 100644 --- a/pkg/models/label_task_rights.go +++ b/pkg/models/label_task_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/label_task_test.go b/pkg/models/label_task_test.go index 321dff708..f31e0904a 100644 --- a/pkg/models/label_task_test.go +++ b/pkg/models/label_task_test.go @@ -26,7 +26,7 @@ import ( "code.vikunja.io/api/pkg/user" "gopkg.in/d4l3k/messagediff.v1" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" ) func TestLabelTask_ReadAll(t *testing.T) { diff --git a/pkg/models/label_test.go b/pkg/models/label_test.go index ba811f854..0fcea06c6 100644 --- a/pkg/models/label_test.go +++ b/pkg/models/label_test.go @@ -26,7 +26,7 @@ import ( "code.vikunja.io/api/pkg/user" "gopkg.in/d4l3k/messagediff.v1" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" ) func TestLabel_ReadAll(t *testing.T) { diff --git a/pkg/models/link_sharing.go b/pkg/models/link_sharing.go index e2072ec50..bc61f21f3 100644 --- a/pkg/models/link_sharing.go +++ b/pkg/models/link_sharing.go @@ -25,7 +25,7 @@ import ( "code.vikunja.io/api/pkg/user" "code.vikunja.io/api/pkg/utils" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "github.com/golang-jwt/jwt/v5" "golang.org/x/crypto/bcrypt" "xorm.io/builder" diff --git a/pkg/models/link_sharing_rights.go b/pkg/models/link_sharing_rights.go index b5593b945..75a76a008 100644 --- a/pkg/models/link_sharing_rights.go +++ b/pkg/models/link_sharing_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/notifications_database.go b/pkg/models/notifications_database.go index 55b840259..4c80e8136 100644 --- a/pkg/models/notifications_database.go +++ b/pkg/models/notifications_database.go @@ -18,7 +18,7 @@ package models import ( "code.vikunja.io/api/pkg/notifications" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/project.go b/pkg/models/project.go index 6aaf1b51a..de6aa543c 100644 --- a/pkg/models/project.go +++ b/pkg/models/project.go @@ -30,7 +30,7 @@ import ( "code.vikunja.io/api/pkg/user" "code.vikunja.io/api/pkg/utils" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/builder" "xorm.io/xorm" ) diff --git a/pkg/models/project_duplicate.go b/pkg/models/project_duplicate.go index 8c6349cb7..0caea7c9d 100644 --- a/pkg/models/project_duplicate.go +++ b/pkg/models/project_duplicate.go @@ -20,7 +20,7 @@ import ( "code.vikunja.io/api/pkg/files" "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/utils" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/project_rights.go b/pkg/models/project_rights.go index 8442d52a0..09785389e 100644 --- a/pkg/models/project_rights.go +++ b/pkg/models/project_rights.go @@ -20,7 +20,7 @@ import ( "errors" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/builder" "xorm.io/xorm" ) diff --git a/pkg/models/project_team.go b/pkg/models/project_team.go index 982ae648c..40dc1acae 100644 --- a/pkg/models/project_team.go +++ b/pkg/models/project_team.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/events" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/project_team_rights.go b/pkg/models/project_team_rights.go index bab928bdf..5d100909b 100644 --- a/pkg/models/project_team_rights.go +++ b/pkg/models/project_team_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/project_team_test.go b/pkg/models/project_team_test.go index f53fd3ba3..99b2f3a43 100644 --- a/pkg/models/project_team_test.go +++ b/pkg/models/project_team_test.go @@ -24,7 +24,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/models/project_users.go b/pkg/models/project_users.go index 648e97800..58bd0cdfa 100644 --- a/pkg/models/project_users.go +++ b/pkg/models/project_users.go @@ -24,7 +24,7 @@ import ( "code.vikunja.io/api/pkg/events" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/project_users_rights.go b/pkg/models/project_users_rights.go index 051721373..62e99d403 100644 --- a/pkg/models/project_users_rights.go +++ b/pkg/models/project_users_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/project_users_rights_test.go b/pkg/models/project_users_rights_test.go index 341cea74a..e94d5afe8 100644 --- a/pkg/models/project_users_rights_test.go +++ b/pkg/models/project_users_rights_test.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" ) func TestProjectUser_CanDoSomething(t *testing.T) { diff --git a/pkg/models/project_users_test.go b/pkg/models/project_users_test.go index e9ad3a87f..3e6b09ec5 100644 --- a/pkg/models/project_users_test.go +++ b/pkg/models/project_users_test.go @@ -24,7 +24,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "github.com/stretchr/testify/require" "gopkg.in/d4l3k/messagediff.v1" diff --git a/pkg/models/project_view.go b/pkg/models/project_view.go index 63ed27a10..2f28a1142 100644 --- a/pkg/models/project_view.go +++ b/pkg/models/project_view.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/project_view_rights.go b/pkg/models/project_view_rights.go index 2867bc707..553dbd858 100644 --- a/pkg/models/project_view_rights.go +++ b/pkg/models/project_view_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/reaction.go b/pkg/models/reaction.go index 44fe73d62..965341921 100644 --- a/pkg/models/reaction.go +++ b/pkg/models/reaction.go @@ -19,7 +19,7 @@ package models import ( "time" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/builder" "xorm.io/xorm" diff --git a/pkg/models/reaction_rights.go b/pkg/models/reaction_rights.go index 75ca684c1..f56c64285 100644 --- a/pkg/models/reaction_rights.go +++ b/pkg/models/reaction_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/saved_filters.go b/pkg/models/saved_filters.go index ac4b4f0a2..4b7370e04 100644 --- a/pkg/models/saved_filters.go +++ b/pkg/models/saved_filters.go @@ -22,7 +22,7 @@ import ( "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/builder" "xorm.io/xorm" ) diff --git a/pkg/models/saved_filters_rights.go b/pkg/models/saved_filters_rights.go index 7a032976b..3794a7d58 100644 --- a/pkg/models/saved_filters_rights.go +++ b/pkg/models/saved_filters_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/subscription.go b/pkg/models/subscription.go index 2ad6a547f..109c580fe 100644 --- a/pkg/models/subscription.go +++ b/pkg/models/subscription.go @@ -22,7 +22,7 @@ import ( "xorm.io/builder" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/subscription_rights.go b/pkg/models/subscription_rights.go index c000c9f1a..c8ec6af8d 100644 --- a/pkg/models/subscription_rights.go +++ b/pkg/models/subscription_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/task_assignees.go b/pkg/models/task_assignees.go index 81d231367..43e67bbea 100644 --- a/pkg/models/task_assignees.go +++ b/pkg/models/task_assignees.go @@ -26,7 +26,7 @@ import ( "code.vikunja.io/api/pkg/events" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/task_assignees_rights.go b/pkg/models/task_assignees_rights.go index a9b2d9305..69a1a719c 100644 --- a/pkg/models/task_assignees_rights.go +++ b/pkg/models/task_assignees_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/task_attachment.go b/pkg/models/task_attachment.go index c069b207c..84adca1c2 100644 --- a/pkg/models/task_attachment.go +++ b/pkg/models/task_attachment.go @@ -24,7 +24,7 @@ import ( "code.vikunja.io/api/pkg/files" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/task_attachment_rights.go b/pkg/models/task_attachment_rights.go index 7ce4747df..4eed5e5f6 100644 --- a/pkg/models/task_attachment_rights.go +++ b/pkg/models/task_attachment_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/task_collection.go b/pkg/models/task_collection.go index 676510164..434a41bce 100644 --- a/pkg/models/task_collection.go +++ b/pkg/models/task_collection.go @@ -20,7 +20,7 @@ import ( "strings" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/task_collection_test.go b/pkg/models/task_collection_test.go index b321a1d48..9f0e17fa5 100644 --- a/pkg/models/task_collection_test.go +++ b/pkg/models/task_collection_test.go @@ -25,7 +25,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/files" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "gopkg.in/d4l3k/messagediff.v1" ) diff --git a/pkg/models/task_comment_rights.go b/pkg/models/task_comment_rights.go index 42d4054ae..52a0af7e3 100644 --- a/pkg/models/task_comment_rights.go +++ b/pkg/models/task_comment_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/task_comments.go b/pkg/models/task_comments.go index 108273208..6d1b374af 100644 --- a/pkg/models/task_comments.go +++ b/pkg/models/task_comments.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/events" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/builder" "xorm.io/xorm" diff --git a/pkg/models/task_position.go b/pkg/models/task_position.go index 2db26fb49..86b04057b 100644 --- a/pkg/models/task_position.go +++ b/pkg/models/task_position.go @@ -20,7 +20,7 @@ import ( "math" "code.vikunja.io/api/pkg/events" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/task_relation.go b/pkg/models/task_relation.go index 23f0e578d..f8304a77e 100644 --- a/pkg/models/task_relation.go +++ b/pkg/models/task_relation.go @@ -25,7 +25,7 @@ import ( "xorm.io/xorm" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" ) // RelationKind represents a kind of relation between to tasks diff --git a/pkg/models/task_relation_rights.go b/pkg/models/task_relation_rights.go index 646525a86..99dd0d6a4 100644 --- a/pkg/models/task_relation_rights.go +++ b/pkg/models/task_relation_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/task_search.go b/pkg/models/task_search.go index f02398caa..f296dc608 100644 --- a/pkg/models/task_search.go +++ b/pkg/models/task_search.go @@ -24,7 +24,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/log" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "github.com/typesense/typesense-go/typesense/api" "github.com/typesense/typesense-go/typesense/api/pointer" diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 94d23ed71..192b2e411 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -30,7 +30,7 @@ import ( "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/user" "code.vikunja.io/api/pkg/utils" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "dario.cat/mergo" "github.com/google/uuid" diff --git a/pkg/models/tasks_rights.go b/pkg/models/tasks_rights.go index 7573a9b48..a52d4252f 100644 --- a/pkg/models/tasks_rights.go +++ b/pkg/models/tasks_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/team_members.go b/pkg/models/team_members.go index a06cf83db..814dd839e 100644 --- a/pkg/models/team_members.go +++ b/pkg/models/team_members.go @@ -19,7 +19,7 @@ package models import ( "code.vikunja.io/api/pkg/events" user2 "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/team_members_rights.go b/pkg/models/team_members_rights.go index 02e7ce439..f5c77c084 100644 --- a/pkg/models/team_members_rights.go +++ b/pkg/models/team_members_rights.go @@ -18,7 +18,7 @@ package models import ( "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/teams.go b/pkg/models/teams.go index 2c911b42e..85923b948 100644 --- a/pkg/models/teams.go +++ b/pkg/models/teams.go @@ -24,7 +24,7 @@ import ( "code.vikunja.io/api/pkg/events" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/builder" "xorm.io/xorm" diff --git a/pkg/models/teams_rights.go b/pkg/models/teams_rights.go index 27cf2a2e0..e66e562bc 100644 --- a/pkg/models/teams_rights.go +++ b/pkg/models/teams_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/teams_rights_test.go b/pkg/models/teams_rights_test.go index 0740e406e..8f32c0f9c 100644 --- a/pkg/models/teams_rights_test.go +++ b/pkg/models/teams_rights_test.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" ) func TestTeam_CanDoSomething(t *testing.T) { diff --git a/pkg/models/users.go b/pkg/models/users.go index a24a21ffb..52f257dbc 100644 --- a/pkg/models/users.go +++ b/pkg/models/users.go @@ -18,7 +18,7 @@ package models import ( "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/webhooks.go b/pkg/models/webhooks.go index d6109d336..a6c9e12dd 100644 --- a/pkg/models/webhooks.go +++ b/pkg/models/webhooks.go @@ -37,7 +37,7 @@ import ( "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/user" "code.vikunja.io/api/pkg/version" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/models/webhooks_rights.go b/pkg/models/webhooks_rights.go index b5cc88bd3..30fc6d5fa 100644 --- a/pkg/models/webhooks_rights.go +++ b/pkg/models/webhooks_rights.go @@ -17,7 +17,7 @@ package models import ( - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/modules/auth/auth.go b/pkg/modules/auth/auth.go index 164ea51e0..45fd3d8b5 100644 --- a/pkg/modules/auth/auth.go +++ b/pkg/modules/auth/auth.go @@ -26,7 +26,7 @@ import ( "code.vikunja.io/api/pkg/config" "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "github.com/golang-jwt/jwt/v5" "github.com/labstack/echo/v4" diff --git a/pkg/modules/auth/openid/openid.go b/pkg/modules/auth/openid/openid.go index c2ee5dcf1..8f585e868 100644 --- a/pkg/modules/auth/openid/openid.go +++ b/pkg/modules/auth/openid/openid.go @@ -24,7 +24,7 @@ import ( "strconv" "strings" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/log" diff --git a/pkg/modules/background/background.go b/pkg/modules/background/background.go index da8ea5298..a698b7819 100644 --- a/pkg/modules/background/background.go +++ b/pkg/modules/background/background.go @@ -18,7 +18,7 @@ package background import ( "code.vikunja.io/api/pkg/models" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "xorm.io/xorm" ) diff --git a/pkg/modules/background/handler/background.go b/pkg/modules/background/handler/background.go index 23091f058..7d2950a50 100644 --- a/pkg/modules/background/handler/background.go +++ b/pkg/modules/background/handler/background.go @@ -42,8 +42,8 @@ import ( "code.vikunja.io/api/pkg/modules/background" "code.vikunja.io/api/pkg/modules/background/unsplash" "code.vikunja.io/api/pkg/modules/background/upload" - "code.vikunja.io/web" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web" + "code.vikunja.io/api/pkg/web/handler" "github.com/bbrks/go-blurhash" "github.com/gabriel-vasile/mimetype" diff --git a/pkg/modules/background/unsplash/proxy.go b/pkg/modules/background/unsplash/proxy.go index 6b08251ec..7f0232a55 100644 --- a/pkg/modules/background/unsplash/proxy.go +++ b/pkg/modules/background/unsplash/proxy.go @@ -21,7 +21,7 @@ import ( "net/http" "strings" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/modules/background/unsplash/unsplash.go b/pkg/modules/background/unsplash/unsplash.go index 902c4997b..7a72aea9b 100644 --- a/pkg/modules/background/unsplash/unsplash.go +++ b/pkg/modules/background/unsplash/unsplash.go @@ -34,7 +34,7 @@ import ( "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/modules/background" "code.vikunja.io/api/pkg/modules/keyvalue" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" ) const ( diff --git a/pkg/modules/background/upload/upload.go b/pkg/modules/background/upload/upload.go index e202d1de2..d2b98d289 100644 --- a/pkg/modules/background/upload/upload.go +++ b/pkg/modules/background/upload/upload.go @@ -24,7 +24,7 @@ import ( "code.vikunja.io/api/pkg/files" "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/modules/background" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" ) // Provider represents an upload provider diff --git a/pkg/modules/migration/handler/common.go b/pkg/modules/migration/handler/common.go index ce6078c85..222a5f826 100644 --- a/pkg/modules/migration/handler/common.go +++ b/pkg/modules/migration/handler/common.go @@ -21,7 +21,7 @@ import ( "code.vikunja.io/api/pkg/modules/migration" user2 "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/modules/migration/handler/handler.go b/pkg/modules/migration/handler/handler.go index e0ab939b1..1e054738e 100644 --- a/pkg/modules/migration/handler/handler.go +++ b/pkg/modules/migration/handler/handler.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/modules/migration" user2 "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/modules/migration/handler/handler_file.go b/pkg/modules/migration/handler/handler_file.go index 3f5790d99..541102366 100644 --- a/pkg/modules/migration/handler/handler_file.go +++ b/pkg/modules/migration/handler/handler_file.go @@ -22,7 +22,7 @@ import ( "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/modules/migration" user2 "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/avatar.go b/pkg/routes/api/v1/avatar.go index d64303b2f..e70e099e2 100644 --- a/pkg/routes/api/v1/avatar.go +++ b/pkg/routes/api/v1/avatar.go @@ -29,7 +29,7 @@ import ( "code.vikunja.io/api/pkg/modules/avatar/marble" "code.vikunja.io/api/pkg/modules/avatar/upload" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "bytes" "image" diff --git a/pkg/routes/api/v1/link_sharing_auth.go b/pkg/routes/api/v1/link_sharing_auth.go index f08d9f08e..484987663 100644 --- a/pkg/routes/api/v1/link_sharing_auth.go +++ b/pkg/routes/api/v1/link_sharing_auth.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/modules/auth" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/login.go b/pkg/routes/api/v1/login.go index bc722b177..3b27095ea 100644 --- a/pkg/routes/api/v1/login.go +++ b/pkg/routes/api/v1/login.go @@ -25,7 +25,7 @@ import ( "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/modules/auth" user2 "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/golang-jwt/jwt/v5" "github.com/labstack/echo/v4" diff --git a/pkg/routes/api/v1/task_attachment.go b/pkg/routes/api/v1/task_attachment.go index cae3a4f5d..61a929633 100644 --- a/pkg/routes/api/v1/task_attachment.go +++ b/pkg/routes/api/v1/task_attachment.go @@ -23,7 +23,8 @@ import ( "code.vikunja.io/api/pkg/models" auth2 "code.vikunja.io/api/pkg/modules/auth" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" + "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/user_caldav_token.go b/pkg/routes/api/v1/user_caldav_token.go index e6a878610..bf751c57a 100644 --- a/pkg/routes/api/v1/user_caldav_token.go +++ b/pkg/routes/api/v1/user_caldav_token.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/user_confirm_email.go b/pkg/routes/api/v1/user_confirm_email.go index 79187a17b..645366615 100644 --- a/pkg/routes/api/v1/user_confirm_email.go +++ b/pkg/routes/api/v1/user_confirm_email.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/user_deletion.go b/pkg/routes/api/v1/user_deletion.go index bdf6dcf1b..311507112 100644 --- a/pkg/routes/api/v1/user_deletion.go +++ b/pkg/routes/api/v1/user_deletion.go @@ -22,7 +22,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/user_export.go b/pkg/routes/api/v1/user_export.go index 048e9c46f..a356ee7c0 100644 --- a/pkg/routes/api/v1/user_export.go +++ b/pkg/routes/api/v1/user_export.go @@ -24,7 +24,7 @@ import ( "code.vikunja.io/api/pkg/files" "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" "xorm.io/xorm" ) diff --git a/pkg/routes/api/v1/user_list.go b/pkg/routes/api/v1/user_list.go index 97b769d3c..8296c3537 100644 --- a/pkg/routes/api/v1/user_list.go +++ b/pkg/routes/api/v1/user_list.go @@ -25,7 +25,7 @@ import ( "code.vikunja.io/api/pkg/models" auth2 "code.vikunja.io/api/pkg/modules/auth" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/user_password_reset.go b/pkg/routes/api/v1/user_password_reset.go index 9edc9b54b..597460364 100644 --- a/pkg/routes/api/v1/user_password_reset.go +++ b/pkg/routes/api/v1/user_password_reset.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/user_register.go b/pkg/routes/api/v1/user_register.go index 33a3d927c..5146f43f9 100644 --- a/pkg/routes/api/v1/user_register.go +++ b/pkg/routes/api/v1/user_register.go @@ -25,7 +25,7 @@ import ( "code.vikunja.io/api/pkg/config" "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/user_settings.go b/pkg/routes/api/v1/user_settings.go index e628aaf5e..137d53b51 100644 --- a/pkg/routes/api/v1/user_settings.go +++ b/pkg/routes/api/v1/user_settings.go @@ -27,7 +27,7 @@ import ( "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/models" user2 "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" ) // UserAvatarProvider holds the user avatar provider type diff --git a/pkg/routes/api/v1/user_show.go b/pkg/routes/api/v1/user_show.go index 7215780c0..633d39670 100644 --- a/pkg/routes/api/v1/user_show.go +++ b/pkg/routes/api/v1/user_show.go @@ -27,7 +27,7 @@ import ( "code.vikunja.io/api/pkg/db" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/user_totp.go b/pkg/routes/api/v1/user_totp.go index 1de45802a..d7ac193b9 100644 --- a/pkg/routes/api/v1/user_totp.go +++ b/pkg/routes/api/v1/user_totp.go @@ -28,7 +28,7 @@ import ( "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/user_update_email.go b/pkg/routes/api/v1/user_update_email.go index 9c557a856..121189ec3 100644 --- a/pkg/routes/api/v1/user_update_email.go +++ b/pkg/routes/api/v1/user_update_email.go @@ -26,7 +26,7 @@ import ( "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/api/v1/user_update_password.go b/pkg/routes/api/v1/user_update_password.go index fdf464baa..9ec18aa3d 100644 --- a/pkg/routes/api/v1/user_update_password.go +++ b/pkg/routes/api/v1/user_update_password.go @@ -23,7 +23,7 @@ import ( "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" ) diff --git a/pkg/routes/caldav/handler.go b/pkg/routes/caldav/handler.go index c1dbb81a8..05dd69332 100644 --- a/pkg/routes/caldav/handler.go +++ b/pkg/routes/caldav/handler.go @@ -28,7 +28,7 @@ import ( "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web/handler" "github.com/labstack/echo/v4" "github.com/samedi/caldav-go" "github.com/samedi/caldav-go/lib" diff --git a/pkg/routes/caldav/listStorageProvider.go b/pkg/routes/caldav/listStorageProvider.go index d11e8b885..aa8113cb5 100644 --- a/pkg/routes/caldav/listStorageProvider.go +++ b/pkg/routes/caldav/listStorageProvider.go @@ -27,7 +27,7 @@ import ( "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/models" user2 "code.vikunja.io/api/pkg/user" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "github.com/samedi/caldav-go/data" "github.com/samedi/caldav-go/errs" "xorm.io/xorm" diff --git a/pkg/routes/routes.go b/pkg/routes/routes.go index 26552986b..7f6c77a86 100644 --- a/pkg/routes/routes.go +++ b/pkg/routes/routes.go @@ -77,8 +77,8 @@ import ( apiv1 "code.vikunja.io/api/pkg/routes/api/v1" "code.vikunja.io/api/pkg/routes/caldav" "code.vikunja.io/api/pkg/version" - "code.vikunja.io/web" - "code.vikunja.io/web/handler" + "code.vikunja.io/api/pkg/web" + "code.vikunja.io/api/pkg/web/handler" "github.com/getsentry/sentry-go" sentryecho "github.com/getsentry/sentry-go/echo" diff --git a/pkg/user/error.go b/pkg/user/error.go index 26deaa4cb..750a1bcc7 100644 --- a/pkg/user/error.go +++ b/pkg/user/error.go @@ -20,7 +20,7 @@ import ( "fmt" "net/http" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" ) // ===================== diff --git a/pkg/user/user.go b/pkg/user/user.go index 6feb6ad23..6f9cfe4d7 100644 --- a/pkg/user/user.go +++ b/pkg/user/user.go @@ -30,7 +30,7 @@ import ( "code.vikunja.io/api/pkg/modules/keyvalue" "code.vikunja.io/api/pkg/notifications" - "code.vikunja.io/web" + "code.vikunja.io/api/pkg/web" "github.com/golang-jwt/jwt/v5" "github.com/labstack/echo/v4" "golang.org/x/crypto/bcrypt" diff --git a/pkg/web/handler/config.go b/pkg/web/handler/config.go new file mode 100644 index 000000000..85ab90d09 --- /dev/null +++ b/pkg/web/handler/config.go @@ -0,0 +1,57 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public Licensee 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 Licensee for more details. +// +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . + +package handler + +import ( + "code.vikunja.io/api/pkg/web" + "github.com/op/go-logging" + "xorm.io/xorm" +) + +// Config contains the config for the web handler +type Config struct { + AuthProvider *web.Auths + LoggingProvider *logging.Logger + MaxItemsPerPage int + SessionFactory func() *xorm.Session +} + +var config *Config + +func init() { + config = &Config{} +} + +// SetAuthProvider sets the auth provider in config +func SetAuthProvider(provider *web.Auths) { + config.AuthProvider = provider +} + +// SetLoggingProvider sets the logging provider in the config +func SetLoggingProvider(logger *logging.Logger) { + config.LoggingProvider = logger +} + +// SetMaxItemsPerPage sets the max number of items per page in the config +func SetMaxItemsPerPage(maxItemsPerPage int) { + config.MaxItemsPerPage = maxItemsPerPage +} + +// SetSessionFactory sets the session factory +func SetSessionFactory(sessionFactory func() *xorm.Session) { + config.SessionFactory = sessionFactory +} diff --git a/pkg/web/handler/create.go b/pkg/web/handler/create.go new file mode 100644 index 000000000..5af1cac08 --- /dev/null +++ b/pkg/web/handler/create.go @@ -0,0 +1,89 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public Licensee 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 Licensee for more details. +// +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . + +package handler + +import ( + "fmt" + "net/http" + + "github.com/labstack/echo/v4" +) + +// CreateWeb is the handler to create an object +func (c *WebHandler) CreateWeb(ctx echo.Context) error { + // Get our model + currentStruct := c.EmptyStruct() + + // Get the object & bind params to struct + if err := ctx.Bind(currentStruct); err != nil { + config.LoggingProvider.Debugf("Invalid model error. Internal error was: %s", err.Error()) + if he, is := err.(*echo.HTTPError); is { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided. Error was: %s", he.Message)) + } + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided.")) + } + + // Validate the struct + if err := ctx.Validate(currentStruct); err != nil { + return echo.NewHTTPError(http.StatusBadRequest, err) + } + + // Get the user to pass for later checks + currentAuth, err := config.AuthProvider.AuthObject(ctx) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, "Could not determine the current user.") + } + + // Create the db session + s := config.SessionFactory() + defer func() { + err = s.Close() + if err != nil { + config.LoggingProvider.Errorf("Could not close session: %s", err) + } + }() + + // Check rights + canCreate, err := currentStruct.CanCreate(s, currentAuth) + if err != nil { + _ = s.Rollback() + return HandleHTTPError(err, ctx) + } + if !canCreate { + _ = s.Rollback() + config.LoggingProvider.Noticef("Tried to create while not having the rights for it (User: %v)", currentAuth) + return echo.NewHTTPError(http.StatusForbidden) + } + + // Create + err = currentStruct.Create(s, currentAuth) + if err != nil { + _ = s.Rollback() + return HandleHTTPError(err, ctx) + } + + err = s.Commit() + if err != nil { + return HandleHTTPError(err, ctx) + } + + err = ctx.JSON(http.StatusCreated, currentStruct) + if err != nil { + return HandleHTTPError(err, ctx) + } + return err +} diff --git a/pkg/web/handler/delete.go b/pkg/web/handler/delete.go new file mode 100644 index 000000000..d76bea2dc --- /dev/null +++ b/pkg/web/handler/delete.go @@ -0,0 +1,87 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public Licensee 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 Licensee for more details. +// +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . + +package handler + +import ( + "fmt" + "net/http" + + "github.com/labstack/echo/v4" +) + +type message struct { + Message string `json:"message"` +} + +// DeleteWeb is the web handler to delete something +func (c *WebHandler) DeleteWeb(ctx echo.Context) error { + + // Get our model + currentStruct := c.EmptyStruct() + + // Bind params to struct + if err := ctx.Bind(currentStruct); err != nil { + config.LoggingProvider.Debugf("Invalid model error. Internal error was: %s", err.Error()) + if he, is := err.(*echo.HTTPError); is { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided. Error was: %s", he.Message)) + } + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided.")) + } + + // Check if the user has the right to delete + currentAuth, err := config.AuthProvider.AuthObject(ctx) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError) + } + + // Create the db session + s := config.SessionFactory() + defer func() { + err = s.Close() + if err != nil { + config.LoggingProvider.Errorf("Could not close session: %s", err) + } + }() + + canDelete, err := currentStruct.CanDelete(s, currentAuth) + if err != nil { + _ = s.Rollback() + return HandleHTTPError(err, ctx) + } + if !canDelete { + _ = s.Rollback() + config.LoggingProvider.Noticef("Tried to delete while not having the rights for it (User: %v)", currentAuth) + return echo.NewHTTPError(http.StatusForbidden) + } + + err = currentStruct.Delete(s, currentAuth) + if err != nil { + _ = s.Rollback() + return HandleHTTPError(err, ctx) + } + + err = s.Commit() + if err != nil { + return HandleHTTPError(err, ctx) + } + + err = ctx.JSON(http.StatusOK, message{"Successfully deleted."}) + if err != nil { + return HandleHTTPError(err, ctx) + } + return err +} diff --git a/pkg/web/handler/helper.go b/pkg/web/handler/helper.go new file mode 100644 index 000000000..0d009e3a4 --- /dev/null +++ b/pkg/web/handler/helper.go @@ -0,0 +1,46 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public Licensee 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 Licensee for more details. +// +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . + +package handler + +import ( + "net/http" + + "code.vikunja.io/api/pkg/web" + "github.com/labstack/echo/v4" +) + +// WebHandler defines the webhandler object +// This does web stuff, aka returns json etc. Uses CRUDable Methods to get the data +type WebHandler struct { + EmptyStruct func() CObject +} + +// CObject is the definition of our object, holds the structs +type CObject interface { + web.CRUDable + web.Rights +} + +// HandleHTTPError does what it says +func HandleHTTPError(err error, ctx echo.Context) *echo.HTTPError { + config.LoggingProvider.Error(err.Error()) + if a, has := err.(web.HTTPErrorProcessor); has { + errDetails := a.HTTPError() + return echo.NewHTTPError(errDetails.HTTPCode, errDetails) + } + return echo.NewHTTPError(http.StatusInternalServerError) +} diff --git a/pkg/web/handler/read_all.go b/pkg/web/handler/read_all.go new file mode 100644 index 000000000..c09ce3c63 --- /dev/null +++ b/pkg/web/handler/read_all.go @@ -0,0 +1,129 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public Licensee 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 Licensee for more details. +// +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . + +package handler + +import ( + "fmt" + "math" + "net/http" + "strconv" + + "github.com/labstack/echo/v4" +) + +// ReadAllWeb is the webhandler to get all objects of a type +func (c *WebHandler) ReadAllWeb(ctx echo.Context) error { + // Get our model + currentStruct := c.EmptyStruct() + + currentAuth, err := config.AuthProvider.AuthObject(ctx) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, "Could not determine the current user.") + } + + // Get the object & bind params to struct + if err := ctx.Bind(currentStruct); err != nil { + config.LoggingProvider.Debugf("Invalid model error. Internal error was: %s", err.Error()) + if he, is := err.(*echo.HTTPError); is { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided. Error was: %s", he.Message)) + } + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided.")) + } + + // Pagination + page := ctx.QueryParam("page") + if page == "" { + page = "1" + } + pageNumber, err := strconv.Atoi(page) + if err != nil { + config.LoggingProvider.Error(err.Error()) + return echo.NewHTTPError(http.StatusBadRequest, "Bad page requested.") + } + if pageNumber < 0 { + return echo.NewHTTPError(http.StatusBadRequest, "Page number cannot be negative.") + } + + // Items per page + var perPageNumber int + perPage := ctx.QueryParam("per_page") + // If we dont have an "items per page" parameter, we want to use the default. + // To prevent Atoi from failing, we check this here. + if perPage != "" { + perPageNumber, err = strconv.Atoi(perPage) + if err != nil { + config.LoggingProvider.Error(err.Error()) + return echo.NewHTTPError(http.StatusBadRequest, "Bad per page amount requested.") + } + } + // Set default page count + if perPageNumber == 0 { + perPageNumber = config.MaxItemsPerPage + } + if perPageNumber < 1 { + return echo.NewHTTPError(http.StatusBadRequest, "Per page amount cannot be negative.") + } + if perPageNumber > config.MaxItemsPerPage { + perPageNumber = config.MaxItemsPerPage + } + + // Create the db session + s := config.SessionFactory() + defer func() { + err = s.Close() + if err != nil { + config.LoggingProvider.Errorf("Could not close session: %s", err) + } + }() + + // Search + search := ctx.QueryParam("s") + + result, resultCount, numberOfItems, err := currentStruct.ReadAll(s, currentAuth, search, pageNumber, perPageNumber) + if err != nil { + _ = s.Rollback() + return HandleHTTPError(err, ctx) + } + + // Calculate the number of pages from the number of items + // We always round up, because if we don't have a number of items which is exactly dividable by the number of items per page, + // we would get a result that is one page off. + var numberOfPages = math.Ceil(float64(numberOfItems) / float64(perPageNumber)) + // If we return all results, we only have one page + if pageNumber < 0 { + numberOfPages = 1 + } + // If we don't have results, we don't have a page + if resultCount == 0 { + numberOfPages = 0 + } + + ctx.Response().Header().Set("x-pagination-total-pages", strconv.FormatFloat(numberOfPages, 'f', 0, 64)) + ctx.Response().Header().Set("x-pagination-result-count", strconv.FormatInt(int64(resultCount), 10)) + ctx.Response().Header().Set("Access-Control-Expose-Headers", "x-pagination-total-pages, x-pagination-result-count") + + err = s.Commit() + if err != nil { + return HandleHTTPError(err, ctx) + } + + err = ctx.JSON(http.StatusOK, result) + if err != nil { + return HandleHTTPError(err, ctx) + } + return err +} diff --git a/pkg/web/handler/read_one.go b/pkg/web/handler/read_one.go new file mode 100644 index 000000000..4826d37ff --- /dev/null +++ b/pkg/web/handler/read_one.go @@ -0,0 +1,90 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public Licensee 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 Licensee for more details. +// +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . + +package handler + +import ( + "fmt" + "net/http" + "strconv" + + "github.com/labstack/echo/v4" +) + +// ReadOneWeb is the webhandler to get one object +func (c *WebHandler) ReadOneWeb(ctx echo.Context) error { + // Get our model + currentStruct := c.EmptyStruct() + + // Get the object & bind params to struct + if err := ctx.Bind(currentStruct); err != nil { + config.LoggingProvider.Debugf("Invalid model error. Internal error was: %s", err.Error()) + if he, is := err.(*echo.HTTPError); is { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided. Error was: %s", he.Message)) + } + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided.")) + } + + // Check rights + currentAuth, err := config.AuthProvider.AuthObject(ctx) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, "Could not determine the current user.") + } + + // Create the db session + s := config.SessionFactory() + defer func() { + err = s.Close() + if err != nil { + config.LoggingProvider.Errorf("Could not close session: %s", err) + } + }() + + canRead, maxRight, err := currentStruct.CanRead(s, currentAuth) + if err != nil { + _ = s.Rollback() + return HandleHTTPError(err, ctx) + } + if !canRead { + _ = s.Rollback() + config.LoggingProvider.Noticef("Tried to read while not having the rights for it (User: %v)", currentAuth) + return echo.NewHTTPError(http.StatusForbidden, "You don't have the right to see this") + } + + // Get our object + err = currentStruct.ReadOne(s, currentAuth) + if err != nil { + _ = s.Rollback() + return HandleHTTPError(err, ctx) + } + + // Set the headers + if canRead { + ctx.Response().Header().Set("x-max-right", strconv.FormatInt(int64(maxRight), 10)) + ctx.Response().Header().Set("Access-Control-Expose-Headers", "x-max-right") + } + + err = s.Commit() + if err != nil { + return HandleHTTPError(err, ctx) + } + + err = ctx.JSON(http.StatusOK, currentStruct) + if err != nil { + return HandleHTTPError(err, ctx) + } + return err +} diff --git a/pkg/web/handler/update.go b/pkg/web/handler/update.go new file mode 100644 index 000000000..fa9ef835a --- /dev/null +++ b/pkg/web/handler/update.go @@ -0,0 +1,89 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public Licensee 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 Licensee for more details. +// +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . + +package handler + +import ( + "fmt" + "net/http" + + "github.com/labstack/echo/v4" +) + +// UpdateWeb is the webhandler to update an object +func (c *WebHandler) UpdateWeb(ctx echo.Context) error { + + // Get our model + currentStruct := c.EmptyStruct() + + // Get the object & bind params to struct + if err := ctx.Bind(currentStruct); err != nil { + config.LoggingProvider.Debugf("Invalid model error. Internal error was: %s", err.Error()) + if he, is := err.(*echo.HTTPError); is { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided. Error was: %s", he.Message)) + } + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided.")) + } + + // Validate the struct + if err := ctx.Validate(currentStruct); err != nil { + return echo.NewHTTPError(http.StatusBadRequest, err) + } + + // Check if the user has the right to do that + currentAuth, err := config.AuthProvider.AuthObject(ctx) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, "Could not determine the current user.") + } + + // Create the db session + s := config.SessionFactory() + defer func() { + err = s.Close() + if err != nil { + config.LoggingProvider.Errorf("Could not close session: %s", err) + } + }() + + canUpdate, err := currentStruct.CanUpdate(s, currentAuth) + if err != nil { + _ = s.Rollback() + return HandleHTTPError(err, ctx) + } + if !canUpdate { + _ = s.Rollback() + config.LoggingProvider.Noticef("Tried to update while not having the rights for it (User: %v)", currentAuth) + return echo.NewHTTPError(http.StatusForbidden) + } + + // Do the update + err = currentStruct.Update(s, currentAuth) + if err != nil { + _ = s.Rollback() + return HandleHTTPError(err, ctx) + } + + err = s.Commit() + if err != nil { + return HandleHTTPError(err, ctx) + } + + err = ctx.JSON(http.StatusOK, currentStruct) + if err != nil { + return HandleHTTPError(err, ctx) + } + return err +} diff --git a/pkg/web/readme.md b/pkg/web/readme.md new file mode 100644 index 000000000..85733266d --- /dev/null +++ b/pkg/web/readme.md @@ -0,0 +1,253 @@ +# Vikunja Web Handler + +[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](LICENSE) +[![Go Report Card](https://goreportcard.com/badge/code.vikunja.io/web)](https://goreportcard.com/report/code.vikunja.io/web) + +> When I started Vikunja, I started like everyone else, by writing a bunch of functions to do the logic and then a bunch of +handler functions to parse the request data and call the implemented functions to do the logic and eventually return a dataset. +After I implemented some functions, I've decided to save me a lot of hassle and put most of that "parse the request and call a +processing function"-logic to a general interface to facilitate development and not having to have a lot of similar code all over the place. + +This webhandler was built to be used in a REST-API, it takes and returns JSON, but can also be used in combination with own +other handler implementations, enabling a lot of flexibility while develeoping. + +## Features + +* Easy to use +* Built for REST-APIs +* Beautiful error handling built in +* Manages rights +* Pluggable authentication mechanisms + +## Table of contents + +* [Installation](#installation) +* [Todos](#todos) +* [DB Sessions](#db-sessions) +* [CRUDable](#crudable) +* [Rights](#rights) +* [Handler Config](#handler-config) + * [Auth](#auth) + * [Logging](#logging) + * [Full Example](#full-example) +* [Preprocessing](#preprocessing) + * [Pagination](#pagination) + * [Search](#search) +* [Standard web handler](#defining-routes-using-the-standard-web-handler) +* [Errors](#errors) +* [URL param binder](#how-the-url-param-binder-works) + +### TODOs + +* [x] Improve docs/Merge with the ones of Vikunja +* [x] Description of web.HTTPError +* [x] Rights methods should return errors (I know, this will break a lot of existing stuff) +* [ ] optional Before- and after-{load|update|create} methods which do some preprocessing/after processing like making human-readable names from automatically up counting consts +* [ ] "Magic": Check if a passed struct implements Crudable methods and use a general (user defined) function if not + +## Installation + +Using the web handler in your application is pretty straight forward, simply run `go get -u code.vikunja.io/web` and start using it. + +In order to use the common web handler, the struct must implement the `web.CRUDable` and `web.Rights` interface. + +To learn how to use the handler, take a look at the [handler config](#handler-config) [defining routes](#defining-routes-using-the-standard-web-handler) + +## DB Sessions + +Each request runs in its own db session. +This ensures each operation is one atomic entity without any side effects for concurrent requests happening at the same time. + +The session is started at the beginning of the request, rolled back in case of any errors and comitted if no errors occur. +The rights methods get the same session (for the same request) as the actual crud methods. + +See [`SessionFactory`](#sessionfactory) for docs about how to configure it. + +## CRUDable + +This interface defines methods to Create/Read/ReadAll/Update/Delete something. It is defined as followed: + +```go +type CRUDable interface { + Create(*xorm.Session, Auth) error + ReadOne(*xorm.Session, Auth) error + ReadAll(s *xorm.Session, auth Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) + Update(*xorm.Session, Auth) error + Delete(*xorm.Session, Auth) error +} +``` + +Each of these methods gets called on an instance of a struct like so: + +```go +func (l *List) ReadOne() (err error) { + *l, err = GetListByID(l.ID) + return +} +``` + +In that case, it takes the `ID` saved in the struct instance, gets the full list object and fills the original object with it. +(See [parambinder](#how-the-url-param-binder-works) to understand where that `ID` is coming from in that specific case). + +All functions should behave like this, if they create or update something, the struct instance they are called on should +contain the created/updated struct instance. The only exception is `ReadAll()` which returns an interface. +Usually this method returns a slice of results because you cannot make an array of a set type (If you know a +way to do this, don't hesitate to [drop me a message](https://vikunja.io/en/contact/)). + +## Rights + +This interface defines methods to check for rights on structs. They accept an `Auth`-element as parameter and return a `bool` and `error`. + +The `error` is handled [as usual](#errors). + +The interface is defined as followed: + +```go +type Rights interface { + CanRead(*xorm.Session, Auth) (bool, int, error) // The int is the max right the user has for this entity. + CanDelete(*xorm.Session, Auth) (bool, error) + CanUpdate(*xorm.Session, Auth) (bool, error) + CanCreate(*xorm.Session, Auth) (bool, error) +} +``` + +When using the standard web handler, all methods are called before their `CRUD` counterparts. +Use pointers for methods like `CanRead()` to get the base data of the model first, then check the right and then add addintional data. + +The `CanRead` method should also return the max right a user has on this entity. +This number will be returned in the`x-max-right` header to enable user interfaces to show/hide ui elements based on the right the user has. + +## Handler Config + +The handler has some options which you can (and need to) configure. + +#### Auth + +`Auth` is an interface with some methods to decouple the action of getting the current user from the web handler. +The function defined via `Auths` should return a struct which implements the `Auth` interface. + +To define the thing which gets the appropriate auth object, you need to call a middleware like so (After all auth middlewares were called): + +#### Logging + +You can provide your own instance of `logger.Logger` (using [go-logging](https://github.com/op/go-logging)) to the handler. +It will use this instance to log errors which are not better specified or things like users trying to do something they're +not allowed to do and so on. + +#### MaxItemsPerPage + +Contains the maximum number of items per page. +If the client requests more items than this, the number of items requested is set to this value. + +See [pagination](#pagination) for more. + +#### SessionFactory + +To create a new session for each request, you need to call the `SetSessionFactory` method before any web request. +It has the following signature: + +```go +func SetSessionFactory(sessionFactory func() *xorm.Session) +``` + +The closure will be called for every request. + +#### Full Example + +```go +handler.SetAuthProvider(&web.Auths{ + AuthObject: func(echo.Context) (web.Auth, error) { + return models.GetCurrentUser(c) // Your functions + }, +}) +handler.SetLoggingProvider(&log.Log) +handler.SetSessionFactory(x.NewSession) +``` + +## Preprocessing + +### Pagination + +The `ReadAll`-method has a number of parameters: + +```go +ReadAll(auth Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfItems int64, err error) +``` + +The third parameter contains the requested page, the fourth parameter contains the number of items per page. +You should calculate the limits accordingly. + +If the number of items per page are not set by the client, the web handler will pass the maximum number of items per page instead. +This makes items per page optional for clients. +Take a look at [the config section](#handler-config) for information on how to set that value. + +You need to return a number of things: + +* The result itself, usually a slice +* The number of items you return in `result`. Most of the time, this is just `len(result)`. You need to return this value to make the clients aware if they requested a number of items > max items per page. +* The total number of items available. We use the total number of items here and not the number pages so the implementations don't have to deal with calculating the number of pages from that. The total number of clients is then calculated and returned to the client, ite can then be used by the clients to build client-side pagination or similar. +* An error. + +The number of items and the total number of pages available will be returned in the `x-pagination-total-pages` and `x-pagination-result-count` response headers. +_You should put this in your api documentation._ + +### Search + +When using the `ReadAll`-method, the first parameter is a search term which should be used to search items of your struct. +You define the critera inside of that function. + +Users can then pass the `?s=something` parameter to the url to search, _thats something you should put in your api documentation_. + +As the logic for "give me everything" and "give me everything where the name contains 'something'" is mostly the same, we made +the decision to design the function like this, in order to keep the places with mostly the same logic as few as possible. +Also just adding `?s=query` to the url one already knows and uses is a lot more convenient. + +## Defining routes using the standard web handler + +You can define routes for the standard web handler like so: + +`models.List` needs to implement `web.CRUDable` and `web.Rights`. + +```go +listHandler := &crud.WebHandler{ + EmptyStruct: func() crud.CObject { + return &models.List{} + }, +} +a.GET("/lists", listHandler.ReadAllWeb) +a.GET("/lists/:list", listHandler.ReadOneWeb) +a.POST("/lists/:list", listHandler.UpdateWeb) +a.DELETE("/lists/:list", listHandler.DeleteWeb) +a.PUT("/namespaces/:namespace/lists", listHandler.CreateWeb) +``` + +The handler will take care of everything like parsing the request, checking rights, pretty-print errors and return appropriate responses. + +## Errors + +Error types with their messages and http-codes should be implemented by you somewhere in your application and then returned by +the appropriate function when an error occures. If the error type implements `HTTPError`, the server returns a user-friendly +error message when this error occours. This means it returns a good HTTP status code, a message, and an error code. The error +code should be unique across all error codes and can be used on the client to show a localized error message or do other stuff +based on the exact error the server returns. That way the client won't have to "guess" that the error message remains the same +over multiple versions of your application. + +An `HTTPError` is defined as follows: + +```go +type HTTPError struct { + HTTPCode int `json:"-"` // Can be any valid HTTP status code, I'd reccomend to use the constants of the http package. + Code int `json:"code"` // Must be a uniqe int identifier for this specific error. I'd reccomend defining a constant for this. + Message string `json:"message"` // A user-readable message what went wrong. +} +``` + +You can learn more about how exactly custom error types are created in the [vikunja docs](https://vikunja.io/docs/custom-errors/). + +## How the url param binder works + +The binder binds all values inside the url to their respective fields in a struct. Those fields need to have a tag +`param` with the name of the url placeholder which must be the same as in routes. + +Whenever one of the standard CRUD methods is invoked, this binder is called, which enables one handler method +to handle all kinds of different urls with different parameters. diff --git a/pkg/web/web.go b/pkg/web/web.go new file mode 100644 index 000000000..e00bbbcd6 --- /dev/null +++ b/pkg/web/web.go @@ -0,0 +1,67 @@ +// Vikunja is a to-do list application to facilitate your life. +// Copyright 2018-present Vikunja and contributors. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public Licensee 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 Licensee for more details. +// +// You should have received a copy of the GNU Affero General Public Licensee +// along with this program. If not, see . + +package web + +import ( + "github.com/labstack/echo/v4" + "xorm.io/xorm" +) + +// Rights defines rights methods +type Rights interface { + CanRead(*xorm.Session, Auth) (bool, int, error) + CanDelete(*xorm.Session, Auth) (bool, error) + CanUpdate(*xorm.Session, Auth) (bool, error) + CanCreate(*xorm.Session, Auth) (bool, error) +} + +// CRUDable defines the crud methods +type CRUDable interface { + Create(*xorm.Session, Auth) error + ReadOne(*xorm.Session, Auth) error + ReadAll(s *xorm.Session, auth Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) + Update(*xorm.Session, Auth) error + Delete(*xorm.Session, Auth) error +} + +// HTTPErrorProcessor is executed when the defined error is thrown, it will make sure the user sees an appropriate error message and http status code +type HTTPErrorProcessor interface { + HTTPError() HTTPError +} + +// HTTPError holds informations about an http error +type HTTPError struct { + HTTPCode int `json:"-"` + Code int `json:"code"` + Message string `json:"message"` +} + +// Auth defines the authentication interface used to get some auth thing +type Auth interface { + // Most of the time, we need an ID from the auth object only. Having this method saves the need to cast it. + GetID() int64 +} + +// Authprovider is a holder for the implementation of an authprovider by the application +type Authprovider interface { + GetAuthObject(echo.Context) (Auth, error) +} + +// Auths holds the authobject +type Auths struct { + AuthObject func(echo.Context) (Auth, error) +}