mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
response format fix, smtp QA fixes
This commit is contained in:
@@ -166,7 +166,7 @@ class Mail extends Event
|
||||
*/
|
||||
public function setSmtpUsername(string $username): self
|
||||
{
|
||||
$this->smtp['username'];
|
||||
$this->smtp['username'] = $username;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,19 @@ class Mail extends Event
|
||||
*/
|
||||
public function setSmtpPassword(string $password): self
|
||||
{
|
||||
$this->smtp['password'];
|
||||
$this->smtp['password'] = $password;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SMTP secure
|
||||
*
|
||||
* @param string $password
|
||||
* @return self
|
||||
*/
|
||||
public function setSmtpSecure(string $secure): self
|
||||
{
|
||||
$this->smtp['secure'] = $secure;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -194,6 +206,18 @@ class Mail extends Event
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SMTP sender name
|
||||
*
|
||||
* @param string $senderName
|
||||
* @return self
|
||||
*/
|
||||
public function setSmtpSenderName(string $senderName): self
|
||||
{
|
||||
$this->smtp['senderName'] = $senderName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SMTP reply to
|
||||
*
|
||||
@@ -246,6 +270,16 @@ class Mail extends Event
|
||||
return $this->smtp['password'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SMTP secure
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSmtpSecure(): string
|
||||
{
|
||||
return $this->smtp['secure'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SMTP sender email
|
||||
*
|
||||
@@ -256,6 +290,16 @@ class Mail extends Event
|
||||
return $this->smtp['senderEmail'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SMTP sender name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSmtpSenderName(): string
|
||||
{
|
||||
return $this->smtp['senderName'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SMTP reply to
|
||||
*
|
||||
|
||||
@@ -54,6 +54,7 @@ class Exception extends \Exception
|
||||
public const GENERAL_PROTOCOL_UNSUPPORTED = 'general_protocol_unsupported';
|
||||
public const GENERAL_CODES_DISABLED = 'general_codes_disabled';
|
||||
public const GENERAL_USAGE_DISABLED = 'general_usage_disabled';
|
||||
public const GENERAL_NOT_IMPLEMENTED = 'general_not_implemented';
|
||||
|
||||
/** Users */
|
||||
public const USER_COUNT_EXCEEDED = 'user_count_exceeded';
|
||||
@@ -188,6 +189,7 @@ class Exception extends \Exception
|
||||
public const PROJECT_KEY_EXPIRED = 'project_key_expired';
|
||||
|
||||
public const PROJECT_SMTP_CONFIG_INVALID = 'project_smtp_config_invalid';
|
||||
public const PROJECT_SMTP_CONFIG_NOT_FOUND = 'project_smtp_config_not_found';
|
||||
|
||||
public const PROJECT_TEMPLATE_DEFAULT_DELETION = 'project_template_default_deletion';
|
||||
|
||||
|
||||
@@ -480,7 +480,7 @@ class Response extends SwooleResponse
|
||||
*/
|
||||
public function dynamic(Document $document, string $model): void
|
||||
{
|
||||
$output = $this->output(new Document($document->getArrayCopy()), $model);
|
||||
$output = $this->output(clone $document, $model);
|
||||
|
||||
// If filter is set, parse the output
|
||||
if (self::hasFilter()) {
|
||||
@@ -521,11 +521,11 @@ class Response extends SwooleResponse
|
||||
*/
|
||||
public function output(Document $document, string $model): array
|
||||
{
|
||||
$data = new Document($document->getArrayCopy());
|
||||
$data = clone $document;
|
||||
$model = $this->getModel($model);
|
||||
$output = [];
|
||||
|
||||
$data = $model->filter($document);
|
||||
$data = $model->filter($data);
|
||||
|
||||
if ($model->isAny()) {
|
||||
$this->payload = $data->getArrayCopy();
|
||||
@@ -534,7 +534,7 @@ class Response extends SwooleResponse
|
||||
}
|
||||
|
||||
foreach ($model->getRules() as $key => $rule) {
|
||||
if (!$document->isSet($key) && $rule['required']) { // do not set attribute in response if not required
|
||||
if (!$data->isSet($key) && $rule['required']) { // do not set attribute in response if not required
|
||||
if (\array_key_exists('default', $rule)) {
|
||||
$data->setAttribute($key, $rule['default']);
|
||||
} else {
|
||||
@@ -543,11 +543,12 @@ class Response extends SwooleResponse
|
||||
}
|
||||
|
||||
if ($rule['array']) {
|
||||
if (!is_array($document[$key])) {
|
||||
if (!is_array($data[$key])) {
|
||||
\var_dump($data);
|
||||
throw new Exception($key . ' must be an array of type ' . $rule['type']);
|
||||
}
|
||||
|
||||
foreach ($document[$key] as $index => $item) {
|
||||
foreach ($data[$key] as $index => $item) {
|
||||
if ($item instanceof Document) {
|
||||
if (\is_array($rule['type'])) {
|
||||
foreach ($rule['type'] as $type) {
|
||||
@@ -575,7 +576,7 @@ class Response extends SwooleResponse
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($document[$key] instanceof Document) {
|
||||
if ($data[$key] instanceof Document) {
|
||||
$data[$key] = $this->output($data[$key], $rule['type']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user