Skip to content

Commit

Permalink
Merge pull request #393 from canyongbs/develop
Browse files Browse the repository at this point in the history
1.0-rc12
  • Loading branch information
Orrison authored Dec 22, 2023
2 parents e1ed32a + 3787c6f commit be22e39
Show file tree
Hide file tree
Showing 332 changed files with 12,242 additions and 1,741 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ AWS_USE_PATH_STYLE_ENDPOINT=true

AWS_URL=http://localhost:9000/local

AWS_SQS_ACCESS_KEY_ID=
AWS_SQS_SECRET_ACCESS_KEY=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
Expand Down
251 changes: 246 additions & 5 deletions _ide_helper_models.php

Large diffs are not rendered by default.

132 changes: 132 additions & 0 deletions app-modules/alert/graphql/alert.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
type Alert @model(class: "AdvisingApp\\Alert\\Models\\Alert") {
"Unique primary key."
id: UUID!

"The Concern of the alert."
concern: Educatable! @morphTo

"The description of the alert."
description: String!

"The severity of the alert."
severity: AlertSeverity!

"The status of the alert."
status: AlertStatus!

"The suggested intervention for the alert."
suggested_intervention: String!

"The created datetime of the alert."
created_at: DateTime

"The updated datetime of the alert."
updated_at: DateTime

"The deleted datetime of the alert."
deleted_at: DateTime
}

input AlertConcernsQuery {
student: StudentsQuery
prospect: ProspectsQuery
}

input AlertsQuery {
id: UUID
concern: AlertConcernsQuery @morphToRelation
concern_id: EducatableId
concern_type: EducatableType
description: String
severity: AlertSeverity
status: AlertStatus
suggested_intervention: String
created_at: DateTime
updated_at: DateTime
deleted_at: DateTime
}

type AlertQueries {
"Find a single alert by an identifying attribute."
find(
"The value of the attribute to match."
id: UUID! @whereKey @rules(apply: ["required", "uuid", "exists:alerts"])
): Alert @find @softDeletes @canResolved(ability: "view")

"List multiple alerts."
list(where: AlertsQuery @searchBy): [Alert!]!
@paginate
@softDeletes
@canModel(ability: "viewAny")
}

extend type Query {
alert: AlertQueries! @namespaced
}

input CreateAlertInput {
"The Concern related to the alert."
concern_id: EducatableId!
@rules(
apply: [
"required"
"AdvisingApp\\Alert\\Rules\\ConcernIdExistsRule"
]
)

"The type of Concern related to the alert."
concern_type: EducatableType!
@rules(apply: ["required", "in:student,prospect"])

"The description of the alert."
description: String! @rules(apply: ["required", "string"])

"The severity of the alert."
severity: AlertSeverity! @rules(apply: ["required"])

"The status of the alert."
status: AlertStatus! @rules(apply: ["required"])

"The suggested intervention for the alert."
suggested_intervention: String! @rules(apply: ["required", "string"])
}

input UpdateAlertInput {
"The description of the alert."
description: String @rules(apply: ["filled", "string"])

"The severity of the alert."
severity: AlertSeverity @rules(apply: ["filled"])

"The status of the alert."
status: AlertStatus @rules(apply: ["filled"])

"The suggested intervention for the alert."
suggested_intervention: String @rules(apply: ["filled", "string"])
}

type AlertMutations {
"Create an alert."
create(input: CreateAlertInput! @spread): Alert!
@create
@canModel(ability: "create")

"Update an alert."
update(
"The identifier of the alert you would like to update."
id: UUID! @whereKey @rules(apply: ["required", "uuid", "exists:alerts"])

"The fields you would like to update."
input: UpdateAlertInput! @spread
): Alert! @update @canFind(ability: "update", find: "id")

"Delete an alert."
delete(
"The identifier of the alert you would like to delete."
id: UUID! @whereKey @rules(apply: ["required", "uuid", "exists:alerts"])
): Alert @delete @canFind(ability: "delete", find: "id")
}

extend type Mutation {
alert: AlertMutations! @namespaced
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
use AdvisingApp\Alert\Events\AlertCreated;
use Illuminate\Contracts\Queue\ShouldQueue;
use AdvisingApp\StudentDataModel\Models\Student;
use AdvisingApp\Notifications\Models\Subscription;
use AdvisingApp\Notification\Models\Subscription;
use AdvisingApp\Alert\Notifications\AlertCreatedNotification;

class NotifySubscribersOfAlertCreated implements ShouldQueue
Expand Down
4 changes: 2 additions & 2 deletions app-modules/alert/src/Models/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
use AdvisingApp\Campaign\Models\CampaignAction;
use AdvisingApp\StudentDataModel\Models\Student;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use AdvisingApp\Notifications\Models\Contracts\Subscribable;
use AdvisingApp\Notification\Models\Contracts\Subscribable;
use AdvisingApp\StudentDataModel\Models\Contracts\Educatable;
use AdvisingApp\Audit\Models\Concerns\Auditable as AuditableTrait;
use AdvisingApp\Campaign\Models\Contracts\ExecutableFromACampaignAction;
use AdvisingApp\Notifications\Models\Contracts\CanTriggerAutoSubscription;
use AdvisingApp\Notification\Models\Contracts\CanTriggerAutoSubscription;

/**
* @property-read Student|Prospect $concern
Expand Down
11 changes: 7 additions & 4 deletions app-modules/alert/src/Observers/AlertObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@

namespace AdvisingApp\Alert\Observers;

use App\Models\User;
use AdvisingApp\Alert\Models\Alert;
use Illuminate\Support\Facades\Cache;
use AdvisingApp\Alert\Events\AlertCreated;
use AdvisingApp\Notifications\Actions\SubscriptionCreate;
use AdvisingApp\Notification\Actions\SubscriptionCreate;

class AlertObserver
{
public function created(Alert $alert): void
{
if ($user = auth()->user()) {
$user = auth()->user();

if ($user instanceof User) {
// Creating the subscription directly so that the alert can be sent to this User as well
resolve(SubscriptionCreate::class)->handle($user, $alert->getSubscribable(), false);
}
Expand All @@ -55,11 +58,11 @@ public function created(Alert $alert): void

public function saved(Alert $alert): void
{
Cache::tags('alert-count')->flush();
Cache::tags('{alert-count}')->flush();
}

public function deleted(Alert $alert): void
{
Cache::tags('alert-count')->flush();
Cache::tags('{alert-count}')->flush();
}
}
17 changes: 16 additions & 1 deletion app-modules/alert/src/Providers/AlertServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
use AdvisingApp\Alert\AlertPlugin;
use AdvisingApp\Alert\Models\Alert;
use Illuminate\Support\Facades\Event;
use App\Concerns\GraphSchemaDiscovery;
use Illuminate\Support\ServiceProvider;
use AdvisingApp\Alert\Enums\AlertStatus;
use AdvisingApp\Alert\Enums\AlertSeverity;
use AdvisingApp\Alert\Events\AlertCreated;
use AdvisingApp\Alert\Observers\AlertObserver;
use Illuminate\Database\Eloquent\Relations\Relation;
Expand All @@ -50,6 +53,8 @@

class AlertServiceProvider extends ServiceProvider
{
use GraphSchemaDiscovery;

public function register(): void
{
Panel::configureUsing(fn (Panel $panel) => $panel->plugin(new AlertPlugin()));
Expand All @@ -66,9 +71,11 @@ public function boot(): void
$this->registerObservers();

$this->registerEvents();

$this->registerGraphQL();
}

protected function registerRolesAndPermissions()
protected function registerRolesAndPermissions(): void
{
$permissionRegistry = app(AuthorizationPermissionRegistry::class);

Expand Down Expand Up @@ -107,4 +114,12 @@ protected function registerEvents(): void
NotifySubscribersOfAlertCreated::class
);
}

protected function registerGraphQL(): void
{
$this->discoverSchema(__DIR__ . '/../../graphql/alert.graphql');

$this->registerEnum(AlertSeverity::class);
$this->registerEnum(AlertStatus::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,36 @@
</COPYRIGHT>
*/

namespace AdvisingApp\Engagement\Notifications;
namespace AdvisingApp\Alert\Rules;

use Illuminate\Bus\Queueable;
use App\Notifications\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use AdvisingApp\Engagement\Models\EngagementDeliverable;
use Closure;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Validation\DataAwareRule;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Database\Eloquent\Relations\Relation;

class EngagementNotification extends Notification implements ShouldQueue
class ConcernIdExistsRule implements DataAwareRule, ValidationRule
{
use Queueable;
protected $data = [];

public function __construct(
public EngagementDeliverable $deliverable
) {}

public function via(object $notifiable): array
public function validate(string $attribute, mixed $value, Closure $fail): void
{
return ['mail'];
$type = $this->data['input']['concern_type'];

/** @var ?Model $morph */
$morph = Relation::getMorphedModel($type);

if (! $morph) {
$fail('The concern type must be either student or prospect.');
} elseif ($morph::query()->whereKey($value)->doesntExist()) {
$fail('The concern does not exist.');
}
}

public function toMail(object $notifiable): MailMessage
public function setData(array $data): static
{
return MailMessage::make()
->subject($this->deliverable->engagement->subject)
->greeting('Hello ' . $this->deliverable->engagement->recipient->display_name . '!')
->content($this->deliverable->engagement->getBody())
->salutation("Regards, {$this->deliverable->engagement->user->name}");
$this->data = $data;

return $this;
}
}
1 change: 1 addition & 0 deletions app-modules/application/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
</COPYRIGHT>
*/

use Illuminate\Support\Facades\Route;
use AdvisingApp\Application\Http\Controllers\ApplicationWidgetController;
use AdvisingApp\Form\Http\Middleware\EnsureSubmissibleIsEmbeddableAndAuthorized;
use AdvisingApp\Application\Http\Middleware\EnsureOnlineAdmissionsFeatureIsActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use AdvisingApp\Prospect\Models\Prospect;
use Illuminate\Contracts\Queue\ShouldQueue;
use AdvisingApp\StudentDataModel\Models\Student;
use AdvisingApp\Notifications\Models\Subscription;
use AdvisingApp\Notification\Models\Subscription;
use AdvisingApp\Application\Events\ApplicationSubmissionCreated;
use AdvisingApp\Application\Notifications\AuthorLinkedApplicationSubmissionCreatedNotification;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function created(ApplicationSubmission $submission): void
);

if (! is_null($submission->author)) {
Cache::tags('application-submission-count')
Cache::tags('{application-submission-count}')
->forget(
"application-submission-count-{$submission->author->getKey()}"
"{application-submission-count-{$submission->author->getKey()}}"
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@
?>

<x-filament-panels::page
class="max-h-screen"
full-height="true"
>
<x-filament-panels::page full-height="true">
<div
class="flex h-full flex-col"
wire:init="determineIfConsentWasGiven"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@

use App\Models\User;
use Illuminate\Bus\Queueable;
use App\Notifications\MailMessage;
use App\Models\NotificationSetting;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use AdvisingApp\Assistant\Models\AssistantChat;
use AdvisingApp\Notification\Notifications\Messages\MailMessage;
use AdvisingApp\Assistant\Services\AIInterface\Enums\AIChatMessageFrom;

class SendAssistantTranscriptNotification extends Notification implements ShouldQueue
Expand Down
3 changes: 2 additions & 1 deletion app-modules/audit/config/audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
'guards' => [
'web',
'api',
'sanctum',
],
'resolver' => OwenIt\Auditing\Resolvers\UserResolver::class,
],
Expand Down Expand Up @@ -204,7 +205,7 @@
'queue' => [
'dispatch_listener' => ProcessDispatchAudit::class,
'connection' => env('AUDIT_QUEUE_CONNECTION', 'sync'),
'queue' => 'default',
'queue' => env('SQS_QUEUE', 'default'),
'delay' => 0,
],

Expand Down
4 changes: 3 additions & 1 deletion app-modules/campaign/config/permissions/web/custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@
</COPYRIGHT>
*/

return [];
return [
'view_campaign_settings',
];
Loading

0 comments on commit be22e39

Please sign in to comment.