Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@

# Changelog

## Unreleased

- **Confirmation emails for respondents**

Form owners can enable an automatic confirmation email that is sent to the respondent after a successful submission.
Requires an email-validated short text question in the form.

Supported placeholders in subject/body:

- `{formTitle}`, `{formDescription}`
- `{<fieldName>}` (question `name` or text, sanitized)

## v5.2.0 - 2025-09-25

- **Time: restrictions and ranges**
Expand Down
3 changes: 3 additions & 0 deletions docs/API_v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ Returns the full-depth object of the requested form (without submissions).
"state": 0,
"lockedBy": null,
"lockedUntil": null,
"confirmationEmailEnabled": false,
"confirmationEmailSubject": null,
"confirmationEmailBody": null,
"permissions": [
"edit",
"results",
Expand Down
6 changes: 6 additions & 0 deletions docs/DataStructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ This document describes the Object-Structure, that is used within the Forms App
| description | String | max. 8192 ch. | The Form description |
| ownerId | String | | The nextcloud userId of the form owner |
| submissionMessage | String | max. 2048 ch. | Optional custom message, with Markdown support, to be shown to users when the form is submitted (default is used if set to null) |
| confirmationEmailEnabled | Boolean | | If enabled, send a confirmation email to the respondent after submission |
| confirmationEmailSubject | String | max. 255 ch. | Optional confirmation email subject template (supports placeholders) |
| confirmationEmailBody | String | | Optional confirmation email body template (plain text, supports placeholders) |
| created | unix timestamp | | When the form has been created |
| access | [Access-Object](#access-object) | | Describing access-settings of the form |
| expires | unix-timestamp | | When the form should expire. Timestamp `0` indicates _never_ |
Expand All @@ -46,6 +49,9 @@ This document describes the Object-Structure, that is used within the Forms App
"title": "Form 1",
"description": "Description Text",
"ownerId": "jonas",
"confirmationEmailEnabled": false,
"confirmationEmailSubject": null,
"confirmationEmailBody": null,
"created": 1611240961,
"access": {},
"expires": 0,
Expand Down
1 change: 1 addition & 0 deletions lib/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class Constants {
];

public const EXTRA_SETTINGS_SHORT = [
'confirmationEmailRecipient' => ['boolean'],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, if we should add the extraSetting to the whole short question type or if we'd better have it only for *_SHORT_EMAIL. Otherwise it could also be set for e.g. number fields.

@susnux @pringelmann what do you think?

'validationType' => ['string'],
'validationRegex' => ['string'],
];
Expand Down
16 changes: 16 additions & 0 deletions lib/Db/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
* @method int|null getMaxSubmissions()
* @method void setMaxSubmissions(int|null $value)
* @method void setLockedUntil(int|null $value)
* @method int getConfirmationEmailEnabled()
* @method void setConfirmationEmailEnabled(bool $value)
* @method string|null getConfirmationEmailSubject()
* @method void setConfirmationEmailSubject(string|null $value)
* @method string|null getConfirmationEmailBody()
* @method void setConfirmationEmailBody(string|null $value)
*/
class Form extends Entity {
protected $hash;
Expand All @@ -74,6 +80,9 @@ class Form extends Entity {
protected $lockedBy;
protected $lockedUntil;
protected $maxSubmissions;
protected $confirmationEmailEnabled;
protected $confirmationEmailSubject;
protected $confirmationEmailBody;

/**
* Form constructor.
Expand All @@ -90,6 +99,7 @@ public function __construct() {
$this->addType('lockedBy', 'string');
$this->addType('lockedUntil', 'integer');
$this->addType('maxSubmissions', 'integer');
$this->addType('confirmationEmailEnabled', 'boolean');
}

// JSON-Decoding of access-column.
Expand Down Expand Up @@ -164,6 +174,9 @@ public function setAccess(array $access): void {
* lockedBy: ?string,
* lockedUntil: ?int,
* maxSubmissions: ?int,
* confirmationEmailEnabled: bool,
* confirmationEmailSubject: ?string,
* confirmationEmailBody: ?string,
* }
*/
public function read() {
Expand All @@ -188,6 +201,9 @@ public function read() {
'lockedBy' => $this->getLockedBy(),
'lockedUntil' => $this->getLockedUntil(),
'maxSubmissions' => $this->getMaxSubmissions(),
'confirmationEmailEnabled' => (bool)$this->getConfirmationEmailEnabled(),
'confirmationEmailSubject' => $this->getConfirmationEmailSubject(),
'confirmationEmailBody' => $this->getConfirmationEmailBody(),
];
}
}
6 changes: 6 additions & 0 deletions lib/FormsMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public function export(IUser $user, IExportDestination $exportDestination, Outpu
$forms = $this->formMapper->findAllByOwnerId($user->getUID());
foreach ($forms as $form) {
$formData = $form->read();
$formData['confirmationEmailEnabled'] ??= false;
$formData['confirmationEmailSubject'] ??= null;
$formData['confirmationEmailBody'] ??= null;
$formData['questions'] = $this->formsService->getQuestions($formData['id']);
$formData['submissions'] = $this->submissionService->getSubmissions($formData['id']);

Expand Down Expand Up @@ -149,6 +152,9 @@ public function import(IUser $user, IImportSource $importSource, OutputInterface
$form->setAllowEditSubmissions($formData['allowEditSubmissions']);
$form->setShowExpiration($formData['showExpiration']);
$form->setMaxSubmissions($formData['maxSubmissions'] ?? null);
$form->setConfirmationEmailEnabled($formData['confirmationEmailEnabled'] ?? false);
$form->setConfirmationEmailSubject($formData['confirmationEmailSubject'] ?? null);
$form->setConfirmationEmailBody($formData['confirmationEmailBody'] ?? null);

$this->formMapper->insert($form);

Expand Down
58 changes: 58 additions & 0 deletions lib/Migration/Version050300Date20260413233000.php
Comment thread
dtretyakov marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Forms\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
* Add confirmation email fields to forms
*/
class Version050300Date20260413233000 extends SimpleMigrationStep {

/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('forms_v2_forms');

if (!$table->hasColumn('confirmation_email_enabled')) {
$table->addColumn('confirmation_email_enabled', Types::BOOLEAN, [
'notnull' => false,
'default' => 0,
]);
}

if (!$table->hasColumn('confirmation_email_subject')) {
$table->addColumn('confirmation_email_subject', Types::STRING, [
'notnull' => false,
'default' => null,
'length' => 255,
]);
}

if (!$table->hasColumn('confirmation_email_body')) {
$table->addColumn('confirmation_email_body', Types::TEXT, [
'notnull' => false,
'default' => null,
]);
}

return $schema;
}
}
4 changes: 4 additions & 0 deletions lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* dateMax?: int,
* dateMin?: int,
* dateRange?: bool,
* confirmationEmailRecipient?: bool,
* maxAllowedFilesCount?: int,
* maxFileSize?: int,
* optionsHighest?: 2|3|4|5|6|7|8|9|10,
Expand Down Expand Up @@ -141,6 +142,9 @@
* shares: list<FormsShare>,
* submissionCount?: int,
* submissionMessage: ?string,
* confirmationEmailEnabled: bool,
* confirmationEmailSubject: ?string,
* confirmationEmailBody: ?string,
* }
Comment thread
dtretyakov marked this conversation as resolved.
*
* @psalm-type FormsUploadedFile = array{
Expand Down
Loading