Skip to content
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
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

APP_TIMEZONE=UTC
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database
PHP_CLI_SERVER_WORKERS=4

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
Expand Down Expand Up @@ -40,7 +41,7 @@ MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_SCHEME=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/public/storage
/storage/*.key
/storage/*.json
/storage/pail
/vendor
.env
.phpunit.result.cache
Expand Down Expand Up @@ -129,3 +130,4 @@ storage/backups
cron-fail.log
.DS_Store
.phpunit.cache/
/.nova
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GenerateVendingNetJournalEntryCommand extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
if (! QuickBooksAuthSettings::hasKnownAuth()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/QuickBooks/RefreshAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RefreshAccessToken extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
if (! QuickBooksAuthSettings::hasKnownAuth()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Stripe/TopUpIssuingBalance.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TopUpIssuingBalance extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
// This code should only be temporary until we have the full system built out to manage current issuing balance

Expand Down
4 changes: 2 additions & 2 deletions app/External/Slack/Modals/CountdownTestModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(?int $timeLeft)
blocks: [
Kit::section(
text: 'This is a test to see how responsive something like a countdown is.'
)
),
],
);

Expand All @@ -41,7 +41,7 @@ public function __construct(?int $timeLeft)
actionId: self::START_COUNTDOWN,
text: 'Start Countdown',
style: ButtonStyle::PRIMARY,
)
),
],
blockId: self::START_COUNTDOWN
),
Expand Down
5 changes: 2 additions & 3 deletions app/External/Slack/Modals/CreateTrainableEquipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class CreateTrainableEquipment implements ModalInterface
{
use ModalTrait;
use HasExternalOptions;
use RespondsToBlockActions;
use ModalTrait;

private const string EQUIPMENT_NAME = 'equipment-name';

Expand Down Expand Up @@ -129,11 +129,10 @@ public static function callbackId(): string
public static function handle(SlackRequest $request): JsonResponse
{
if (! $request->customer()->hasMembership(UserMembership::MEMBERSHIP_META_TRAINER)) {
Log::warning('CreateTrainableEquipment: Rejecting unauthorized submission from user ' . $request->customer()->id);
Log::warning('CreateTrainableEquipment: Rejecting unauthorized submission from user '.$request->customer()->id);
throw new \Exception('Unauthorized');
}


$values = $request->payload()['view']['state']['values'];
$equipmentName = $values[self::EQUIPMENT_NAME][self::EQUIPMENT_NAME]['value'];
$userSlackChannel = $values[self::USER_SLACK_CHANNEL][self::USER_SLACK_CHANNEL]['selected_channel'];
Expand Down
4 changes: 2 additions & 2 deletions app/External/Slack/Modals/EquipmentAuthorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

class EquipmentAuthorization implements ModalInterface
{
use HasExternalOptions;
use ModalTrait;
use RespondsToBlockActions;
use HasExternalOptions;

private const string EQUIPMENT_DROPDOWN = 'equipment-dropdown';

Expand Down Expand Up @@ -121,7 +121,7 @@ public static function handle(SlackRequest $request): JsonResponse
]);
}

return new SuccessModal("Authorization submitted!")->update();
return new SuccessModal('Authorization submitted!')->update();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/External/Slack/Modals/HasExternalOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

trait HasExternalOptions
{
public abstract static function getExternalOptions(SlackRequest $request): OptionsResult;
abstract public static function getExternalOptions(SlackRequest $request): OptionsResult;
}
12 changes: 6 additions & 6 deletions app/External/Slack/Modals/ManageOpenHouseModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct()
foreach (Door::all() as $door) {
$doorCheckboxOptions->append(Kit::option(
text: $door->humanReadableName,
value: 'device-' . $door->dsxDeviceId,
value: 'device-'.$door->dsxDeviceId,
initial: $door->openDuringOpenHouseByDefault
));
}
Expand Down Expand Up @@ -74,12 +74,12 @@ public static function callbackId(): string
public static function handle(SlackRequest $request): JsonResponse
{
if (! $request->customer()->canIDcheck()) {
Log::warning('ManageOpenHouseModal: Rejecting unauthorized submission from user ' . $request->customer()->id);
Log::warning('ManageOpenHouseModal: Rejecting unauthorized submission from user '.$request->customer()->id);
throw new \Exception('Unauthorized');
}

$values = $request->payload()['view']['state']['values'];
Log::info('Manage open house modal: ' . print_r($values, true));
Log::info('Manage open house modal: '.print_r($values, true));

$selectedTime = $values[self::EXPIRES_TIME][self::EXPIRES_TIME]['selected_time'];
$selectedOptions = collect($values[self::DOORS][self::DOORS]['selected_options'])
Expand All @@ -89,13 +89,13 @@ public static function handle(SlackRequest $request): JsonResponse

$selectedTimeCarbon = now()->tz('America/Denver');
$selectedTime = explode(':', $selectedTime);
$selectedTimeCarbon->hour = (int)$selectedTime[0];
$selectedTimeCarbon->minute = (int)$selectedTime[1];
$selectedTimeCarbon->hour = (int) $selectedTime[0];
$selectedTimeCarbon->minute = (int) $selectedTime[1];

$doors = Door::all();
/** @var Door $door */
foreach ($doors as $door) {
$shouldOpen = $selectedOptions->contains('device-' . $door->dsxDeviceId);
$shouldOpen = $selectedOptions->contains('device-'.$door->dsxDeviceId);
if ($selectedOptions->contains(self::CLOSE_ALL_DOORS)) {
$door->shouldOpen(false);
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/External/Slack/Modals/ManageVolunteerGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function __construct()
submit: 'Submit',
blocks: [
Kit::section(
text: "This feature is not yet implemented.",
)
text: 'This feature is not yet implemented.',
),
]
);
}
Expand Down
6 changes: 3 additions & 3 deletions app/External/Slack/Modals/MembershipOptionsModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(?Customer $customer)
placeholder: 'Select an item',
options: $membershipOptions,
),
)
),
]
);

Expand All @@ -81,15 +81,15 @@ public static function handle(SlackRequest $request): JsonResponse
break;
case self::QUICK_OPEN_HOUSE_VALUE:
if (! $request->customer()->canIDcheck()) {
Log::warning('QuickOpenHouse: Rejecting unauthorized submission from user ' . $request->customer()->id);
Log::warning('QuickOpenHouse: Rejecting unauthorized submission from user '.$request->customer()->id);
throw new \Exception('Unauthorized');
}
Door::quickOpenHouse();

return self::clearViewStack();
case self::ALL_DOORS_DEFAULT_VALUE:
if (! $request->customer()->canIDcheck()) {
Log::warning('QuickOpenHouse: Rejecting unauthorized submission from user ' . $request->customer()->id);
Log::warning('QuickOpenHouse: Rejecting unauthorized submission from user '.$request->customer()->id);
throw new \Exception('Unauthorized');
}
Door::quickDefaultDoors();
Expand Down
4 changes: 2 additions & 2 deletions app/External/Slack/Modals/NeedIdCheckModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct()
placeholder: 'Select a Customer',
options: $customers
),
)
),
],
);
}
Expand All @@ -66,7 +66,7 @@ public static function callbackId(): string
public static function handle(SlackRequest $request): JsonResponse
{
if (! $request->customer()->canIDcheck()) {
Log::warning('NeedIdCheckModal: Rejecting unauthorized submission from user ' . $request->customer()->id);
Log::warning('NeedIdCheckModal: Rejecting unauthorized submission from user '.$request->customer()->id);
throw new \Exception('Unauthorized');
}

Expand Down
2 changes: 1 addition & 1 deletion app/External/Slack/Modals/NewMemberIdCheckModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct($customer_id)
),
Kit::section(
text: Kit::plainText(
'The numbers on the card will look like either "12345 3300687-1" or "175-012345" and ' .
'The numbers on the card will look like either "12345 3300687-1" or "175-012345" and '.
'you should enter "12345" in this field.',
),
),
Expand Down
8 changes: 4 additions & 4 deletions app/External/Slack/Modals/NewMemberInfoModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class NewMemberInfoModal implements ModalInterface
use ModalTrait;

private const INFO = [
"This is a community. You are a member, not a customer. This organization runs on the contributions of its members.",
'This is a community. You are a member, not a customer. This organization runs on the contributions of its members.',
"We're a drug and alcohol free space. There is hazardous equipment here, always keep everyone's safety in mind.",
"Don't live or sleep at the space. That includes in the parking lot. Don't leave your car in the lot overnight.",
"There are other tenants in the building. Don't go upstairs except for the gender neutral bathroom since there's not one on the first floor. Close denhac doors if no one else is in the room. The exterior doors are unlocked randomly throughout the day.",
"Slack has many channels you can join. Channels prefixed with help- are a good place to start to ask for training on equipment. Channels prefixed with sig- are a good place to start volunteering and get involved. Reply in threads to make channels easier to follow.",
'Slack has many channels you can join. Channels prefixed with help- are a good place to start to ask for training on equipment. Channels prefixed with sig- are a good place to start volunteering and get involved. Reply in threads to make channels easier to follow.',
"Read all signs everywhere and abide by them. Also read the wiki. If something isn't in the wiki, add it. Check out the How To page on our website, it provides some information on 'How to be a denhac member' essentially.",
"No Harassment or Bullying: This includes, but is not limited to, attention that comes after a request to stop. Recognize and respect everyone's differences. Treat all members with kindness and respect. Our anti-harassment policy is part of the member agreement you've agreed to - please read it.",
"The last Saturday of the month is Hack denhac Day. The space is closed for personal project work. Come help us work on the space.",
"Leave the space better than you found it. Take out the trash. Communicate any issues through Slack.",
'The last Saturday of the month is Hack denhac Day. The space is closed for personal project work. Come help us work on the space.',
'Leave the space better than you found it. Take out the trash. Communicate any issues through Slack.',
];

public function __construct()
Expand Down
14 changes: 7 additions & 7 deletions app/External/Slack/Modals/OpenDoorModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct()
foreach (Door::all() as $door) {
$doorButtonOptions->append(Kit::option(
text: $door->humanReadableName,
value: 'device-' . $door->dsxDeviceId,
value: 'device-'.$door->dsxDeviceId,
));
}

Expand Down Expand Up @@ -57,13 +57,13 @@ public static function handle(SlackRequest $request): JsonResponse
{
$customer = $request->customer();
$values = $request->payload()['view']['state']['values'];
Log::info('Open Door Modal: ' . print_r($values, true));
Log::info('Open Door Modal: '.print_r($values, true));

$selectedOption = collect($values[self::DOORS][self::DOORS]['selected_option']);

/** @var Door $door */
$door = Door::all()
->filter(fn($door) => $selectedOption['value'] == 'device-' . $door->dsxDeviceId)
->filter(fn ($door) => $selectedOption['value'] == 'device-'.$door->dsxDeviceId)
->first();

if (is_null($door)) {
Expand All @@ -76,10 +76,10 @@ public static function handle(SlackRequest $request): JsonResponse

$earliestAllowedTimestamp = Carbon::now()->subMinutes(5)->getTimestamp();
$atTheSpace = $accessLogs
->where('user_id', $customer->slack_id)
->where('ip', setting('ip.space'))
->filter(fn($data) => $data['date_last'] >= $earliestAllowedTimestamp)
->count() > 0;
->where('user_id', $customer->slack_id)
->where('ip', setting('ip.space'))
->filter(fn ($data) => $data['date_last'] >= $earliestAllowedTimestamp)
->count() > 0;

if ($atTheSpace) {
event(new DoorControlUpdated($door->momentaryOpenTime, $door->shouldOpen(true)));
Expand Down
4 changes: 2 additions & 2 deletions app/External/Slack/Modals/SelectAMemberModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

class SelectAMemberModal implements ModalInterface
{
use ModalTrait;
use HasExternalOptions;
use ModalTrait;

private const SELECT_A_MEMBER = 'select-a-member';

Expand Down Expand Up @@ -82,7 +82,7 @@ public static function getExternalOptions(SlackRequest $request): OptionsResult
/** @var Customer $customer */
$name = "{$customer->first_name} {$customer->last_name}";

if(! is_null($filterValue) && ! Str::contains(Str::lower($name), Str::lower($filterValue))) {
if (! is_null($filterValue) && ! Str::contains(Str::lower($name), Str::lower($filterValue))) {
continue;
}

Expand Down
43 changes: 22 additions & 21 deletions app/Http/Controllers/AllCardsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,44 @@

class AllCardsController extends Controller
{
private const DENHAC_ACCESS = "denhac";
private const SERVER_ROOM_ACCESS = "Server Room";
private const CAN_OPEN_HOUSE_UDF = "dh_can_open_house";
private const DENHAC_ACCESS = 'denhac';

private const SERVER_ROOM_ACCESS = 'Server Room';

private const CAN_OPEN_HOUSE_UDF = 'dh_can_open_house';

public function __invoke(Request $request)
{
return Customer::with(['cards', 'memberships'])
->paginate(100)
->through(function ($customer) {
/** @var Customer $customer */

$cards = $customer->cards
->filter(fn($card) => $card->member_has_card)
->filter(fn ($card) => $card->member_has_card)
->map(function ($card) use ($customer) {
/** @var Card $card */
/** @var Card $card */

// Their card should only be active if it's already set to active, they have it, and they're a
// member. We already filter out cards that the member for sure does not have.
$activeCard = $card->active && $customer->member;
// Their card should only be active if it's already set to active, they have it, and they're a
// member. We already filter out cards that the member for sure does not have.
$activeCard = $card->active && $customer->member;

$access = [];
if($activeCard) {
$access[] = self::DENHAC_ACCESS;
$access = [];
if ($activeCard) {
$access[] = self::DENHAC_ACCESS;

if ($customer->hasMembership(UserMembership::SERVER_ROOM_ACCESS)) {
$access[] = self::SERVER_ROOM_ACCESS;
if ($customer->hasMembership(UserMembership::SERVER_ROOM_ACCESS)) {
$access[] = self::SERVER_ROOM_ACCESS;
}
}
}

return [
'card_num' => $card->number,
'access' => $access,
];
})->all();
return [
'card_num' => $card->number,
'access' => $access,
];
})->all();

$extra = [];
if($customer->isABoardMember() || $customer->isAManager()) {
if ($customer->isABoardMember() || $customer->isAManager()) {
$extra[] = self::CAN_OPEN_HOUSE_UDF;
}

Expand Down
9 changes: 1 addition & 8 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,4 @@

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

abstract class Controller extends BaseController
{
use AuthorizesRequests, ValidatesRequests;
}
abstract class Controller {}
Loading