Skip to content

Commit

Permalink
Merge branch 'develop' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
zarevskaya authored Jun 16, 2024
2 parents 4d35eeb + a3e97ef commit 3bc60c3
Show file tree
Hide file tree
Showing 14 changed files with 303 additions and 8 deletions.
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Thank you for creating a PR! We appreciate your contribution to Hi.Events.

To make the process as smooth as possible, please ensure you've read the [contributing guidelines](https://github.com/HiEventsDev/hi.events/blob/develop/CONTRIBUTING.md) before proceeding.

Please include a summary of the changes and the issue being fixed or the feature being added. The more detail, the better!

## Checklist

- [ ] I have read the contributing guidelines.
- [ ] My code is of good quality and follows the coding standards of the project.
- [ ] I have tested my changes, and they work as expected.

Thank you for your contribution! 🎉
30 changes: 30 additions & 0 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "CLA Assistant"
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened,closed,synchronize]

permissions:
actions: write
contents: read
pull-requests: write
statuses: write

jobs:
CLAAssistant:
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
uses: contributor-assistant/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
path-to-signatures: 'signatures.json'
path-to-document: 'https://github.com/HiEventsDev/hi.events/blob/develop/CLA.md'
branch: 'main'
allowlist: daveearley,bot*
remote-organization-name: HiEventsDev
remote-repository-name: cla-signatures
23 changes: 23 additions & 0 deletions CLA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Hi.Events Contributor License Agreement

Thank you for your interest in contributing to Hi.Events!

Like many open source projects, we ask you to please sign this Contributor License Agreement (CLA) to confirm that you have the rights to your contributions and grant us the necessary permissions to use them. This helps us manage the project effectively and offer both open-source and commercial licenses.

**Contributor License Agreement**

This Contributor License Agreement ("Agreement") documents the rights granted by contributors to Hi.Event Ltd. ("Company"). To make this a binding legal agreement, please review the following terms and sign below.

You hereby grant to Hi.Event Ltd. a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable license to use, modify, reproduce, distribute, and sublicense your contributions under the terms of both the GNU Affero General Public License version 3 (AGPL-3.0) and a commercial license, without any compensation to you.

You confirm that:

1. Each contribution is an original creation of yours and that you have the right to grant the licenses stated above.
2. Your contributions do not infringe any third-party copyrights, patents, trademarks, or other rights.
3. You will notify Hi.Event Ltd. of any facts or circumstances of which you become aware that would make your representations in this Agreement inaccurate in any respect.

For more details on how to contribute, please read our [Contribution Guidelines](https://github.com/HiEventsDev/hi.events/blob/develop/CONTRIBUTING.md).

Before contributing to Hi.Events, you must accept and agree to the terms of this Agreement.

Thank you for your contributions and support!
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Please ensure that your pull request includes:
- Tests for new functionality or bug fixes, if applicable.
- A demo or screenshots, if the changes are visual.

Once you create a pull request, a CLA bot will automatically check if you have signed the Contributor License Agreement (CLA).
Signing is as simple as leaving a comment on the pull request with the message `I have read the CLA Document and I hereby sign the CLA`.
We require all contributors to sign the CLA to ensure that we have the necessary permissions to use and distribute your contributions.

## Development Setup

To set up the development environment for Hi.Events, follow the detailed instructions in our [Getting Started with Local Development guide](https://hi.events/docs/getting-started/local-development).
Expand Down
23 changes: 23 additions & 0 deletions backend/app/DomainObjects/EventSettingDomainObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,27 @@ public function getGetEmailFooterHtml(): string
</div>
HTML;
}

public function getAddressString(): string
{
$locationDetails = $this->getLocationDetails();

if (is_null($locationDetails)) {
return '';
}

$addressParts = [
$locationDetails['venue_name'] ?? null,
$locationDetails['address_line_1'] ?? null,
$locationDetails['address_line_2'] ?? null,
$locationDetails['city'] ?? null,
$locationDetails['state_or_region'] ?? null,
$locationDetails['zip_or_postal_code'] ?? null,
$locationDetails['country'] ?? null
];

$filteredAddressParts = array_filter($addressParts, static fn($part) => !is_null($part) && $part !== '');

return implode(', ', $filteredAddressParts);
}
}
41 changes: 41 additions & 0 deletions backend/app/Mail/Attendee/AttendeeTicketMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

namespace HiEvents\Mail\Attendee;

use Carbon\Carbon;
use HiEvents\DomainObjects\AttendeeDomainObject;
use HiEvents\DomainObjects\EventDomainObject;
use HiEvents\DomainObjects\EventSettingDomainObject;
use HiEvents\DomainObjects\OrganizerDomainObject;
use HiEvents\Helper\StringHelper;
use HiEvents\Helper\Url;
use HiEvents\Mail\BaseMail;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Support\Str;
use Spatie\IcalendarGenerator\Components\Calendar;
use Spatie\IcalendarGenerator\Components\Event;

/**
* @uses /backend/resources/views/emails/orders/attendee-ticket.blade.php
Expand All @@ -20,6 +26,7 @@ public function __construct(
private readonly AttendeeDomainObject $attendee,
private readonly EventDomainObject $event,
private readonly EventSettingDomainObject $eventSettings,
private readonly OrganizerDomainObject $organizer,
)
{
parent::__construct();
Expand Down Expand Up @@ -51,4 +58,38 @@ public function content(): Content
]
);
}

public function attachments(): array
{
$startDateTime = Carbon::parse($this->event->getStartDate(), $this->event->getTimezone());
$endDateTime = $this->event->getEndDate() ? Carbon::parse($this->event->getEndDate(), $this->event->getTimezone()) : null;

$event = Event::create()
->name($this->event->getTitle())
->uniqueIdentifier('event-' . $this->attendee->getId())
->startsAt($startDateTime)
->url($this->event->getEventUrl())
->organizer($this->organizer->getEmail(), $this->organizer->getName());

if ($this->event->getDescription()) {
$event->description(StringHelper::previewFromHtml($this->event->getDescription()));
}

if ($this->eventSettings->getLocationDetails()) {
$event->address($this->eventSettings->getAddressString());
}

if ($endDateTime) {
$event->endsAt($endDateTime);
}

$calendar = Calendar::create()
->event($event)
->get();

return [
Attachment::fromData(static fn() => $calendar, 'event.ics')
->withMime('text/calendar')
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use HiEvents\DomainObjects\AttendeeDomainObject;
use HiEvents\DomainObjects\EventDomainObject;
use HiEvents\DomainObjects\EventSettingDomainObject;
use HiEvents\DomainObjects\OrganizerDomainObject;
use HiEvents\Mail\Attendee\AttendeeTicketMail;
use Illuminate\Contracts\Mail\Mailer;

Expand All @@ -20,12 +21,14 @@ public function send(
AttendeeDomainObject $attendee,
EventDomainObject $event,
EventSettingDomainObject $eventSettings,
OrganizerDomainObject $organizer,
): void
{
$this->mailer->to($attendee->getEmail())->send(new AttendeeTicketMail(
attendee: $attendee,
event: $event,
eventSettings: $eventSettings,
organizer: $organizer,
));
}
}
8 changes: 7 additions & 1 deletion backend/app/Services/Domain/Mail/SendOrderDetailsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ private function sendAttendeeTicketEmails(OrderDomainObject $order, EventDomainO
continue;
}

$this->sendAttendeeTicketService->send($attendee, $event, $event->getEventSettings());
$this->sendAttendeeTicketService->send(
attendee: $attendee,
event: $event,
eventSettings: $event->getEventSettings(),
organizer: $event->getOrganizer(),
);

$sentEmails[] = $attendee->getEmail();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace HiEvents\Services\Handlers\Attendee;

use HiEvents\DomainObjects\EventSettingDomainObject;
use HiEvents\DomainObjects\OrganizerDomainObject;
use HiEvents\DomainObjects\Status\AttendeeStatus;
use HiEvents\Exceptions\ResourceConflictException;
use HiEvents\Repository\Eloquent\Value\Relationship;
use HiEvents\Repository\Interfaces\AttendeeRepositoryInterface;
use HiEvents\Repository\Interfaces\EventRepositoryInterface;
use HiEvents\Services\Domain\Attendee\SendAttendeeTicketService;
Expand Down Expand Up @@ -42,10 +44,16 @@ public function handle(ResendAttendeeTicketDTO $resendAttendeeTicketDTO): void
}

$event = $this->eventRepository
->loadRelation(new Relationship(OrganizerDomainObject::class, name: 'organizer'))
->loadRelation(EventSettingDomainObject::class)
->findById($resendAttendeeTicketDTO->eventId);

$this->sendAttendeeTicketService->send($attendee, $event, $event->getEventSettings());
$this->sendAttendeeTicketService->send(
attendee: $attendee,
event: $event,
eventSettings: $event->getEventSettings(),
organizer: $event->getOrganizer(),
);

$this->logger->info('Attendee ticket resent', [
'attendeeId' => $resendAttendeeTicketDTO->attendeeId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public function handle(PartialUpdateEventSettingsDTO $eventSettingsDTO): EventSe
throw new RefundNotPossibleException('Event settings not found');
}

$locationDetails = $eventSettingsDTO->settings['location_details'] ?? $existingSettings->getLocationDetails();
$isOnlineEvent = $eventSettingsDTO->settings['is_online_event'] ?? $existingSettings->getIsOnlineEvent();

if ($isOnlineEvent) {
$locationDetails = null;
}

return $this->eventSettingsHandler->handle(
UpdateEventSettingsDTO::fromArray([
'event_id' => $eventSettingsDTO->event_id,
Expand Down Expand Up @@ -59,7 +66,7 @@ public function handle(PartialUpdateEventSettingsDTO $eventSettingsDTO): EventSe
'order_timeout_in_minutes' => $eventSettingsDTO->settings['order_timeout_in_minutes'] ?? $existingSettings->getOrderTimeoutInMinutes(),
'website_url' => $eventSettingsDTO->settings['website_url'] ?? $existingSettings->getWebsiteUrl(),
'maps_url' => $eventSettingsDTO->settings['maps_url'] ?? $existingSettings->getMapsUrl(),
'location_details' => $eventSettingsDTO->settings['location_details'] ?? $existingSettings->getLocationDetails(),
'location_details' => $locationDetails,
'is_online_event' => $eventSettingsDTO->settings['is_online_event'] ?? $existingSettings->getIsOnlineEvent(),
'online_event_connection_details' => array_key_exists('online_event_connection_details', $eventSettingsDTO->settings)
? $eventSettingsDTO->settings['online_event_connection_details']
Expand Down
1 change: 1 addition & 0 deletions backend/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"maatwebsite/excel": "^3.1",
"nette/php-generator": "^4.0",
"php-open-source-saver/jwt-auth": "^2.1",
"spatie/icalendar-generator": "^2.8",
"stripe/stripe-php": "^10.15"
},
"require-dev": {
Expand Down
Loading

0 comments on commit 3bc60c3

Please sign in to comment.