Skip to content

Commit

Permalink
Merge branch 'main' into fix/show-create-label-button
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Feb 1, 2025
2 parents 0afe578 + 5d2caec commit ab95bd2
Show file tree
Hide file tree
Showing 258 changed files with 3,898 additions and 3,022 deletions.
16 changes: 11 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,20 @@ [email protected]
MAIL_REPLY_TO_NAME="${APP_NAME}"

# Search
# We use Laravel Scout to do full-text search.
# Read config/scout.php for more information.
# Note that you have to use Meilisearch, Algolia or the database driver to enable
# search in Monica. Searching requires a queue to be configured.
## We use Laravel Scout to do full-text search.
## Read config/scout.php for more information.
## Note that you have to use: 'meilisearch', 'typesense', 'algolia' or the 'database'
## driver to enable search in Monica. Searching requires a queue to be configured.
SCOUT_DRIVER=database
SCOUT_QUEUE=true
MEILISEARCH_HOST=
## If you never intend to use the 'database' driver, you can set this value to false:
FULL_TEXT_INDEX=true
## Meilisearch settings
MEILISEARCH_URL=
MEILISEARCH_KEY=
## Typesense settings
TYPESENSE_HOST=
TYPESENSE_API_KEY=

# Notification channels
TELEGRAM_BOT_TOKEN=
Expand Down
2 changes: 1 addition & 1 deletion .env.example.sail
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ MAIL_REPLY_TO_NAME="${APP_NAME}"

SCOUT_DRIVER=meilisearch
SCOUT_QUEUE=true
MEILISEARCH_HOST=http://meilisearch:7700
MEILISEARCH_URL=http://meilisearch:7700
MEILISEARCH_KEY=
MEILISEARCH_NO_ANALYTICS=false
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npx lint-staged
yarn lint-staged
2 changes: 1 addition & 1 deletion app/Actions/Jetstream/UserProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __invoke(Request $request, array $data): array
]);

$webauthnKeys = $request->user()->webauthnKeys
->map(fn (WebauthnKey $key) => [
->map(fn (WebauthnKey $key) => [ // @phpstan-ignore-line
'id' => $key->id,
'name' => $key->name,
'type' => $key->type,
Expand Down
13 changes: 8 additions & 5 deletions app/Console/Commands/SetupScout.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Console\Commands;

use App\Helpers\ScoutHelper;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Symfony\Component\Console\Attribute\AsCommand;
Expand Down Expand Up @@ -49,17 +50,18 @@ public function handle(): void
*/
protected function scoutConfigure(): void
{
if (config('scout.driver') === 'meilisearch' && config('scout.meilisearch.host') !== '') {
$this->artisan('☐ Updating indexes on Meilisearch', 'scout:sync-index-settings', ['--verbose' => true]);
if (ScoutHelper::isIndexed()) {
$this->artisan('☐ Updating indexes', 'scout:sync-index-settings', ['--verbose' => true]);
}
}

/**
* Import models.
* Flush indexes.
*/
protected function scoutFlush(): void
{
if (config('scout.driver') !== null && $this->option('flush')) {
if ($this->option('flush') && ScoutHelper::isIndexed()) {
// Using meilisearch config for any driver
foreach (config('scout.meilisearch.index-settings') as $index => $settings) {
$name = (new $index)->getTable();
$this->artisan("☐ Flush {$name} index", 'scout:flush', ['model' => $index, '--verbose' => true]);
Expand All @@ -74,7 +76,8 @@ protected function scoutFlush(): void
*/
protected function scoutImport(): void
{
if (config('scout.driver') !== null && $this->option('import')) {
if ($this->option('import') && ScoutHelper::isIndexed()) {
// Using meilisearch config for any driver
foreach (config('scout.meilisearch.index-settings') as $index => $settings) {
$name = (new $index)->getTable();
$this->artisan("☐ Import {$name}", 'scout:import', ['model' => $index, '--verbose' => true]);
Expand Down
2 changes: 1 addition & 1 deletion app/Domains/Contact/Dav/Services/GetEtag.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function execute(array $data): string
/** @var VCardResource */
$entry = $data['entry'];

if ($entry->vault_id !== $this->vault->id) {
if ($entry->vault_id != $this->vault->id) {
throw new ModelNotFoundException;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getAddressBooksForUser($principalUri): array

private function getAddressBookDetails(Vault $vault): array
{
$token = $this->getCurrentSyncToken($vault->id);
$token = $this->getCurrentSyncToken((string) $vault->id);

$des = [
'id' => $vault->id,
Expand Down
2 changes: 1 addition & 1 deletion app/Domains/Contact/DavClient/Jobs/GetMultipleVCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private function run(): void
$data = $this->addressbookMultiget();

$jobs = collect($data)
->filter(fn (array $contact): bool => is_array($contact) && $contact['status'] === '200')
->filter(fn (array $contact): bool => $contact['status'] === '200')
->map(fn (array $contact, string $href): ?UpdateVCard => $this->updateVCard($contact, $href))
->filter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private function addContactInformationToVCard(VCard $vcard, ContactInformation $
case trans('Phone'):
// https://datatracker.ietf.org/doc/html/rfc6350#section-6.4.1
$vcard->add('TEL', $contactInformation->data, [
//'TYPE' => $contactInformation->contactInformationType->type,
// 'TYPE' => $contactInformation->contactInformationType->type,
]);
break;
case trans('Facebook'):
Expand Down
2 changes: 1 addition & 1 deletion app/Domains/Contact/ManageContact/Dav/ImportContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private function getExistingContact(VCard $vcard): ?Contact
$contact = null;

if (($uri = Arr::get($this->context->data, 'uri')) !== null) {
$contact = $backend->getObject($this->vault()->id, $uri);
$contact = $backend->getObject((string) $this->vault()->id, $uri);

if ($contact === null) {
$contact = Contact::firstWhere([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private function copy(): void
$this->newContact = new Contact;

$this->newContact = $this->contact->replicate();
$this->newContact->vault_id = $this->newVault->id;
$this->newContact->vault_id = (string) $this->newVault->id;
$this->newContact->save();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private function moveCompanyInformation(): void
{
if ($this->contact->company) {
if ($this->contact->company->contacts->count() === 1) {
$this->contact->company->vault_id = $this->newVault->id;
$this->contact->company->vault_id = (string) $this->newVault->id;
$this->contact->company->save();
} else {
$newCompany = (new CreateCompany)->execute([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ContactVCardController extends Controller
{
public function download(Request $request, Vault $vault, Contact $contact)
{
$cardData = $this->exportVCard($vault->id, $contact->id);
$cardData = $this->exportVCard((string) $vault->id, $contact->id);
$name = Str::of($contact->name)->slug(language: App::getLocale());

return Redirect::back()->with('flash', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function data(Vault $vault): Collection
]),
]);

return [
return [ // @phpstan-ignore-line
'id' => $group->id,
'name' => $group->name,
'url' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function data(Group $group): array
: $group->groupType->groupTypeRoles()
->orderBy('position')
->get()
->map(function (GroupTypeRole $role) use ($group) {
->map(function (GroupTypeRole $role) use ($group) { // @phpstan-ignore-line
$contactsCollection = $group->contacts()
->wherePivot('group_type_role_id', $role->id)
->get()
Expand All @@ -37,7 +37,7 @@ public static function data(Group $group): array
]),
]);

return [
return [ // @phpstan-ignore-line
'id' => $role->id,
'label' => $role->label,
'contacts' => $contactsCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public static function data(Contact $contact, User $user): array
$loansAsLoaner = $contact->loansAsLoaner()->where('settled', false)->get();
$loansAsLoanee = $contact->loansAsLoanee()->where('settled', false)->get();

$loans = $loansAsLoaner->concat($loansAsLoanee)->sortBy('loaned_at')->unique('id');

$loansAssociatedWithContactCollection = $loans->map(function ($loan) use ($contact, $user) {
return self::dtoLoan($loan, $contact, $user);
});
$loansAssociatedWithContactCollection = $loansAsLoaner
->concat($loansAsLoanee)
->sortBy('loaned_at')
->unique('id')
->map(fn (Loan $loan): array => self::dtoLoan($loan, $contact, $user)); // @phpstan-ignore-line

return [
'loans' => $loansAssociatedWithContactCollection,
Expand Down
4 changes: 3 additions & 1 deletion app/Domains/Settings/ManageUsers/Services/DestroyUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ private function validate(): void
{
$this->validateRules($this->data);

$this->user = $this->account()->users()
/** @var User */
$user = $this->account()->users()
->findOrFail($this->data['user_id']);
$this->user = $user;

if ($this->data['user_id'] === $this->data['author_id']) {
throw new ValidationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function execute(array $data): User
{
$this->validateRules($data);

/** @var User */
$user = $this->account()->users()
->findOrFail($data['user_id']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function execute(array $data): User
{
$this->validateRules($data);

/** @var User */
$user = $this->account()->users()
->findOrFail($data['user_id']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ class UserIndexViewHelper
{
public static function data(User $loggedUser): array
{
/** @var \Illuminate\Database\Eloquent\Collection<int,User> */
$users = $loggedUser->account->users;

$userCollection = $users->map(function ($user) use ($loggedUser) {
return self::dtoUser($user, $loggedUser);
});
$userCollection = $users->map(fn (User $user): array => self::dtoUser($user, $loggedUser));

return [
'users' => $userCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class AddPostToSliceOfLife extends BaseService implements ServiceInterface
{
private Post $post;

private ?SliceOfLife $slice;

private array $data;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,14 @@ public static function postsInYear(Journal $journal, int $year, User $user): Col
*/
public static function yearsOfContentInJournal(Journal $journal): Collection
{
/** @var Collection<int,Post> */
$posts = Post::where('journal_id', $journal->id)
->select(DB::raw(SQLHelper::year('written_at').' as year'))
->distinct()
->orderBy('year', 'desc')
->get();

return $posts->map(fn (Post $post) => [
return $posts->map(fn (Post $post): array => [ // @phpstan-ignore-line
'year' => $post->year,
'posts' => Post::where('journal_id', $journal->id)
->whereYear('written_at', $post->year)
Expand Down Expand Up @@ -196,7 +197,7 @@ public static function tags(Journal $journal): Collection

public static function slices(Journal $journal): Collection
{
$slicesCollection = $journal
return $journal
->slicesOfLife()
->get()
->map(fn (SliceOfLife $slice) => [
Expand All @@ -212,7 +213,5 @@ public static function slices(Journal $journal): Collection
]),
],
]);

return $slicesCollection;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static function data(User $user): array
private static function getContacts(Vault $vault): Collection
{
return $vault->contacts
->random(fn (Collection $items): int => min(5, count($items)))
->random(fn (Collection $items): int => min(5, count($items))) // @phpstan-ignore-line
->map(fn (Contact $contact) => [
'id' => $contact->id,
'name' => $contact->name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static function data(Vault $vault, User $user): Collection
$reminder = ContactReminder::where('id', $contactReminderScheduled->contact_reminder_id)->with('contact')->first();
$contact = $reminder->contact;

if ($contact->vault_id !== $vault->id) {
if ($contact->vault_id != $vault->id) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function upcomingReminders(Vault $vault, User $user): array
$remindersCollection = $contactRemindersScheduled->map(function ($reminder) use ($vault, $user) {
$contact = $reminder->contact;

if ($contact->vault_id !== $vault->id) {
if ($contact->vault_id != $vault->id) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ private function validate(): void
{
$this->validateRules($this->data);

$this->user = $this->account()->users()
/** @var User */
$user = $this->account()->users()
->findOrFail($this->data['user_id']);
$this->user = $user;

if ($this->user->id === $this->author->id) {
throw new SameUserException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ private function validate(): void
{
$this->validateRules($this->data);

$this->user = $this->account()->users()
/** @var User */
$user = $this->account()->users()
->findOrFail($this->data['user_id']);
$this->user = $user;

if ($this->user->id === $this->author->id) {
throw new SameUserException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ private function validate(): void
{
$this->validateRules($this->data);

$this->user = $this->account()->users()
/** @var User */
$user = $this->account()->users()
->findOrFail($this->data['user_id']);
$this->user = $user;

if ($this->user->id === $this->author->id) {
throw new SameUserException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ public static function data(Vault $vault): array
$usersInAccount = $vault->account->users()->whereNotNull('email_verified_at')->get();
$usersInVault = $vault->users()->get();
$usersInAccount = $usersInAccount->diff($usersInVault);
$usersInAccountCollection = $usersInAccount->map(function ($user) use ($vault) {
return self::dtoUser($user, $vault);
});
$usersInVaultCollection = $usersInVault->map(function ($user) use ($vault) {
return self::dtoUser($user, $vault);
});
$usersInAccountCollection = $usersInAccount->map(fn (User $user): array => self::dtoUser($user, $vault)); // @phpstan-ignore-line
$usersInVaultCollection = $usersInVault->map(fn (User $user): array => self::dtoUser($user, $vault));

// labels
$labels = $vault->labels()
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Handler extends ExceptionHandler
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array<int, string>
* @var list<string>
*/
protected $dontFlash = [
'current_password',
Expand Down
6 changes: 1 addition & 5 deletions app/Helpers/CollectionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ public static function getCollator(?string $locale = null): \Collator
*/
protected static function valueRetriever(callable|string $value): callable
{
if (! is_string($value) && is_callable($value)) {
return $value;
}

return fn ($item) => data_get($item, $value);
return is_callable($value) ? $value : fn ($item) => data_get($item, $value);
}
}
2 changes: 1 addition & 1 deletion app/Helpers/ImportantDateHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static function determineType(ContactImportantDate $date): ?string
}

// case: only know the month and day. In this case, we can't calculate
//the age at all
// the age at all
if ($date->day && $date->month && ! $date->year) {
$type = ContactImportantDate::TYPE_MONTH_DAY;
}
Expand Down
Loading

0 comments on commit ab95bd2

Please sign in to comment.