Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/composer/composer/composer-2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkregel authored Feb 13, 2024
2 parents 33bb26a + 32a660e commit 616621c
Show file tree
Hide file tree
Showing 112 changed files with 3,036 additions and 832 deletions.
28 changes: 2 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ $ ./sail up -d

## Planned
- [ ] IFTTT inspired Dynamic Automations
- [ ] Plaid integration for asset syncing
- [ ] Budgeting per project
- [x] Plaid integration for asset syncing
- [-] Budgeting per project
- [ ] Built-in project researching for Scholarly articles and browsing the web.
- [ ] Calendar integration for project and site wide events
- [ ] Task management, tasks are created per project
Expand All @@ -37,27 +37,3 @@ $ ./sail up -d

- Single Chat interface
- Email interface
# Domain Feature Details
This presently uses Cloudflare DNS.

We can configure and manage any DNS records that Cloudflare supports.

We also want to be able to update the NS of registrars to point to Cloudflare

## Domain Syncing
This will sync domains from Namecheap to Cloudflare. It will also sync domains from Cloudflare to Laravel Forge.

# Server Feature Details
We can manage any server listed in our database as long as there is at least an SSH server configured.

Servers house code or perform jobs. They are not necessarily web servers, but can be. When accessed via SSH, you have full access to everything that user has access to.

## Server Feature Details
Laravel Forge, and Digital Ocean are both supported providers, but any server can be added manually and accessed via SSH.

# RSS Feature Details
RSS feeds are synced and updated on a schedule. This is done via a job that runs every 15 minutes.

# Page Feature Details
Pages are dynamic routes that can be configured to point to any domain, or server. They can also be configured to redirect to another page, or domain.

11 changes: 11 additions & 0 deletions app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Actions\Fortify;

use App\Models\Person;
use App\Models\Team;
use App\Models\User;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -37,6 +38,7 @@ public function create(array $input): User
'password' => Hash::make($input['password']),
]), function (User $user) {
$this->createTeam($user);
$this->createPersonalRecord($user);
});
});
}
Expand All @@ -52,4 +54,13 @@ protected function createTeam(User $user): void
'personal_team' => true,
]));
}

protected function createPersonalRecord(User $user)
{
Person::create([
'name' => $user->name,
'emails' => [$user->email],
'names' => [$user->name],
]);
}
}
14 changes: 2 additions & 12 deletions app/Actions/Spork/SyncDataFromCredential.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

namespace App\Actions\Spork;

use App\Jobs\FetchDomainsForCredential;
use App\Jobs\FetchRegistrarForCredential;
use App\Jobs\FetchServersForCredential;
use App\Jobs\Finance\SyncPlaidTransactionsJob;
use App\Jobs\Servers\LaravelForgeServersSyncJob;
use App\Jobs\FetchResourcesFromCredential;
use App\Models\Credential;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Http\Request;
Expand All @@ -25,13 +21,7 @@ public function __invoke(Dispatcher $dispatcher, Request $request)
$credentials = Credential::where('user_id', $request->user()->id)->whereIn('id', $request->get('items'))->get();

foreach ($credentials as $credential) {
$dispatcher->dispatch(match ($credential->type) {
Credential::TYPE_REGISTRAR => new FetchRegistrarForCredential($credential),
Credential::TYPE_DOMAIN => new FetchDomainsForCredential($credential),
Credential::TYPE_SERVER => new FetchServersForCredential($credential),
Credential::TYPE_DEVELOPMENT, 'forge' => new LaravelForgeServersSyncJob($credential),
Credential::TYPE_FINANCE => new SyncPlaidTransactionsJob($credential, now()->subWeek(), now(), false),
});
$dispatcher->dispatch(new FetchResourcesFromCredential($credential));
}
}
}
16 changes: 7 additions & 9 deletions app/Console/Commands/MakeUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Console\Commands;

use App\Models\User;
use App\Actions\Fortify\CreateNewUser;
use Illuminate\Console\Command;

class MakeUser extends Command
Expand All @@ -28,16 +28,14 @@ class MakeUser extends Command
*/
public function handle()
{
$user = User::create([
$action = new CreateNewUser();

$action->create([
'name' => $this->ask('What is your name?'),
'email' => $this->ask('What is your email address?'),
'password' => bcrypt($this->ask('What password would you like to use?')),
]);

$user->ownedTeams()->create([
'name' => config('app.name'),
'personal_team' => true,
'settings' => [],
'password' => $password = $this->ask('What password would you like to use?'),
'password_confirmation' => $password,
'terms' => true,
]);
}
}
2 changes: 1 addition & 1 deletion app/Console/Commands/Messaging/MatrixBeeperRequestCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MatrixBeeperRequestCode extends Command
*/
public function handle()
{
$client = new \App\Services\Matrix\MatrixClient($this->argument('email'), $this->option('host'));
$client = new \App\Services\Messaging\MatrixClient($this->argument('email'), $this->option('host'));

$client->requestCodeForBeeper($this->argument('email'));
$this->info('Please check your email, and return within 30 minutes');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MatrixBeeperRequestTokenCode extends Command
*/
public function handle()
{
$client = new \App\Services\Matrix\MatrixClient($this->argument('email'), $this->option('host'));
$client = new \App\Services\Messaging\MatrixClient($this->argument('email'), $this->option('host'));

$response = $client->loginWithJwt($this->argument('code'));

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Messaging/MatrixBeeperVerifyCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MatrixBeeperVerifyCode extends Command
*/
public function handle()
{
$client = new \App\Services\Matrix\MatrixClient($this->argument('email'), $this->option('host'));
$client = new \App\Services\Messaging\MatrixClient($this->argument('email'), $this->option('host'));

$response = $client->loginWithBeeperCode($this->argument('email'), $this->argument('code'));

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule): void
{
$schedule->job(UpdateAllFeeds::class)->hourly();
$schedule->job(FetchResourcesFromCredentials::class)->everyOddHour();
$schedule->job(FetchResourcesFromCredentials::class)->hourly();
$schedule->job(FetchCloudflareAnalytics::class)->everyFourHours();
$schedule->command('operations:queue')->everyFiveMinutes();
}
Expand Down
1 change: 1 addition & 0 deletions app/Contracts/LogicalOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

interface LogicalOperator
{
public function compute(mixed $haystack, mixed $needle): bool;
}
12 changes: 12 additions & 0 deletions app/Contracts/Repositories/CredentialRepositoryContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace App\Contracts\Repositories;

use Illuminate\Contracts\Pagination\LengthAwarePaginator;

interface CredentialRepositoryContract
{
public function findAllOfType(string $type): LengthAwarePaginator;
}
10 changes: 10 additions & 0 deletions app/Contracts/Services/GeocodingServiceContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace App\Contracts\Services;

interface GeocodingServiceContract
{
public function geocode(string $address): array;
}
24 changes: 24 additions & 0 deletions app/Contracts/Services/ImapServiceContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Contracts\Services;

use Carbon\Carbon;
use Illuminate\Support\Collection;

interface ImapServiceContract
{
public function findAllMailboxes(): Collection;

public function findAllFromDate(string $mailbox, Carbon $date): Collection;

/**
* @param bool $peak This will set the read status in the imap server, when set to true, mail will be marked as read.
*/
public function findMessage(string $messageNumber, bool $peak = true): array;

public function markAsRead(string $messageId): void;

public function markAsUnread(string $messageId): void;
}
13 changes: 12 additions & 1 deletion app/Events/Models/Message/MessageCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@

use App\Events\AbstractLogicalEvent;
use App\Models\Message;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class MessageCreated extends AbstractLogicalEvent
class MessageCreated extends AbstractLogicalEvent implements ShouldBroadcast
{
public function __construct(
public Message $model,
) {
}

public function broadcastOn()
{
$this->model->load('credential');

return [
new PrivateChannel('App.Models.User.'.$this->model->credential->user_id),
];
}
}
16 changes: 13 additions & 3 deletions app/Http/Controllers/Api/Mail/MarkAsReadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@
namespace App\Http\Controllers\Api\Mail;

use App\Http\Controllers\Controller;
use App\Services\ImapService;
use App\Http\Requests\Messages\MailOwnerRequest;
use App\Models\Message;
use App\Services\Messaging\ImapFactoryService;

class MarkAsReadController extends Controller
{
public function __invoke(ImapService $imap)
public function __invoke(MailOwnerRequest $request, ImapFactoryService $factoryService)
{
request()->validate([
'id' => 'integer',
]);

$imap->markAsRead(request('id'));
$message = Message::query()
->with('credential')
->findOrFail($request->get('id'));

$service = $factoryService->make($message->credential);
$service->markAsRead($message->event_id);
$message->update([
'seen' => true,
]);
}
}
16 changes: 13 additions & 3 deletions app/Http/Controllers/Api/Mail/MarkAsUnreadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@
namespace App\Http\Controllers\Api\Mail;

use App\Http\Controllers\Controller;
use App\Services\ImapService;
use App\Http\Requests\Messages\MailOwnerRequest;
use App\Models\Message;
use App\Services\Messaging\ImapFactoryService;

class MarkAsUnreadController extends Controller
{
public function __invoke(ImapService $imap)
public function __invoke(MailOwnerRequest $request, ImapFactoryService $factoryService)
{
request()->validate([
'id' => 'integer',
]);

$imap->markAsUnread(request('id'));
$message = Message::query()
->with('credential')
->findOrFail($request->get('id'));

$service = $factoryService->make($message->credential);
$service->markAsUnread($message->event_id);
$message->update([
'seen' => false,
]);
}
}
25 changes: 0 additions & 25 deletions app/Http/Controllers/Petoskey/TodayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,5 @@ public function __invoke()
->orderByDesc('last_modified')
->paginate(10, ['*'], 'articles'),
]);

return view('petoskey.today', [
'articles' => Article::query()
->with('author:id,name')
->where('author_type', ExternalRssFeed::class)
->whereIn('author_id', ExternalRssFeed::query()
->where('name', 'Petoskey Area')
->orWhere('name', 'Petoskey Downtown on Facebook')
->orWhere('name', 'Petoskey Library on Facebook')
->pluck('id')
)
->where('last_modified', '>=', now()->subDays(7))
->orderByDesc('last_modified')
->paginate(5, ['*'], 'articles'),
'weather' => Arr::first((new OpenWeatherService)->query('Petoskey, MI')),
'news' => Article::query()
->with('author:id,name')
->where('author_type', ExternalRssFeed::class)
->where('last_modified', '>=', now()->subDays(7))
->whereIn('author_id', ExternalRssFeed::query()
->where('name', 'Petoskey News on Facebook')
->pluck('id')
)
->paginate(5, ['*'], 'news'),
]);
}
}
Loading

0 comments on commit 616621c

Please sign in to comment.