diff --git a/Dockerfile b/Dockerfile index a786563fccaf88d0fd482e5af58f3241007e5ad5..e0fae0e76ab70e48b2054e92e2f2c7f08b91cc0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ -FROM nextcloud:20.0.12-fpm +FROM nextcloud:20.0.12-fpm as base ARG BASE_DIR="/usr/src/nextcloud" -ARG TMP_PATCH_DIR="/tmp/build_patches" -ARG THEME_VERSION="20.1.2" +ARG THEME_VERSION="20.1.3" ARG THEME_HELPER_VERSION="1.0.1" ARG NEWS_VERSION="16.0.1" ARG QUOTA_WARN_VERSION="1.9.1" @@ -17,10 +16,9 @@ ARG ECLOUD_LAUNCHER_JOB_ID="204816" ARG GOOGLE_INTEGRATION_VERSION="1.0.5-1-nightly" RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images -COPY patches/ ${TMP_PATCH_DIR}/ COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh -RUN sed -i 's/20,0,12,1/20,0,12,14/' ${BASE_DIR}/version.php +RUN sed -i 's/20,0,12,1/20,0,12,17/' ${BASE_DIR}/version.php # Install unzip for unzipping artifacts RUN apt-get update && apt-get install unzip @@ -101,44 +99,70 @@ RUN sed -i "s/\$systemConfig->setValue('theme', '');/\$systemConfig->setValue('t # fix min version of google data migration app RUN sed -i "s/min-version=\"22\"/min-version=\"20\"/" ${BASE_DIR}/custom_apps/integration_google/appinfo/info.xml +# Remove colored background from email template logo +RUN sed -i 's/$this->header, \[$this->themingDefaults->getColorPrimary()/$this->header, \["none"/' ${BASE_DIR}/lib/private/Mail/EMailTemplate.php + +# Ignore OS dark mode for all users +# Don't use user-specific dark theme css for non-logged in users +RUN sed -i 's/OCA.Accessibility.theme="dark"/OCA.Accessibility.theme="light"/' ${BASE_DIR}/apps/accessibility/js/accessibilityoca.js +RUN sed -i "s/$userValues = \['dark'\]/$userValues = \[\]/" ${BASE_DIR}/apps/accessibility/lib/Controller/AccessibilityController.php + +# Custom theme +RUN curl -fsSL -o eCloud-theme.tar.gz \ + "https://gitlab.e.foundation/e/infra/nextcloud-theme/-/archive/${THEME_VERSION}/nextcloud-theme-${THEME_VERSION}.tar.gz" && \ + tar -xf eCloud-theme.tar.gz -C /tmp/ && \ + mv /tmp/nextcloud-theme-${THEME_VERSION}/ ${BASE_DIR}/themes/eCloud && \ + chown -R www-data:www-data ${BASE_DIR}/themes/eCloud/ && \ + rm -rf eCloud-theme.tar.gz ${BASE_DIR}/themes/example/ + +# Replace "Get your own free account" NC link with /e/ Account link in public pages +RUN sed -i 's/https:\/\/nextcloud.com\/signup\//https:\/\/e\.foundation\/\/e-email-invite\//' ${BASE_DIR}/core/templates/layout.public.php + +ENTRYPOINT ["/custom_entrypoint.sh"] +CMD ["php-fpm"] + + +FROM base as selfhost +ARG BASE_DIR="/usr/src/nextcloud" +ARG TMP_PATCH_DIR="/tmp/build_patches" + +COPY patches/ ${TMP_PATCH_DIR}/ + # Patches RUN patch -u ${BASE_DIR}/core/Controller/LoginController.php -i ${TMP_PATCH_DIR}/002-login-without-domain.patch -RUN patch -u ${BASE_DIR}/core/templates/layout.user.php -i ${TMP_PATCH_DIR}/003-contact-search-removal.patch -RUN patch -u ${BASE_DIR}/core/Controller/ContactsMenuController.php -i ${TMP_PATCH_DIR}/004-contact-search-controller-removal.patch -RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-core.patch -RUN cd ${BASE_DIR}/custom_apps && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-custom-app.patch RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/006-recovery-email-changes.patch RUN patch -u ${BASE_DIR}/apps/settings/lib/Settings/Personal/ServerDevNotice.php -i ${TMP_PATCH_DIR}/007-remove-dev-notice.patch RUN patch -u ${BASE_DIR}/lib/private/Template/IconsCacher.php -i ${TMP_PATCH_DIR}/008-icons-cacher-theme-svgs.patch RUN patch -u ${BASE_DIR}/core/Controller/SvgController.php -i ${TMP_PATCH_DIR}/008-svg-controller-theme-svgs.patch RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/009-help-links.patch -RUN patch -u ${BASE_DIR}/lib/private/Updater.php -i ${TMP_PATCH_DIR}/010-disable-app-store-upgrade.patch RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/011-privacy-settings.patch -RUN cd ${BASE_DIR} && patch -u ${BASE_DIR}/apps/dashboard/lib/Controller/DashboardController.php -i ${TMP_PATCH_DIR}/012-remove-user-status-widget.patch RUN rm -rf ${TMP_PATCH_DIR} +FROM selfhost as ecloud +ARG BASE_DIR="/usr/src/nextcloud" +ARG TMP_PATCH_DIR="/tmp/build_patches" + +COPY patches/ ${TMP_PATCH_DIR}/ + +# Privacy specific patches +RUN patch -u ${BASE_DIR}/core/templates/layout.user.php -i ${TMP_PATCH_DIR}/003-contact-search-removal.patch +RUN patch -u ${BASE_DIR}/core/Controller/ContactsMenuController.php -i ${TMP_PATCH_DIR}/004-contact-search-controller-removal.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-core.patch +RUN cd ${BASE_DIR}/custom_apps && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-custom-app.patch +RUN patch -u ${BASE_DIR}/lib/private/Updater.php -i ${TMP_PATCH_DIR}/010-disable-app-store-upgrade.patch +RUN cd ${BASE_DIR} && patch -u ${BASE_DIR}/apps/dashboard/lib/Controller/DashboardController.php -i ${TMP_PATCH_DIR}/012-remove-user-status-widget.patch + # autocomplete leak tweak apps frontend with sed, disable group suggestion RUN cd ${BASE_DIR}/custom_apps/contacts && sed -i 's/"GROUP","INDIVIDUAL"/"INDIVIDUAL"/g' js/contacts-main.js RUN cd ${BASE_DIR}/custom_apps/calendar && sed -i 's/"GROUP","INDIVIDUAL"/"INDIVIDUAL"/g' js/calendar.js RUN cd ${BASE_DIR}/custom_apps/calendar && sed -i 's/anyof/allof/g' js/calendar.js -# Set default widgets to calendar, tasks and notes -RUN sed -i 's/recommendations,spreed,mail,calendar/calendar,tasks,notes/' ${BASE_DIR}/apps/dashboard/lib/Controller/DashboardController.php - -# Remove colored background from email template logo -RUN sed -i 's/$this->header, \[$this->themingDefaults->getColorPrimary()/$this->header, \["none"/' ${BASE_DIR}/lib/private/Mail/EMailTemplate.php - -# Custom theme -RUN curl -fsSL -o eCloud-theme.tar.gz \ - "https://gitlab.e.foundation/e/infra/nextcloud-theme/-/archive/${THEME_VERSION}/nextcloud-theme-${THEME_VERSION}.tar.gz" && \ - tar -xf eCloud-theme.tar.gz -C /tmp/ && \ - mv /tmp/nextcloud-theme-${THEME_VERSION}/ ${BASE_DIR}/themes/eCloud && \ - chown -R www-data:www-data ${BASE_DIR}/themes/eCloud/ && \ - rm -rf eCloud-theme.tar.gz ${BASE_DIR}/themes/example/ +# UserConfigChangedEvent Ref: https://github.com/nextcloud/server/pull/42039 -# Replace "Get your own free account" NC link with /e/ Account link in public pages -RUN sed -i 's/https:\/\/nextcloud.com\/signup\//https:\/\/e\.foundation\/\/e-email-invite\//' ${BASE_DIR}/core/templates/layout.public.php +RUN cd ${BASE_DIR} && patch -p1 < ${TMP_PATCH_DIR}/035-user-config-change-event.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/036-user-config-changed-event-new-file.patch -ENTRYPOINT ["/custom_entrypoint.sh"] -CMD ["php-fpm"] +# Set default widgets to calendar, tasks and notes +RUN sed -i 's/recommendations,spreed,mail,calendar/calendar,tasks,notes/' ${BASE_DIR}/apps/dashboard/lib/Controller/DashboardController.php +RUN rm -rf ${TMP_PATCH_DIR} diff --git a/custom_entrypoint.sh b/custom_entrypoint.sh index 36dfb301e73e299cfb0b877fd29cc00c7ffdc4a0..6513df4226c0bf6ccb749ec22dc7c84510e412d3 100644 --- a/custom_entrypoint.sh +++ b/custom_entrypoint.sh @@ -29,6 +29,8 @@ if version_greater "$image_version" "$installed_version"; then rsync $rsync_options --include "/ecloud_drop_account/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ rsync $rsync_options --include "/ecloud-theme-helper/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ rsync $rsync_options --include "/ecloud-launcher/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + rsync $rsync_options --include "/integration_google/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + rsync $rsync_options --include "/eCloud/" --exclude '/*' $SRC_DIR/themes/ $DST_DIR/themes/ else diff --git a/patches/002-login-without-domain.patch b/patches/002-login-without-domain.patch index 6e6706286120b34c1605ae32aa7756ef61e0956a..477bd803faf56e1a062103e877598642d49cbe68 100644 --- a/patches/002-login-without-domain.patch +++ b/patches/002-login-without-domain.patch @@ -17,7 +17,7 @@ diff --git files/LoginController.php files/LoginController-new.php + $user = mb_strtolower($user, 'UTF-8'); + $domain = $this->config->getSystemValue("mail_domain"); + $domain_suffix = "@$domain"; -+ $admin_username = $_ENV["NEXTCLOUD_ADMIN_USER"]; ++ $admin_username = mb_strtolower($_ENV["NEXTCLOUD_ADMIN_USER"], 'UTF-8'); + if (stristr($user, $domain_suffix) === FALSE && strcmp($user, $admin_username) != 0) { + $user = $user . $domain_suffix; + } diff --git a/patches/035-user-config-change-event.patch b/patches/035-user-config-change-event.patch new file mode 100644 index 0000000000000000000000000000000000000000..5449066507dff47eaf45328dd9c2618bb2971a5f --- /dev/null +++ b/patches/035-user-config-change-event.patch @@ -0,0 +1,59 @@ +--- ./lib/private/AllConfig.php 2024-03-28 01:02:39 ++++ ./lib/private/AllConfig-new.php 2024-04-15 16:36:23 +@@ -38,6 +38,8 @@ + use OCP\IConfig; + use OCP\IDBConnection; + use OCP\PreConditionNotMetException; ++use OCP\EventDispatcher\IEventDispatcher; ++use OCP\User\Events\UserConfigChangedEvent; + + /** + * Class to combine all the configuration options ownCloud offers +@@ -278,6 +280,7 @@ + $qb->executeStatement(); + + $this->userCache[$userId][$appName][$key] = (string)$value; ++ $this->triggerUserValueChange($userId, $appName, $key, $value, $prevValue); + return; + } + } +@@ -304,8 +307,15 @@ + } + $this->userCache[$userId][$appName][$key] = (string)$value; + } ++ $this->triggerUserValueChange($userId, $appName, $key, $value, $prevValue); + } + ++ private function triggerUserValueChange($userId, $appId, $key, $value, $oldValue = null) { ++ if (\OC::$server instanceof \OCP\IServerContainer) { ++ $dispatcher = \OC::$server->get(IEventDispatcher::class); ++ $dispatcher->dispatchTyped(new UserConfigChangedEvent($userId, $appId, $key, $value, $oldValue)); ++ } ++ } + /** + * Getting a user defined value + * + + +--- ./lib/composer/composer/autoload_static.php 2024-03-28 01:02:39 ++++ ./lib/composer/composer/autoload_static-new.php 2024-04-15 16:34:18 +@@ -710,6 +710,7 @@ + 'OCP\\User\\Events\\PasswordUpdatedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/PasswordUpdatedEvent.php', + 'OCP\\User\\Events\\PostLoginEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/PostLoginEvent.php', + 'OCP\\User\\Events\\UserChangedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserChangedEvent.php', ++ 'OCP\\User\\Events\\UserConfigChangedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserConfigChangedEvent.php', + 'OCP\\User\\Events\\UserCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserCreatedEvent.php', + 'OCP\\User\\Events\\UserDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserDeletedEvent.php', + 'OCP\\User\\Events\\UserLiveStatusEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLiveStatusEvent.php', + + +--- ./lib/composer/composer/autoload_classmap.php 2024-03-28 01:02:39 ++++ ./lib/composer/composer/autoload_classmap-new.php 2024-04-15 16:33:19 +@@ -683,6 +683,7 @@ + 'OCP\\User\\Events\\UserLoggedInEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInEvent.php', + 'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php', + 'OCP\\User\\Events\\UserLoggedOutEvent' => $baseDir . '/lib/public/User/Events/UserLoggedOutEvent.php', ++ 'OCP\\User\\Events\\UserConfigChangedEvent' => $baseDir . '/lib/public/User/Events/UserConfigChangedEvent.php', + 'OCP\\User\\GetQuotaEvent' => $baseDir . '/lib/public/User/GetQuotaEvent.php', + 'OCP\\Util' => $baseDir . '/lib/public/Util.php', + 'OCP\\WorkflowEngine\\EntityContext\\IContextPortation' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IContextPortation.php', diff --git a/patches/036-user-config-changed-event-new-file.patch b/patches/036-user-config-changed-event-new-file.patch new file mode 100644 index 0000000000000000000000000000000000000000..9b9d664b02a69b1a081e1cef1839374ab19750b7 --- /dev/null +++ b/patches/036-user-config-changed-event-new-file.patch @@ -0,0 +1,70 @@ +--- /dev/null ++++ ./lib/public/User/Events/UserConfigChangedEvent.php +@@ -0,0 +1 @@ ++ ++ * ++ * @author Murena SAS ++ * ++ * @license GNU AGPL version 3 or any later version ++ * ++ * This program is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU Affero General Public License as ++ * published by the Free Software Foundation, either version 3 of the ++ * License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU Affero General Public License for more details. ++ * ++ * You should have received a copy of the GNU Affero General Public License ++ * along with this program. If not, see . ++ * ++ */ ++ ++namespace OCP\User\Events; ++ ++use OCP\EventDispatcher\Event; ++ ++class UserConfigChangedEvent extends Event { ++ private string $userId; ++ private string $appId; ++ private string $key; ++ private mixed $value; ++ private mixed $oldValue; ++ ++ public function __construct(string $userId, string $appId, string $key, mixed $value, mixed $oldValue = null) { ++ parent::__construct(); ++ $this->userId = $userId; ++ $this->appId = $appId; ++ $this->key = $key; ++ $this->value = $value; ++ $this->oldValue = $oldValue; ++ } ++ ++ public function getUserId(): string { ++ return $this->userId; ++ } ++ ++ public function getAppId(): string { ++ return $this->appId; ++ } ++ ++ public function getKey(): string { ++ return $this->key; ++ } ++ ++ public function getValue() { ++ return $this->value; ++ } ++ ++ public function getOldValue() { ++ return $this->oldValue; ++ } ++} +\ No newline at end of file