Skip to content

Commit

Permalink
Merge pull request #7 from monicahq/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
sktlmarat authored Apr 1, 2021
2 parents 24f7d08 + ad1cee8 commit 0c2b9b4
Show file tree
Hide file tree
Showing 144 changed files with 18,751 additions and 717 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
path: CHANGELOG.md

package:
needs: semantic-release
needs: semantic
runs-on: ubuntu-latest
name: Package release
if: needs.semantic.outputs.new_release_published == 'true'
Expand Down
1 change: 1 addition & 0 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
[
"semantic-release-github-pullrequest",
{
"baseRef": "master",
"assets": ["CHANGELOG.md"],
"labels": [
"semantic-release",
Expand Down
Binary file added .rnd
Binary file not shown.
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# [2.20.0](https://github.com/monicahq/monica/compare/v2.19.1...v2.20.0) (2021-03-18)


### Bug Fixes

* catch fatal error during install hooks ([#4642](https://github.com/monicahq/monica/issues/4642)) ([1c63ea0](https://github.com/monicahq/monica/commit/1c63ea0b3088e7701c4326bce365a8f09491d6f3))
* fix add gender type ([#4548](https://github.com/monicahq/monica/issues/4548)) ([c0561ce](https://github.com/monicahq/monica/commit/c0561cef7b6c296d41ee42405dec46dae8bb34af))
* fix broken stay in touch frequency input ([#4969](https://github.com/monicahq/monica/issues/4969)) ([500ecc8](https://github.com/monicahq/monica/commit/500ecc830282c79170121c2666a71025aaa65721))
* fix checkbox UI issue in invite user page ([#4546](https://github.com/monicahq/monica/issues/4546)) ([827154e](https://github.com/monicahq/monica/commit/827154e9bebb3a545c71eb73ef204feeaf59ed07))
* fix contact list description display & UI column names ([#4891](https://github.com/monicahq/monica/issues/4891)) ([aa090f8](https://github.com/monicahq/monica/commit/aa090f89846cc5323005636ca77b294953f2c5de))
* fix date missing on journal api ([#4905](https://github.com/monicahq/monica/issues/4905)) ([8de23ba](https://github.com/monicahq/monica/commit/8de23ba01b5b796cc7c9fbe4d22b4f8b8d2d8cd9))
* fix date you met update UX ([#4511](https://github.com/monicahq/monica/issues/4511)) ([288e3d0](https://github.com/monicahq/monica/commit/288e3d0af5bcd331ac83836f25d5b347194f11c9))
* fix docker build ([#4733](https://github.com/monicahq/monica/issues/4733)) ([4fa4561](https://github.com/monicahq/monica/commit/4fa4561c2c4b34d3f39c5266d1581fa2cd9ee75a))
* fix oauth login bad credentials ([#4688](https://github.com/monicahq/monica/issues/4688)) ([28d4cc9](https://github.com/monicahq/monica/commit/28d4cc94bb339e4345ae1a0d9c1a4f45716707ff))
* fix passport setup migration ([#4606](https://github.com/monicahq/monica/issues/4606)) ([e17b89b](https://github.com/monicahq/monica/commit/e17b89b656ea6d002f8347af75aebb631c4d0e4f))
* fix subscriptions list display ([#4967](https://github.com/monicahq/monica/issues/4967)) ([ca21705](https://github.com/monicahq/monica/commit/ca217056bb375d38b4673f6fcfb4db758b775298))
* fix the adorable url migration ([#4963](https://github.com/monicahq/monica/issues/4963)) ([ed2b3b7](https://github.com/monicahq/monica/commit/ed2b3b7667b8ea2c65bd151b4fe0c75364418eb8))
* fix the adorable url migration (again) ([#4964](https://github.com/monicahq/monica/issues/4964)) ([5894065](https://github.com/monicahq/monica/commit/5894065059e5877ba4486c64bc746378ac655fdb))
* update activity with emotions ([#4459](https://github.com/monicahq/monica/issues/4459)) ([d4adb4f](https://github.com/monicahq/monica/commit/d4adb4f206c7637ae5bd21f39009568e0ca639c3))
* update adorable api to api.hello-avatar.com ([#4778](https://github.com/monicahq/monica/issues/4778)) ([527131e](https://github.com/monicahq/monica/commit/527131e4e72f7a0deea5d4a9d8025a6d1a9d15fa))


### Features

* add a confirmation to delete a journal entry [#4308](https://github.com/monicahq/monica/issues/4308) ([#4514](https://github.com/monicahq/monica/issues/4514)) ([18fadb7](https://github.com/monicahq/monica/commit/18fadb77ce7fb4b46fd71ae8205127b9e8c9581d))
* add Android icon for use when bookmarking ([#4798](https://github.com/monicahq/monica/issues/4798)) ([dcee3a9](https://github.com/monicahq/monica/commit/dcee3a943212476f2e96e5c54165daae244c47fc))
* add Apple icons for use when bookmarking. ([#4743](https://github.com/monicahq/monica/issues/4743)) ([a28adcd](https://github.com/monicahq/monica/commit/a28adcdd7d13330271d198c470b6985eee39df11))
* add artisan command to create new account ([#4745](https://github.com/monicahq/monica/issues/4745)) ([b9ee793](https://github.com/monicahq/monica/commit/b9ee793669562c8bf44bd57322e9f5126b2af998))
* add notion of addressbooks ([#3749](https://github.com/monicahq/monica/issues/3749)) ([a18962e](https://github.com/monicahq/monica/commit/a18962ecbf09cb222ac943f8be19362985a7235a))
* add Swedish language ([#4652](https://github.com/monicahq/monica/issues/4652)) ([e1edcad](https://github.com/monicahq/monica/commit/e1edcad04b5cdee0c61883db0d64cf2ca9e9369c))
* allow customization of life event types ([#4243](https://github.com/monicahq/monica/issues/4243)) ([657d824](https://github.com/monicahq/monica/commit/657d824273e8eedc01ed099576571d47d0e26017))
* default gender to unknown ([#4753](https://github.com/monicahq/monica/issues/4753)) ([ebf7c08](https://github.com/monicahq/monica/commit/ebf7c085dd786b174055be389ba5fef35fae861a))
* set and clear personal description now appears in change log ([#4893](https://github.com/monicahq/monica/issues/4893)) ([686a0a1](https://github.com/monicahq/monica/commit/686a0a1f0b2dbbee91fef41eca318a3b9fbd48ff))

# UNRELEASED CHANGES:

### New features:
Expand Down
1 change: 0 additions & 1 deletion app/Console/Commands/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function handle(): void
if ($this->confirmToProceed()) {
try {
$this->artisan('✓ Maintenance mode: on', 'down', [
'--message' => 'Upgrading Monica v'.config('monica.app_version'),
'--retry' => '10',
]);

Expand Down
20 changes: 10 additions & 10 deletions app/Helpers/AuditLogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@ class AuditLogHelper
*
* @return Collection
*/
public static function getCollectionOfAuditForSettings($logs): Collection
public static function getCollectionOfAudits($logs): Collection
{
$logsCollection = collect();

foreach ($logs as $key => $log) {
$object = null;
$link = null;

// the log is about a contact
if (isset($log->object->{'contact_id'})) {
try {
// check if the contact that the log is about still exists
// in that case, we will display a link to point to this contact
$contact = Contact::findOrFail($log->object->{'contact_id'});
$description = trans(
'logs.settings_log_'.$log->action.'_with_name_with_link',
[
'link' => '/people/'.$contact->hashId(),
'name' => $contact->name,
]
);
$object = $contact->name;
$link = route('people.show', ['contact' => $contact]);
} catch (ModelNotFoundException $e) {
// the contact doesn't exist anymore, we don't need a link, we'll only display a name
$description = trans('logs.settings_log_'.$log->action.'_with_name', ['name' => $log->object->{'contact_name'}]);
$object = $log->object->{'contact_name'};
}
$description = trans('logs.settings_log_'.$log->action.'_with_name', ['name' => $object]);
} else {
$description = trans('logs.settings_log_'.$log->action, ['name' => $log->object->{'name'}]);
}

$logsCollection->push([
'author_name' => ($log->author) ? $log->author->name : $log->author_name,
'description' => $description,
'audited_at' => DateHelper::getShortDateWithTime($log->audited_at),
'link' => $link,
'object' => $object,
'audited_at' => $log->audited_at,
]);
}

Expand Down
15 changes: 15 additions & 0 deletions app/Helpers/CollectionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,19 @@ private static function valueRetriever($value)
return data_get($item, $value);
};
}

/**
* Group collection based on a specific property from its items.
*
* @param \Illuminate\Support\Collection $collection
* @param string $property
*
* @return mixed
*/
public static function groupByItemsProperty($collection, $property)
{
return $collection->mapToGroups(function ($item) use ($property) {
return [data_get($item, $property) => $item];
});
}
}
2 changes: 2 additions & 0 deletions app/Helpers/InstanceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public static function getNumberOfPaidSubscribers()
*/
public static function getPlanInformationFromConfig(string $timePeriod): ?array
{
$timePeriod = strtolower($timePeriod);

if ($timePeriod != 'monthly' && $timePeriod != 'annual') {
return null;
}
Expand Down
16 changes: 2 additions & 14 deletions app/Http/Controllers/Contacts/ContactAuditLogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers\Contacts;

use App\Helpers\DateHelper;
use App\Helpers\AuditLogHelper;
use App\Models\Contact\Contact;
use App\Http\Controllers\Controller;

Expand All @@ -18,21 +18,9 @@ public function index(Contact $contact)
->orderBy('created_at', 'desc')
->paginate(15);

$logsCollection = collect();

foreach ($logs as $log) {
$description = trans('logs.contact_log_'.$log->action);

$logsCollection->push([
'author_name' => ($log->author) ? $log->author->name : $log->author_name,
'description' => $description,
'audited_at' => DateHelper::getShortDateWithTime($log->audited_at),
]);
}

return view('people.auditlogs.index')
->withContact($contact)
->withLogs($logsCollection)
->withLogsCollection(AuditLogHelper::getCollectionOfAudits($logs))
->withLogsPagination($logs);
}
}
16 changes: 16 additions & 0 deletions app/Http/Controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,36 @@ public function show(Contact $contact)
$relationships = $contact->relationships;
// get love relationship type
$loveRelationships = $relationships->filter(function ($item) {
$item->relationshipTypeLocalized = $item->relationshipType->getLocalizedName(null, false, $item->ofContact->gender->type ?? null);

return $item->relationshipType->relationshipTypeGroup->name == 'love';
});
$loveRelationships->sortByCollator('relationshipTypeLocalized');

// get family relationship type
$familyRelationships = $relationships->filter(function ($item) {
$item->relationshipTypeLocalized = $item->relationshipType->getLocalizedName(null, false, $item->ofContact->gender->type ?? null);

return $item->relationshipType->relationshipTypeGroup->name == 'family';
});
$familyRelationships->sortByCollator('relationshipTypeLocalized');

// get friend relationship type
$friendRelationships = $relationships->filter(function ($item) {
$item->relationshipTypeLocalized = $item->relationshipType->getLocalizedName(null, false, $item->ofContact->gender->type ?? null);

return $item->relationshipType->relationshipTypeGroup->name == 'friend';
});
$friendRelationships->sortByCollator('relationshipTypeLocalized');

// get work relationship type
$workRelationships = $relationships->filter(function ($item) {
$item->relationshipTypeLocalized = $item->relationshipType->getLocalizedName(null, false, $item->ofContact->gender->type ?? null);

return $item->relationshipType->relationshipTypeGroup->name == 'work';
});
$workRelationships->sortByCollator('relationshipTypeLocalized');

// reminders
$reminders = $contact->activeReminders;
$relevantRemindersFromRelatedContacts = $contact->getBirthdayRemindersAboutRelatedContacts();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Settings/AuditLogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function index()
$accountHasLimitations = AccountHelper::hasLimitations(auth()->user()->account);

return view('settings.auditlog.index')
->withLogsCollection(AuditLogHelper::getCollectionOfAuditForSettings($logs))
->withLogsCollection(AuditLogHelper::getCollectionOfAudits($logs))
->withAccountHasLimitations($accountHasLimitations)
->withLogsPagination($logs);
}
Expand Down
13 changes: 4 additions & 9 deletions app/Http/Controllers/Settings/StorageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ class StorageController extends Controller
*/
public function index()
{
$documents = Document::where('account_id', auth()->user()->account_id)
->orderBy('created_at', 'desc')
->get();

$photos = Photo::where('account_id', auth()->user()->account_id)
->orderBy('created_at', 'desc')
->get();
$documents = Document::where('account_id', auth()->user()->account_id)->get();
$photos = Photo::where('account_id', auth()->user()->account_id)->get();
$elements = $documents->concat($photos)->sortByDesc('created_at');

// size is in bytes in the database
$currentAccountSize = StorageHelper::getAccountStorageSize(auth()->user()->account);
Expand All @@ -37,8 +33,7 @@ public function index()

return view('settings.storage.index')
->withAccountHasLimitations($accountHasLimitations)
->withDocuments($documents)
->withPhotos($photos)
->withElements($elements)
->withCurrentAccountSize($currentAccountSize)
->withAccountLimit(config('monica.max_storage_size'))
->withPercentUsage($percentUsage);
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Settings/SubscriptionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function index()
]);
}

$planId = $account->getSubscribedPlanId();
try {
$nextBillingDate = $account->getNextBillingDate();
} catch (StripeException $e) {
Expand All @@ -55,7 +54,7 @@ public function index()
}

return view('settings.subscriptions.account', [
'planInformation' => InstanceHelper::getPlanInformationFromConfig($planId),
'planInformation' => InstanceHelper::getPlanInformationFromConfig($subscription->name),
'nextBillingDate' => $nextBillingDate,
'subscription' => $subscription,
'hasInvoices' => $hasInvoices,
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Account/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function contacts()
*/
public function contact()
{
return $this->contacts()->first();
return $this->contacts->first();
}

/**
Expand Down
32 changes: 32 additions & 0 deletions app/Models/Contact/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,38 @@ public function getAvatarDefaultURL()
}
}

/**
* Get the adorable avatar URL.
*
* @param string|null $value
* @return string|null
*/
public function getAvatarAdorableUrlAttribute(?string $value): ?string
{
if (isset($value) && $value !== '') {
return Str::of($value)
->after('https://api.adorable.io/avatars/')
->ltrim('/')
->start(Str::finish(config('monica.adorable_api'), '/'));
}

return null;
}

/**
* Set the adorable avatar URL.
*
* @param string|null $value
* @return void
*/
public function setAvatarAdorableUrlAttribute(?string $value)
{
if (isset($value) && $value !== '') {
$value = Str::of($value)->replace(Str::finish(config('monica.adorable_api'), '/'), '');
}
$this->attributes['avatar_adorable_url'] = $value;
}

/**
* Returns the URL of the avatar, properly sized.
* The avatar can come from 4 sources:
Expand Down
1 change: 1 addition & 0 deletions app/Models/Journal/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function getInfoForJournalEntry()
'month_name' => mb_convert_case(DateHelper::getShortMonth($this->date), MB_CASE_UPPER, 'UTF-8'),
'year' => $this->date->year,
'date' => $this->date,
'created_at' => DateHelper::getShortDateWithTime($this->created_at),
];
}
}
9 changes: 9 additions & 0 deletions app/Providers/MacroServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,14 @@ public function boot()
return CollectionHelper::sortByCollator($collect, $callback, $options, $descending);
});
}

if (! Collection::hasMacro('groupByItemsProperty')) {
Collection::macro('groupByItemsProperty', function ($property) {
/** @var Collection */
$collect = $this;

return CollectionHelper::groupByItemsProperty($collect, $property);
});
}
}
}
Loading

0 comments on commit 0c2b9b4

Please sign in to comment.