Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add call in contact feed #7301

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions app/Domains/Contact/ManageCalls/Services/CreateCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Interfaces\ServiceInterface;
use App\Models\Call;
use App\Models\ContactFeedItem;
use App\Services\BaseService;
use Carbon\Carbon;

Expand Down Expand Up @@ -57,6 +58,7 @@ public function execute(array $data): Call

$this->createCall();
$this->updateLastEditedDate();
$this->createFeedItem();

return $this->call;
}
Expand Down Expand Up @@ -93,4 +95,14 @@ private function updateLastEditedDate(): void
$this->contact->last_updated_at = Carbon::now();
$this->contact->save();
}

private function createFeedItem(): void
{
$feedItem = ContactFeedItem::create([
'author_id' => $this->author->id,
'contact_id' => $this->contact->id,
'action' => ContactFeedItem::ACTION_CALL_CREATED,
]);
$this->call->feedItem()->save($feedItem);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Domains\Contact\ManageContactFeed\Web\ViewHelpers\Actions;

use App\Models\ContactFeedItem;
use App\Models\User;

class ActionFeedCall
{
public static function data(ContactFeedItem $item, User $user): array
{
$contact = $item->contact;
$call = $item->feedable;

return [
'call' => [
'object' => $call ? [
'id' => $call->id,
'type' => $call->type ? $call->type : null,
] : null,
'description' => $item->description,
],
'contact' => [
'id' => $contact->id,
'name' => $contact->name,
'age' => $contact->age,
'avatar' => $contact->avatar,
'url' => route('contact.show', [
'vault' => $contact->vault_id,
'contact' => $contact->id,
]),
],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Domains\Contact\ManageContactFeed\Web\ViewHelpers;

use App\Domains\Contact\ManageContactFeed\Web\ViewHelpers\Actions\ActionFeedAddress;
use App\Domains\Contact\ManageContactFeed\Web\ViewHelpers\Actions\ActionFeedCall;
use App\Domains\Contact\ManageContactFeed\Web\ViewHelpers\Actions\ActionFeedContactInformation;
use App\Domains\Contact\ManageContactFeed\Web\ViewHelpers\Actions\ActionFeedGenericContactInformation;
use App\Domains\Contact\ManageContactFeed\Web\ViewHelpers\Actions\ActionFeedGoal;
Expand Down Expand Up @@ -72,6 +73,7 @@ private static function getSentence(ContactFeedItem $item): mixed
'unfavorited' => trans('removed the contact from the favorites'),
'changed_avatar' => trans('updated the avatar of the contact'),
'mood_tracking_event_added' => trans('logged the mood'),
'call_created' => trans('logged a call'),
default => trans('unknown action'),
};
}
Expand Down Expand Up @@ -141,6 +143,9 @@ private static function getData(ContactFeedItem $item, User $user)
case 'mood_tracking_event_deleted':
return ActionFeedMoodTrackingEvent::data($item, $user);

case 'call_created':
return ActionFeedCall::data($item, $user);

default:
return ActionFeedGenericContactInformation::data($item);
}
Expand Down
9 changes: 9 additions & 0 deletions app/Models/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphOne;

class Call extends Model
{
Expand Down Expand Up @@ -83,4 +84,12 @@ public function emotion(): BelongsTo
{
return $this->belongsTo(Emotion::class);
}

/**
* Get the mood tracking event's feed item.
*/
public function feedItem(): MorphOne
{
return $this->morphOne(ContactFeedItem::class, 'feedable');
}
}
2 changes: 2 additions & 0 deletions app/Models/ContactFeedItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class ContactFeedItem extends Model

public const ACTION_MOOD_TRACKING_EVENT_DESTROYED = 'mood_tracking_event_deleted';

public const ACTION_CALL_CREATED = 'call_created';

/**
* The attributes that are mass assignable.
*
Expand Down
7 changes: 5 additions & 2 deletions lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,13 @@
"Locale default: :value": "اللغة الافتراضية: :value",
"Log a call": "تسجيل مكالمة",
"Log details": "تفاصيل السجل",
"logged a call": "قمت بتسجيل مكالمة",
"logged the mood": "سجلت المزاج",
"Log in": "تسجيل الدخول",
"Login": "تسجيل الدخول",
"Login with:": "تسجيل الدخول مع:",
"Log Out": "تسجيل الخروج",
"Logout": "تسجيل الخروج",
"Log Out": "تسجيل الخروج",
"Log Out Other Browser Sessions": "تسجيل الخروج من جلساتك على المتصفحات الأخرى",
"Longest streak": "أطول أثر",
"Love": "حب",
Expand Down Expand Up @@ -641,8 +642,8 @@
"New Password": "كلمة مرور جديدة",
"New to Monica?": "هل أنت جديد في Monica؟",
"Next": "التالي",
"Nickname": "كنية",
"nickname": "كنية",
"Nickname": "كنية",
"No cities have been added yet in any contact’s addresses.": "لم تتم إضافة أي مدن حتى الآن في عناوين أي جهة اتصال.",
"No contacts found.": "لم يتم العثور على جهات اتصال.",
"No countries have been added yet in any contact’s addresses.": "لم تتم إضافة أي دولة حتى الآن في عناوين أي جهة اتصال.",
Expand Down Expand Up @@ -984,6 +985,7 @@
"The page has been deleted": "تم حذف الصفحة",
"The page has been updated": "تم تحديث الصفحة",
"The password is incorrect.": "كلمة المرور غير صحيحة.",
"The password should be at least 8 characters long.": "يجب أن تتكون كلمة المرور من 8 أحرف على الأقل.",
"The pet category has been created": "تم إنشاء فئة الحيوانات الأليفة",
"The pet category has been deleted": "تم حذف فئة الحيوانات الأليفة",
"The pet category has been updated": "تم تحديث فئة الحيوانات الأليفة",
Expand Down Expand Up @@ -1162,6 +1164,7 @@
"Verified": "تم التحقق",
"Verify Email Address": "التحقق من عنوان البريد الإلكتروني",
"Verify this email address": "تحقق من هذا البريد الألكتروني",
"Version :version.": "الإصدار :version.",
"Version :version — commit [:short](:url).": "الإصدار :version — الالتزام [:short](:url).",
"Via Telegram": "عبر برقية",
"Video call": "مكالمة فيديو",
Expand Down
7 changes: 5 additions & 2 deletions lang/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,13 @@
"Locale default: :value": "স্থানীয় ডিফল্ট: :value",
"Log a call": "একটি কল লগ",
"Log details": "লগ বিবরণ",
"logged a call": "একটি কল লগ",
"logged the mood": "মেজাজ লগ",
"Log in": "লগইন করুন",
"Login": "লগইন",
"Login with:": "লগইন করুন:",
"Log Out": "লগ-আউট",
"Logout": "লগ-আউট",
"Log Out": "লগ-আউট",
"Log Out Other Browser Sessions": "অন্য ব্রাউজার সেশনে লগ আউট করুন",
"Longest streak": "দীর্ঘতম ধারা",
"Love": "ভালবাসা",
Expand Down Expand Up @@ -641,8 +642,8 @@
"New Password": "নতুন পাসওয়ার্ড",
"New to Monica?": "Monica নতুন?",
"Next": "পরবর্তী",
"Nickname": "ডাকনাম",
"nickname": "ডাকনাম",
"Nickname": "ডাকনাম",
"No cities have been added yet in any contact’s addresses.": "কোনো পরিচিতির ঠিকানায় এখনো কোনো শহর যোগ করা হয়নি।",
"No contacts found.": "কোন পরিচিতি পাওয়া যায়নি.",
"No countries have been added yet in any contact’s addresses.": "কোনো পরিচিতির ঠিকানায় এখনো কোনো দেশ যোগ করা হয়নি।",
Expand Down Expand Up @@ -984,6 +985,7 @@
"The page has been deleted": "পৃষ্ঠাটি মুছে ফেলা হয়েছে",
"The page has been updated": "পাতা আপডেট করা হয়েছে",
"The password is incorrect.": "পাসওয়ার্ডটি ভুল।",
"The password should be at least 8 characters long.": "পাসওয়ার্ডটি কমপক্ষে 8 অক্ষর দীর্ঘ হওয়া উচিত।",
"The pet category has been created": "পোষা ক্যাটাগরি তৈরি করা হয়েছে",
"The pet category has been deleted": "পোষা শ্রেণীবিভাগ মুছে ফেলা হয়েছে",
"The pet category has been updated": "পোষা বিভাগ আপডেট করা হয়েছে",
Expand Down Expand Up @@ -1162,6 +1164,7 @@
"Verified": "যাচাই",
"Verify Email Address": "ই-মেইল ঠিকানা যাচাই করুন",
"Verify this email address": "এই ই - মেইল ঠিকানা যাচাই করুন",
"Version :version.": "সংস্করণ :version।",
"Version :version — commit [:short](:url).": "সংস্করণ :version — কমিট [:short](:url)।",
"Via Telegram": "টেলিগ্রামের মাধ্যমে",
"Video call": "ভিডিও কল",
Expand Down
7 changes: 5 additions & 2 deletions lang/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,13 @@
"Locale default: :value": "Localització predeterminada: :value",
"Log a call": "Registre una trucada",
"Log details": "Detalls del registre",
"logged a call": "ha registrat una trucada",
"logged the mood": "registrat l’estat d’ànim",
"Log in": "Entrar",
"Login": "Entrar",
"Login with:": "Accedir amb:",
"Log Out": "Sortir",
"Logout": "Sortir",
"Log Out": "Sortir",
"Log Out Other Browser Sessions": "Tanca la sessió d’altres navegadors",
"Longest streak": "Ratxa més llarga",
"Love": "Amor",
Expand Down Expand Up @@ -641,8 +642,8 @@
"New Password": "Contrasenya Nova",
"New to Monica?": "Nou a la Monica?",
"Next": "Pròxim",
"Nickname": "Pseudònim",
"nickname": "sobrenom",
"Nickname": "Pseudònim",
"No cities have been added yet in any contact’s addresses.": "Encara no s’ha afegit cap ciutat a les adreces de cap contacte.",
"No contacts found.": "No s’han trobat contactes.",
"No countries have been added yet in any contact’s addresses.": "Encara no s’ha afegit cap país a les adreces de cap contacte.",
Expand Down Expand Up @@ -984,6 +985,7 @@
"The page has been deleted": "La pàgina s’ha suprimit",
"The page has been updated": "La pàgina s’ha actualitzat",
"The password is incorrect.": "Contrasenya no és correcta.",
"The password should be at least 8 characters long.": "La contrasenya ha de tenir almenys 8 caràcters.",
"The pet category has been created": "S’ha creat la categoria de mascota",
"The pet category has been deleted": "La categoria de la mascota s’ha suprimit",
"The pet category has been updated": "La categoria de la mascota s’ha actualitzat",
Expand Down Expand Up @@ -1162,6 +1164,7 @@
"Verified": "Verificat",
"Verify Email Address": "Confirmeu la vostra adreça electrònica",
"Verify this email address": "Verifica aquesta adreça de correu electrònic",
"Version :version.": "Versió :version.",
"Version :version — commit [:short](:url).": "Versió :version — commit [:short](:url).",
"Via Telegram": "A través de Telegram",
"Video call": "Videotrucada",
Expand Down
7 changes: 5 additions & 2 deletions lang/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,13 @@
"Locale default: :value": "Landestandard: :value",
"Log a call": "Log et opkald",
"Log details": "Log detaljer",
"logged a call": "logget et opkald",
"logged the mood": "logget stemningen",
"Log in": "Log ind",
"Login": "Log ind",
"Login with:": "Login med:",
"Log Out": "Log ud",
"Logout": "Log ud",
"Log Out": "Log ud",
"Log Out Other Browser Sessions": "Log ud af andre browsersessioner",
"Longest streak": "Længste streak",
"Love": "Elsker",
Expand Down Expand Up @@ -641,8 +642,8 @@
"New Password": "Nyt kodeord",
"New to Monica?": "Ny for Monica?",
"Next": "Næste",
"Nickname": "Kaldenavn",
"nickname": "kaldenavn",
"Nickname": "Kaldenavn",
"No cities have been added yet in any contact’s addresses.": "Ingen byer er blevet tilføjet endnu i nogen kontakts adresser.",
"No contacts found.": "Ingen kontakter fundet.",
"No countries have been added yet in any contact’s addresses.": "Ingen lande er blevet tilføjet endnu i nogen kontakts adresser.",
Expand Down Expand Up @@ -984,6 +985,7 @@
"The page has been deleted": "Siden er blevet slettet",
"The page has been updated": "Siden er blevet opdateret",
"The password is incorrect.": "Adgangskoden er forkert.",
"The password should be at least 8 characters long.": "Adgangskoden skal være på mindst 8 tegn.",
"The pet category has been created": "Kæledyrskategorien er blevet oprettet",
"The pet category has been deleted": "Kæledyrskategorien er blevet slettet",
"The pet category has been updated": "Kæledyrskategorien er blevet opdateret",
Expand Down Expand Up @@ -1162,6 +1164,7 @@
"Verified": "Verificeret",
"Verify Email Address": "Bekræft email-adresse",
"Verify this email address": "Bekræft denne e-mailadresse",
"Version :version.": "Version :version.",
"Version :version — commit [:short](:url).": "Version :version — commit [:short](:url).",
"Via Telegram": "Via Telegram",
"Video call": "Videoopkald",
Expand Down
7 changes: 5 additions & 2 deletions lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,13 @@
"Locale default: :value": "Gebietsschema-Standard: :value",
"Log a call": "Einen Anruf protokollieren",
"Log details": "Protokolldetails",
"logged a call": "einen Anruf protokolliert",
"logged the mood": "protokollierte die Stimmung",
"Log in": "Einloggen",
"Login": "Anmelden",
"Login with:": "Einloggen mit:",
"Log Out": "Abmelden",
"Logout": "Abmelden",
"Log Out": "Abmelden",
"Log Out Other Browser Sessions": "Andere Browser-Sitzungen abmelden",
"Longest streak": "Längste Strähne",
"Love": "Liebe",
Expand Down Expand Up @@ -641,8 +642,8 @@
"New Password": "Neues Passwort",
"New to Monica?": "Neu bei Monica?",
"Next": "Nächste",
"Nickname": "Spitzname",
"nickname": "Spitzname",
"Nickname": "Spitzname",
"No cities have been added yet in any contact’s addresses.": "Zu den Kontaktadressen wurden noch keine Städte hinzugefügt.",
"No contacts found.": "Keine Kontakte gefunden.",
"No countries have been added yet in any contact’s addresses.": "Es wurden noch keine Länder zu den Kontaktadressen hinzugefügt.",
Expand Down Expand Up @@ -984,6 +985,7 @@
"The page has been deleted": "Die Seite wurde gelöscht",
"The page has been updated": "Die Seite wurde aktualisiert",
"The password is incorrect.": "Das Passwort ist falsch.",
"The password should be at least 8 characters long.": "Das Passwort sollte mindestens 8 Zeichen lang sein.",
"The pet category has been created": "Die Haustierkategorie wurde erstellt",
"The pet category has been deleted": "Die Haustierkategorie wurde gelöscht",
"The pet category has been updated": "Die Haustierkategorie wurde aktualisiert",
Expand Down Expand Up @@ -1162,6 +1164,7 @@
"Verified": "Verifiziert",
"Verify Email Address": "E-Mail-Adresse bestätigen",
"Verify this email address": "Bestätigen Sie diese E-Mail-Adresse",
"Version :version.": "Version :version.",
"Version :version — commit [:short](:url).": "Version :version — Commit [:short](:url).",
"Via Telegram": "Per Telegramm",
"Video call": "Videoanruf",
Expand Down
7 changes: 5 additions & 2 deletions lang/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,13 @@
"Locale default: :value": "Προεπιλογή τοπικής ρύθμισης: :value",
"Log a call": "Καταγράψτε μια κλήση",
"Log details": "Στοιχεία καταγραφής",
"logged a call": "κατέγραψε μια κλήση",
"logged the mood": "κατέγραψε τη διάθεση",
"Log in": "Συνδεθείτε",
"Login": "Είσοδος",
"Login with:": "Συνδέσου με:",
"Log Out": "αποσυνδεθείτε",
"Logout": "Έξοδος",
"Log Out": "αποσυνδεθείτε",
"Log Out Other Browser Sessions": "Αποσυνδεθείτε Από Άλλες Συνεδρίες Του Προγράμματος Περιήγησης",
"Longest streak": "Το μεγαλύτερο σερί",
"Love": "Αγάπη",
Expand Down Expand Up @@ -641,8 +642,8 @@
"New Password": "Νέος Κωδικός Πρόσβασης",
"New to Monica?": "Νέος στη Monica;",
"Next": "Επόμενο",
"Nickname": "Παρατσούκλι",
"nickname": "παρατσούκλι",
"Nickname": "Παρατσούκλι",
"No cities have been added yet in any contact’s addresses.": "Δεν έχουν προστεθεί ακόμη πόλεις στις διευθύνσεις οποιασδήποτε επαφής.",
"No contacts found.": "Δεν βρέθηκαν επαφές.",
"No countries have been added yet in any contact’s addresses.": "Δεν έχουν προστεθεί ακόμη χώρες στις διευθύνσεις οποιασδήποτε επαφής.",
Expand Down Expand Up @@ -984,6 +985,7 @@
"The page has been deleted": "Η σελίδα έχει διαγραφεί",
"The page has been updated": "Η σελίδα έχει ενημερωθεί",
"The password is incorrect.": "Ο κωδικός πρόσβασης είναι λανθασμένος.",
"The password should be at least 8 characters long.": "Ο κωδικός πρόσβασης πρέπει να αποτελείται από τουλάχιστον 8 χαρακτήρες.",
"The pet category has been created": "Η κατηγορία κατοικίδιων έχει δημιουργηθεί",
"The pet category has been deleted": "Η κατηγορία κατοικίδιων ζώων έχει διαγραφεί",
"The pet category has been updated": "Η κατηγορία κατοικίδιων ζώων έχει ενημερωθεί",
Expand Down Expand Up @@ -1162,6 +1164,7 @@
"Verified": "Επαληθεύτηκε",
"Verify Email Address": "Επιβεβαιώστε τη διεύθυνση ηλεκτρονικού ταχυδρομείου",
"Verify this email address": "Επαληθεύστε αυτήν τη διεύθυνση ηλεκτρονικού ταχυδρομείου",
"Version :version.": "Έκδοση :version.",
"Version :version — commit [:short](:url).": "Έκδοση :version — δέσμευση [:short](:url).",
"Via Telegram": "Μέσω Telegram",
"Video call": "Κλήση βίντεο",
Expand Down
Loading