Skip to content

Commit

Permalink
Merge pull request #33 from KhushbuFuletra/feature-add-object-source
Browse files Browse the repository at this point in the history
feat(ObjectSource): Add fields to record object source
  • Loading branch information
nyeholt authored Mar 24, 2020
2 parents 2a80a0e + 9ae5abf commit 97ebec7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Model/InternalNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class InternalNotification extends DataObject {
private static $table_name = 'InternalNotification';

private static $db = [
'Title' => 'Varchar(255)',
'Message' => 'Text',
Expand All @@ -24,10 +24,16 @@ class InternalNotification extends DataObject {
private static $has_one = [
'To' => Member::class,
'From' => Member::class,
'SourceObject' => DataObject::class,
'SourceNotification' => SystemNotification::class,
];

private static $summary_fields = [
'Title', 'To.Name', 'SentOn'
'Title' => 'Title',
'To.Name' => 'To',
'SentOn' => 'Sent on',
'IsSeen.Nice' => 'Seen?',
'IsRead.Nice' => 'Read?'
];

private static $default_sort = 'ID DESC';
Expand Down Expand Up @@ -62,4 +68,4 @@ public function canEdit($member = null) {
return $member && (!$this->ID || $this->ToID == $member->ID);
}

}
}
3 changes: 3 additions & 0 deletions src/Service/InternalNotificationSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Symbiote\Notifications\Service;

use Exception;
use Symbiote\Notifications\Model\NotificationSender;
use Symbiote\Notifications\Model\SystemNotification;
use Symbiote\Notifications\Model\InternalNotification;
Expand Down Expand Up @@ -78,6 +79,8 @@ public function sendToUser($notification, $context, $user, $data)
'ToID' => $user->ID,
'FromID' => Member::currentUserID(),
'SentOn' => date('Y-m-d H:i:s'),
'SourceObjectID' => $context->ID,
'SourceNotificationID' => $notification->ID,
'Context' => [
'ClassName' => get_class($context),
'ID' => $context->ID,
Expand Down

0 comments on commit 97ebec7

Please sign in to comment.