Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow email share adding using common email formats with name #2375

Merged
merged 8 commits into from
Apr 15, 2022
Merged
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
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ All notable changes to this project will be documented in this file.
- Hidden polls are now private polls and public polls are called open polls to distinguish them from public polls via public links
- Added configuration options for admins to add legal terms to the public registration dialog and emails
- Added the possibility for admins to add a disclaimer text to generated emails
- Input fields now support matching keyboards on mobiles
- Added email addresses for owner's poll export
- Allow email share adding using common email formats with name
- Input fields now support matching keyboards on mobiles
- Grouping comments for less noise
- Bulk import for text polls
- Save username of a public poll (using cookie)
Expand All @@ -21,6 +22,13 @@ All notable changes to this project will be documented in this file.
- Dont't add tags to description in plain text invitation mail
- poll list in admin page should not link to a poll

## [dev] - tbd
## Changes
- #2377 - Changed transitions on vote vlicks and add hover state
- #2367 - Allow email share adding using common email formats with name (#2375)

## Fixed

## [3.6.0-beta2] - 2022-04-13
## New
- #2373 - Add icon symbol for locked vote options
Expand Down
3 changes: 2 additions & 1 deletion l10n/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,10 @@ OC.L10N.register(
"Options added" : "Volby přidány",
"Error adding options" : "Chyba při přidávání voleb",
"Poll informations" : "Informace o anketě",
"This poll is unpublished" : "Zveřejnění této ankety bylo zrušeno",
"Invite users via the share tab in the sidebar" : "Pozvat uživatele prostřednictvím karty sdílení v postranním panelu",
"A private poll from {name}" : "Soukromá anketa od {name}",
"An openly accessible poll from {name}" : "Otevřeně přístupná anketa od {name}",
"Invite users via the share tab in the sidebar" : "Pozvat uživatele prostřednictvím karty sdílení v postranním panelu",
"Archived" : "Archivováno",
"Closing {relativeExpirationTime}" : "Uzavírá se {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "Termín návrhů skončil {timeRelative}",
Expand Down
3 changes: 2 additions & 1 deletion l10n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@
"Options added" : "Volby přidány",
"Error adding options" : "Chyba při přidávání voleb",
"Poll informations" : "Informace o anketě",
"This poll is unpublished" : "Zveřejnění této ankety bylo zrušeno",
"Invite users via the share tab in the sidebar" : "Pozvat uživatele prostřednictvím karty sdílení v postranním panelu",
"A private poll from {name}" : "Soukromá anketa od {name}",
"An openly accessible poll from {name}" : "Otevřeně přístupná anketa od {name}",
"Invite users via the share tab in the sidebar" : "Pozvat uživatele prostřednictvím karty sdílení v postranním panelu",
"Archived" : "Archivováno",
"Closing {relativeExpirationTime}" : "Uzavírá se {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "Termín návrhů skončil {timeRelative}",
Expand Down
2 changes: 1 addition & 1 deletion l10n/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ OC.L10N.register(
"Options added" : "Optionen hinzugefügt",
"Error adding options" : "Fehler beim Hinzufügen von Optionen",
"Poll informations" : "Umfrageinformationen",
"Invite users via the share tab in the sidebar" : "Laden Sie Benutzer über die Registerkarte „Teilen“ in der Seitenleiste ein",
"A private poll from {name}" : "Eine private Umfrage von {name}",
"An openly accessible poll from {name}" : "Eine öffentlich zugängliche Umfrage von {name}",
"Invite users via the share tab in the sidebar" : "Laden Sie Benutzer über die Registerkarte „Teilen“ in der Seitenleiste ein",
"Archived" : "Archiviert",
"Closing {relativeExpirationTime}" : "Schließt {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "Die Vorschlagsfrist endete {timeRelative}.",
Expand Down
2 changes: 1 addition & 1 deletion l10n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@
"Options added" : "Optionen hinzugefügt",
"Error adding options" : "Fehler beim Hinzufügen von Optionen",
"Poll informations" : "Umfrageinformationen",
"Invite users via the share tab in the sidebar" : "Laden Sie Benutzer über die Registerkarte „Teilen“ in der Seitenleiste ein",
"A private poll from {name}" : "Eine private Umfrage von {name}",
"An openly accessible poll from {name}" : "Eine öffentlich zugängliche Umfrage von {name}",
"Invite users via the share tab in the sidebar" : "Laden Sie Benutzer über die Registerkarte „Teilen“ in der Seitenleiste ein",
"Archived" : "Archiviert",
"Closing {relativeExpirationTime}" : "Schließt {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "Die Vorschlagsfrist endete {timeRelative}.",
Expand Down
3 changes: 2 additions & 1 deletion l10n/de_DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,10 @@ OC.L10N.register(
"Options added" : "Optionen hinzugefügt",
"Error adding options" : "Fehler beim Hinzufügen von Optionen",
"Poll informations" : "Umfrageinformationen",
"This poll is unpublished" : "Diese Umfrage ist nicht veröffentlicht",
"Invite users via the share tab in the sidebar" : "Laden Sie Benutzer über die Registerkarte „Teilen“ in der Seitenleiste ein",
"A private poll from {name}" : "Eine private Umfrage von {name}",
"An openly accessible poll from {name}" : "Eine öffentlich zugängliche Umfrage von {name}",
"Invite users via the share tab in the sidebar" : "Laden Sie Benutzer über die Registerkarte „Teilen“ in der Seitenleiste ein",
"Archived" : "Archiviert",
"Closing {relativeExpirationTime}" : "Schließt {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "Die Vorschlagsfrist endete {timeRelative}.",
Expand Down
3 changes: 2 additions & 1 deletion l10n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@
"Options added" : "Optionen hinzugefügt",
"Error adding options" : "Fehler beim Hinzufügen von Optionen",
"Poll informations" : "Umfrageinformationen",
"This poll is unpublished" : "Diese Umfrage ist nicht veröffentlicht",
"Invite users via the share tab in the sidebar" : "Laden Sie Benutzer über die Registerkarte „Teilen“ in der Seitenleiste ein",
"A private poll from {name}" : "Eine private Umfrage von {name}",
"An openly accessible poll from {name}" : "Eine öffentlich zugängliche Umfrage von {name}",
"Invite users via the share tab in the sidebar" : "Laden Sie Benutzer über die Registerkarte „Teilen“ in der Seitenleiste ein",
"Archived" : "Archiviert",
"Closing {relativeExpirationTime}" : "Schließt {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "Die Vorschlagsfrist endete {timeRelative}.",
Expand Down
3 changes: 2 additions & 1 deletion l10n/pl.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,10 @@ OC.L10N.register(
"Options added" : "Dodano opcje",
"Error adding options" : "Błąd podczas dodawania opcji",
"Poll informations" : "Informacje sondy",
"This poll is unpublished" : "Ta sonda nie została opublikowana",
"Invite users via the share tab in the sidebar" : "Zaproś użytkowników za pomocą zakładki udostępniania na pasku bocznym",
"A private poll from {name}" : "Prywatna sonda od {name}",
"An openly accessible poll from {name}" : "Swobodnie dostępna ankieta od {name}",
"Invite users via the share tab in the sidebar" : "Zaproś użytkowników za pomocą zakładki udostępniania na pasku bocznym",
"Archived" : "Zarchiwizowane",
"Closing {relativeExpirationTime}" : "Zamknięcie {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "Okres propozycji zakończył się {timeRelative}",
Expand Down
3 changes: 2 additions & 1 deletion l10n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@
"Options added" : "Dodano opcje",
"Error adding options" : "Błąd podczas dodawania opcji",
"Poll informations" : "Informacje sondy",
"This poll is unpublished" : "Ta sonda nie została opublikowana",
"Invite users via the share tab in the sidebar" : "Zaproś użytkowników za pomocą zakładki udostępniania na pasku bocznym",
"A private poll from {name}" : "Prywatna sonda od {name}",
"An openly accessible poll from {name}" : "Swobodnie dostępna ankieta od {name}",
"Invite users via the share tab in the sidebar" : "Zaproś użytkowników za pomocą zakładki udostępniania na pasku bocznym",
"Archived" : "Zarchiwizowane",
"Closing {relativeExpirationTime}" : "Zamknięcie {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "Okres propozycji zakończył się {timeRelative}",
Expand Down
2 changes: 1 addition & 1 deletion l10n/pt_BR.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ OC.L10N.register(
"Options added" : "Opções adicionadas",
"Error adding options" : "Erro ao adicionar opções",
"Poll informations" : "Informações da enquete",
"Invite users via the share tab in the sidebar" : "Convide usuários por meio da guia de compartilhamento na barra lateral",
"A private poll from {name}" : "Uma enquete privada de {name}",
"An openly accessible poll from {name}" : "Uma enquete de {name} com acesso aberto",
"Invite users via the share tab in the sidebar" : "Convide usuários por meio da guia de compartilhamento na barra lateral",
"Archived" : "Arquivado",
"Closing {relativeExpirationTime}" : "Encerra {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "O período da proposta terminou {timeRelative}",
Expand Down
2 changes: 1 addition & 1 deletion l10n/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@
"Options added" : "Opções adicionadas",
"Error adding options" : "Erro ao adicionar opções",
"Poll informations" : "Informações da enquete",
"Invite users via the share tab in the sidebar" : "Convide usuários por meio da guia de compartilhamento na barra lateral",
"A private poll from {name}" : "Uma enquete privada de {name}",
"An openly accessible poll from {name}" : "Uma enquete de {name} com acesso aberto",
"Invite users via the share tab in the sidebar" : "Convide usuários por meio da guia de compartilhamento na barra lateral",
"Archived" : "Arquivado",
"Closing {relativeExpirationTime}" : "Encerra {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "O período da proposta terminou {timeRelative}",
Expand Down
3 changes: 2 additions & 1 deletion l10n/tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,10 @@ OC.L10N.register(
"Options added" : "Seçenekler eklendi",
"Error adding options" : "Seçenekler eklenirken sorun çıktı",
"Poll informations" : "Anket bilgileri",
"This poll is unpublished" : "Bu anket yayından kaldırıldı",
"Invite users via the share tab in the sidebar" : "Kullanıcıları çağırmak için yan çubuktaki paylaş sekmesini kullanıın",
"A private poll from {name}" : "{name} tarafından kapalı bir anket",
"An openly accessible poll from {name}" : "{name} tarafından herkese açık bir anket",
"Invite users via the share tab in the sidebar" : "Kullanıcıları çağırmak için yan çubuktaki paylaş sekmesini kullanıın",
"Archived" : "Arşivlenmiş",
"Closing {relativeExpirationTime}" : "Kapanıyor {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "Öneri süresi bitti {timeRelative}",
Expand Down
3 changes: 2 additions & 1 deletion l10n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@
"Options added" : "Seçenekler eklendi",
"Error adding options" : "Seçenekler eklenirken sorun çıktı",
"Poll informations" : "Anket bilgileri",
"This poll is unpublished" : "Bu anket yayından kaldırıldı",
"Invite users via the share tab in the sidebar" : "Kullanıcıları çağırmak için yan çubuktaki paylaş sekmesini kullanıın",
"A private poll from {name}" : "{name} tarafından kapalı bir anket",
"An openly accessible poll from {name}" : "{name} tarafından herkese açık bir anket",
"Invite users via the share tab in the sidebar" : "Kullanıcıları çağırmak için yan çubuktaki paylaş sekmesini kullanıın",
"Archived" : "Arşivlenmiş",
"Closing {relativeExpirationTime}" : "Kapanıyor {relativeExpirationTime}",
"Proposal period ended {timeRelative}" : "Öneri süresi bitti {timeRelative}",
Expand Down
3 changes: 2 additions & 1 deletion l10n/zh_HK.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,10 @@ OC.L10N.register(
"Options added" : "已新增選項",
"Error adding options" : "新增選項錯誤",
"Poll informations" : "民意調查資訊",
"This poll is unpublished" : "此投票未發佈",
"Invite users via the share tab in the sidebar" : "通過側邊欄中的共享選項卡邀請用戶",
"A private poll from {name}" : "來自 {name} 的私人民意調查",
"An openly accessible poll from {name}" : "來自 {name} 向所有註冊用戶開放的投票",
"Invite users via the share tab in the sidebar" : "通過側邊欄中的共享選項卡邀請用戶",
"Archived" : "已封存",
"Closing {relativeExpirationTime}" : "{relativeExpirationTime} 結束",
"Proposal period ended {timeRelative}" : "提議期已於 {timeRelative} 前結束",
Expand Down
3 changes: 2 additions & 1 deletion l10n/zh_HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@
"Options added" : "已新增選項",
"Error adding options" : "新增選項錯誤",
"Poll informations" : "民意調查資訊",
"This poll is unpublished" : "此投票未發佈",
"Invite users via the share tab in the sidebar" : "通過側邊欄中的共享選項卡邀請用戶",
"A private poll from {name}" : "來自 {name} 的私人民意調查",
"An openly accessible poll from {name}" : "來自 {name} 向所有註冊用戶開放的投票",
"Invite users via the share tab in the sidebar" : "通過側邊欄中的共享選項卡邀請用戶",
"Archived" : "已封存",
"Closing {relativeExpirationTime}" : "{relativeExpirationTime} 結束",
"Proposal period ended {timeRelative}" : "提議期已於 {timeRelative} 前結束",
Expand Down
3 changes: 2 additions & 1 deletion l10n/zh_TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,10 @@ OC.L10N.register(
"Options added" : "已新增選項",
"Error adding options" : "新增選項錯誤",
"Poll informations" : "投票資訊",
"This poll is unpublished" : "此投票未發佈",
"Invite users via the share tab in the sidebar" : "透過側邊欄中的分享分頁邀請使用者",
"A private poll from {name}" : "來自 {name} 的私人投票",
"An openly accessible poll from {name}" : "來自 {name} 的開放可存取投票",
"Invite users via the share tab in the sidebar" : "透過側邊欄中的分享分頁邀請使用者",
"Archived" : "已封存",
"Closing {relativeExpirationTime}" : "{relativeExpirationTime} 關閉",
"Proposal period ended {timeRelative}" : "提案期已結束於 {timeRelative}",
Expand Down
3 changes: 2 additions & 1 deletion l10n/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@
"Options added" : "已新增選項",
"Error adding options" : "新增選項錯誤",
"Poll informations" : "投票資訊",
"This poll is unpublished" : "此投票未發佈",
"Invite users via the share tab in the sidebar" : "透過側邊欄中的分享分頁邀請使用者",
"A private poll from {name}" : "來自 {name} 的私人投票",
"An openly accessible poll from {name}" : "來自 {name} 的開放可存取投票",
"Invite users via the share tab in the sidebar" : "透過側邊欄中的分享分頁邀請使用者",
"Archived" : "已封存",
"Closing {relativeExpirationTime}" : "{relativeExpirationTime} 關閉",
"Proposal period ended {timeRelative}" : "提案期已結束於 {timeRelative}",
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/PollController.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function update(int $pollId, array $poll): DataResponse {

return [
'poll' => $this->pollService->update($pollId, $poll),
'acl' => $this->acl,
'acl' => $this->acl->setPollId($pollId),
];
});
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public function list(int $pollId): DataResponse {
* Add share
* @NoAdminRequired
*/
public function add(int $pollId, string $type, string $userId = ''): DataResponse {
return $this->responseCreate(function () use ($pollId, $type, $userId) {
return ['share' => $this->shareService->add($pollId, $type, $userId)];
public function add(int $pollId, string $type, string $userId = '', string $displayName = ''): DataResponse {
return $this->responseCreate(function () use ($pollId, $type, $userId, $displayName) {
return ['share' => $this->shareService->add($pollId, $type, $userId, $displayName)];
});
}

Expand Down
9 changes: 5 additions & 4 deletions lib/Model/UserGroup/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ class Email extends UserBase {

public function __construct(
string $id,
string $displayName = ''
string $displayName = '',
string $emailAddress = ''
) {
parent::__construct($id, self::TYPE);
$this->icon = self::ICON;
$this->description = Container::getL10N()->t('External Email');
$this->description = $emailAddress ? $emailAddress : Container::getL10N()->t('External Email');
$this->richObjectType = 'email';

$this->emailAddress = $id;
$this->emailAddress = $emailAddress ? $emailAddress : $id;
$this->displayName = $displayName ? $displayName : $this->displayName;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Model/UserGroup/UserBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public static function getUserGroupChild(string $type, string $id, string $displ
case Admin::TYPE:
return new Admin($id);
case Email::TYPE:
return new Email($id);
return new Email($id, $displayName, $emailAddress);
case self::TYPE_PUBLIC:
return new GenericUser($id, self::TYPE_PUBLIC);
case self::TYPE_EXTERNAL:
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/ShareService.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private function create(int $pollId, UserBase $userGroup, bool $preventInvitatio
*
* @return Share
*/
public function add(int $pollId, string $type, string $userId = ''): Share {
public function add(int $pollId, string $type, string $userId = '', string $displayName = '', string $emailAddress = ''): Share {
$this->acl->setPollId($pollId, Acl::PERMISSION_POLL_EDIT);

if ($type === UserBase::TYPE_PUBLIC) {
Expand All @@ -297,7 +297,7 @@ public function add(int $pollId, string $type, string $userId = ''): Share {
}
}

$this->create($pollId, UserBase::getUserGroupChild($type, $userId));
$this->create($pollId, UserBase::getUserGroupChild($type, $userId, $displayName, $emailAddress));

$this->eventDispatcher->dispatchTyped(new ShareCreateEvent($this->share));

Expand Down
13 changes: 9 additions & 4 deletions lib/Service/SystemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
use OCP\IUserManager;

class SystemService {

private const REGEX_VALID_MAIL = '/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/';
private const REGEX_PARSE_MAIL = '/(?:"?([^"]*)"?\s)?(?:<?(.+@[^>]+)>?)/';

/** @var VoteMapper */
private $voteMapper;

Expand All @@ -62,7 +64,7 @@ public function __construct(
* @return bool
*/
private static function isValidEmail(string $emailAddress): bool {
return (!preg_match('/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/', $emailAddress)) ? false : true;
return (!preg_match(self::REGEX_VALID_MAIL, $emailAddress)) ? false : true;
}

/**
Expand Down Expand Up @@ -118,8 +120,11 @@ public function getGroups(string $query = ''): array {
public function getSiteUsersAndGroups(string $query = ''): array {
$list = [];
if ($query !== '') {
if (self::isValidEmail($query)) {
$list[] = new Email($query);
preg_match_all(self::REGEX_PARSE_MAIL, $query, $parsedQuery);
$emailAddress = $parsedQuery[2][0];
$displayName = $parsedQuery[1][0];
if ($emailAddress && self::isValidEmail($emailAddress)) {
$list[] = new Email($emailAddress, $displayName, $emailAddress);
}

$list = array_merge($list, UserBase::search($query));
Expand Down
1 change: 1 addition & 0 deletions src/js/components/User/UserSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default {
type: payload.type,
id: payload.id,
emailAddress: payload.emailAddress,
displayName: payload.displayName,
})
} catch {
showError(t('polls', 'Error while adding share'))
Expand Down
Loading