Skip to content

Commit

Permalink
feat: use DECT as Telegram handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Fenrikur committed Aug 22, 2024
1 parent d4f8193 commit 0c5b31a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion includes/view/Locations_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function location_view(Location $location, ShiftsFilterRenderer $shiftsFilterRen
if (config('enable_dect') && $location->dect) {
$dect = heading(__('Contact'), 3)
. description([__('general.dect') => sprintf(
'<a href="tel:%s">%1$s</a>',
'<a href="https://t.me/%s">%1$s</a>',
htmlspecialchars($location->dect)
)]);
}
Expand Down
4 changes: 2 additions & 2 deletions includes/view/User_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function Users_view(
. user_info_icon($user);
$u['first_name'] = htmlspecialchars((string) $user->personalData->first_name);
$u['last_name'] = htmlspecialchars((string) $user->personalData->last_name);
$u['dect'] = sprintf('<a href="tel:%s">%1$s</a>', htmlspecialchars((string) $user->contact->dect));
$u['dect'] = sprintf('<a href="https://t.me/%s">%1$s</a>', htmlspecialchars((string) $user->contact->dect));
$u['arrived'] = icon_bool($user->state->arrived);
if (config('enable_voucher')) {
$u['got_voucher'] = $user->state->got_voucher;
Expand Down Expand Up @@ -713,7 +713,7 @@ function User_view(
config('enable_dect') && $user_source->contact->dect ?
heading(
icon('phone')
. ' <a href="tel:' . htmlspecialchars($user_source->contact->dect) . '">'
. ' <a href="https://t.me/' . htmlspecialchars($user_source->contact->dect) . '">'
. htmlspecialchars($user_source->contact->dect)
. '</a>'
)
Expand Down
2 changes: 1 addition & 1 deletion resources/api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ components:
type: string
nullable: true
example: 4242
description: The DECT number is a short internal number where users can be easily reached
description: The Telegram handle stored in the dect field is used as a way to easily reach users
mobile:
type: string
nullable: true
Expand Down
6 changes: 5 additions & 1 deletion resources/views/pages/angeltypes/about.twig
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<dl class="row card-text">
{% for type, info in {
'contact_name': {'name': __('general.name')},
'contact_dect': {'name': __('general.dect'), 'url': 'tel'},
'contact_dect': {'name': __('general.dect'), 'pattern': 'https://t.me/%s'},
'contact_email': {'name': __('general.email'), 'url': 'mailto'},
} %}
{% if angeltype[type] and (type != 'contact_dect' or config('enable_dect')) %}
Expand All @@ -90,6 +90,10 @@
<a href="{{ info['url'] }}:{{ angeltype[type] | e('html_attr') }}">
{{ angeltype[type] }}
</a>
{% elseif info.pattern is defined %}
<a href="{{ info.pattern | format(angeltype[type]) }}">
{{ angeltype[type] }}
</a>
{% else %}
{{ angeltype[type] }}
{% endif %}
Expand Down
1 change: 0 additions & 1 deletion resources/views/pages/registration.twig
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@
"dect",
__('general.dect'),
{
'type': 'tel-local',
'max_length': 40,
'required': isDectRequired,
'required_icon': isDectRequired,
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Admin/LocationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function save(Request $request): Response

$location->name = $data['name'];
$location->description = $data['description'];
$location->dect = $data['dect'];
$location->dect = ltrim($data['dect'], '@');
$location->map_url = $data['map_url'];

$location->save();
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function saveProfile(Request $request): Response
}

if (config('enable_dect')) {
$user->contact->dect = $data['dect'];
$user->contact->dect = ltrim($data['dect'], '@');
}

$user->contact->mobile = $data['mobile'];
Expand Down

0 comments on commit 0c5b31a

Please sign in to comment.