Skip to content

feat: add call in contact feed #7301

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

Open
wants to merge 5 commits 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
1 change: 1 addition & 0 deletions lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "اللغة الافتراضية: :value",
"Log a call": "تسجيل مكالمة",
"Log details": "تفاصيل السجل",
"logged a call": "قمت بتسجيل مكالمة",
"logged the mood": "سجلت المزاج",
"Log in": "تسجيل الدخول",
"Login": "تسجيل الدخول",
Expand Down
1 change: 1 addition & 0 deletions lang/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "স্থানীয় ডিফল্ট: :value",
"Log a call": "একটি কল লগ",
"Log details": "লগ বিবরণ",
"logged a call": "একটি কল লগ",
"logged the mood": "মেজাজ লগ",
"Log in": "লগইন করুন",
"Login": "লগইন",
Expand Down
1 change: 1 addition & 0 deletions lang/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions lang/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions lang/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Προεπιλογή τοπικής ρύθμισης: :value",
"Log a call": "Καταγράψτε μια κλήση",
"Log details": "Στοιχεία καταγραφής",
"logged a call": "κατέγραψε μια κλήση",
"logged the mood": "κατέγραψε τη διάθεση",
"Log in": "Συνδεθείτε",
"Login": "Είσοδος",
Expand Down
1 change: 1 addition & 0 deletions lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Configuración regional predeterminada: :value",
"Log a call": "Registrar una llamada",
"Log details": "Detalles del registro",
"logged a call": "registró una llamada",
"logged the mood": "registró el estado de ánimo",
"Log in": "Iniciar sesión",
"Login": "Iniciar sesión",
Expand Down
1 change: 1 addition & 0 deletions lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Paramètres régionaux par défaut : :value",
"Log a call": "Enregistrer un appel",
"Log details": "Détails du journal",
"logged a call": "enregistré un appel",
"logged the mood": "a enregistré l’humeur",
"Log in": "Se connecter",
"Login": "Connexion",
Expand Down
1 change: 1 addition & 0 deletions lang/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "ברירת המחדל של המקום: :value",
"Log a call": "רישום שיחה",
"Log details": "פרטי יומן",
"logged a call": "רשם שיחה",
"logged the mood": "רשם את מצב הרוח",
"Log in": "התחבר",
"Login": "התחברות",
Expand Down
1 change: 1 addition & 0 deletions lang/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "स्थानीय डिफ़ॉल्ट: :value",
"Log a call": "कॉल लॉग करें",
"Log details": "लॉग विवरण",
"logged a call": "कॉल लॉग किया",
"logged the mood": "मूड लॉग किया",
"Log in": "लॉग इन करें",
"Login": "लॉगिन करें",
Expand Down
1 change: 1 addition & 0 deletions lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Impostazioni locali predefinite: :value",
"Log a call": "Registra una chiamata",
"Log details": "Dettagli del registro",
"logged a call": "registrato una chiamata",
"logged the mood": "registrato l’umore",
"Log in": "Accedi",
"Login": "Accedi",
Expand Down
1 change: 1 addition & 0 deletions lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "ロケールのデフォルト: :value",
"Log a call": "通話を記録する",
"Log details": "ログの詳細",
"logged a call": "通話を記録しました",
"logged the mood": "気分を記録した",
"Log in": "ログイン",
"Login": "ログイン",
Expand Down
1 change: 1 addition & 0 deletions lang/ml.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@
"Locale default: :value": "പ്രാദേശിക സ്ഥിരസ്ഥിതി: :value",
"Log a call": "ഒരു കോൾ ലോഗ് ചെയ്യുക",
"Log details": "ലോഗ് വിശദാംശങ്ങൾ",
"logged a call": "ഒരു കോൾ ലോഗ് ചെയ്തു",
"logged the mood": "മാനസികാവസ്ഥ രേഖപ്പെടുത്തി",
"Log in": "ലോഗിൻ",
"Login": "ലോഗിൻ",
Expand Down
1 change: 1 addition & 0 deletions lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Standaard landinstelling: :value",
"Log a call": "Een oproep registreren",
"Log details": "Loggegevens",
"logged a call": "een oproep geregistreerd",
"logged the mood": "registreerde de stemming",
"Log in": "Inloggen",
"Login": "Inloggen",
Expand Down
1 change: 1 addition & 0 deletions lang/nn.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Standard standard: :value",
"Log a call": "Logg en samtale",
"Log details": "Loggdetaljer",
"logged a call": "logget en samtale",
"logged the mood": "logget stemningen",
"Log in": "Logg Inn",
"Login": "Logg inn",
Expand Down
1 change: 1 addition & 0 deletions lang/pa.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@
"Locale default: :value": "ਲੋਕੇਲ ਡਿਫੌਲਟ: :value",
"Log a call": "ਇੱਕ ਕਾਲ ਲੌਗ ਕਰੋ",
"Log details": "ਲੌਗ ਵੇਰਵੇ",
"logged a call": "ਇੱਕ ਕਾਲ ਲੌਗ ਕੀਤੀ",
"logged the mood": "ਮੂਡ ਨੂੰ ਲੌਗ ਕੀਤਾ",
"Log in": "ਲਾਗਿਨ",
"Login": "ਲਾਗਿਨ",
Expand Down
1 change: 1 addition & 0 deletions lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Domyślne ustawienia regionalne: :value",
"Log a call": "Zarejestruj połączenie",
"Log details": "Szczegóły dziennika",
"logged a call": "zarejestrował połączenie",
"logged the mood": "zarejestrował nastrój",
"Log in": "Zaloguj się",
"Login": "Logowanie",
Expand Down
1 change: 1 addition & 0 deletions lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Padrão de localidade: :value",
"Log a call": "Registrar uma chamada",
"Log details": "Detalhes do registro",
"logged a call": "registrou uma chamada",
"logged the mood": "registrou o clima",
"Log in": "Iniciar sessão",
"Login": "Iniciar Sessão",
Expand Down
1 change: 1 addition & 0 deletions lang/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Padrão de localidade: :value",
"Log a call": "Registrar uma chamada",
"Log details": "Detalhes do registro",
"logged a call": "registrou uma chamada",
"logged the mood": "registrou o clima",
"Log in": "Entrar",
"Login": "Entrar",
Expand Down
1 change: 1 addition & 0 deletions lang/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Localizare implicită: :value",
"Log a call": "Înregistrează un apel",
"Log details": "Detalii jurnal",
"logged a call": "a înregistrat un apel",
"logged the mood": "a înregistrat starea de spirit",
"Log in": "Autentificare",
"Login": "Autentificare",
Expand Down
1 change: 1 addition & 0 deletions lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Локаль по умолчанию: :value",
"Log a call": "Зарегистрировать звонок",
"Log details": "Подробности журнала",
"logged a call": "зарегистрировал звонок",
"logged the mood": "записал настроение",
"Log in": "Войти",
"Login": "Войти",
Expand Down
1 change: 1 addition & 0 deletions lang/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Standard för språk: :value",
"Log a call": "Logga ett samtal",
"Log details": "Loggdetaljer",
"logged a call": "loggade ett samtal",
"logged the mood": "registrerade stämningen",
"Log in": "Inloggning",
"Login": "Logga in",
Expand Down
1 change: 1 addition & 0 deletions lang/te.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@
"Locale default: :value": "లొకేల్ డిఫాల్ట్: :value",
"Log a call": "కాల్‌ని లాగిన్ చేయండి",
"Log details": "లాగ్ వివరాలు",
"logged a call": "కాల్ లాగ్ చేసాడు",
"logged the mood": "మానసిక స్థితిని లాగిన్ చేసింది",
"Log in": "ప్రవేశించండి",
"Login": "ప్రవేశించండి",
Expand Down
1 change: 1 addition & 0 deletions lang/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Yerel ayar varsayılanı: :value",
"Log a call": "Bir çağrıyı günlüğe kaydet",
"Log details": "Günlük ayrıntıları",
"logged a call": "bir çağrı kaydettim",
"logged the mood": "ruh halini kaydetti",
"Log in": "Giriş yap",
"Login": "Giriş Yap",
Expand Down
1 change: 1 addition & 0 deletions lang/ur.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "لوکل ڈیفالٹ: :value",
"Log a call": "کال لاگ ان کریں۔",
"Log details": "لاگ تفصیلات",
"logged a call": "کال لاگ ان کی",
"logged the mood": "موڈ کو لاگو کیا",
"Log in": "میں لاگ ان کریں",
"Login": "لاگ ان کریں",
Expand Down
1 change: 1 addition & 0 deletions lang/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "Mặc định ngôn ngữ: :value",
"Log a call": "Đăng nhập cuộc gọi",
"Log details": "Chi tiết nhật ký",
"logged a call": "đã ghi lại một cuộc gọi",
"logged the mood": "ghi lại tâm trạng",
"Log in": "Đăng nhập",
"Login": "Đăng nhập",
Expand Down
1 change: 1 addition & 0 deletions lang/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "语言环境默认值::value",
"Log a call": "记录通话",
"Log details": "日志详情",
"logged a call": "已记录通话",
"logged the mood": "记录心情",
"Log in": "登录",
"Login": "登录",
Expand Down
1 change: 1 addition & 0 deletions lang/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
"Locale default: :value": "語言環境預設值::value",
"Log a call": "記錄通話",
"Log details": "日誌詳情",
"logged a call": "已記錄通話",
"logged the mood": "記錄心情",
"Log in": "登入",
"Login": "登入",
Expand Down
5 changes: 5 additions & 0 deletions resources/js/Shared/Modules/Feed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
:data="feedItem.data"
:contact-view-mode="contactViewMode" />

<generic-action
v-if="feedItem.action === 'call_created'"
:data="feedItem.data"
:contact-view-mode="contactViewMode" />

<label-assigned
v-if="feedItem.action === 'label_assigned'"
:data="feedItem.data"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,11 @@ private function executeService(User $author, Account $account, Vault $vault, Co
'who_initiated' => 'contact',
'emotion_id' => optional($emotion)->id,
]);

$this->assertDatabaseHas('contact_feed_items', [
'contact_id' => $contact->id,
'feedable_id' => $call->id,
'feedable_type' => 'App\Models\Call',
]);
}
}