Rename notification.sender

This commit is contained in:
Toby Zerner 2018-08-24 21:46:28 +09:30
parent 3a21b44a71
commit f0d296bfb0
9 changed files with 10 additions and 10 deletions

View File

@ -14,6 +14,6 @@ Object.assign(Notification.prototype, {
additionalUnreadCount: computed('unreadCount', unreadCount => Math.max(0, unreadCount - 1)), additionalUnreadCount: computed('unreadCount', unreadCount => Math.max(0, unreadCount - 1)),
user: Model.hasOne('user'), user: Model.hasOne('user'),
sender: Model.hasOne('sender'), fromUser: Model.hasOne('fromUser'),
subject: Model.hasOne('subject') subject: Model.hasOne('subject')
}); });

View File

@ -20,6 +20,6 @@ export default class DiscussionRenamedNotification extends Notification {
} }
content() { content() {
return app.translator.trans('core.forum.notifications.discussion_renamed_text', {user: this.props.notification.sender()}); return app.translator.trans('core.forum.notifications.discussion_renamed_text', {user: this.props.notification.fromUser()});
} }
} }

View File

@ -26,7 +26,7 @@ export default class Notification extends Component {
if (!isInitialized) $(element).click(this.markAsRead.bind(this)); if (!isInitialized) $(element).click(this.markAsRead.bind(this));
}}> }}>
{avatar(notification.sender())} {avatar(notification.fromUser())}
{icon(this.icon(), {className: 'Notification-icon'})} {icon(this.icon(), {className: 'Notification-icon'})}
<span className="Notification-content">{this.content()}</span> <span className="Notification-content">{this.content()}</span>
{humanTime(notification.createdAt())} {humanTime(notification.createdAt())}

View File

@ -30,7 +30,7 @@ class ListNotificationsController extends AbstractListController
* {@inheritdoc} * {@inheritdoc}
*/ */
public $include = [ public $include = [
'sender', 'fromUser',
'subject', 'subject',
'subject.discussion' 'subject.discussion'
]; ];

View File

@ -65,7 +65,7 @@ class NotificationSerializer extends AbstractSerializer
* @param Notification $notification * @param Notification $notification
* @return \Tobscure\JsonApi\Relationship * @return \Tobscure\JsonApi\Relationship
*/ */
protected function sender($notification) protected function fromUser($notification)
{ {
return $this->hasOne($notification, BasicUserSerializer::class); return $this->hasOne($notification, BasicUserSerializer::class);
} }

View File

@ -23,7 +23,7 @@ interface BlueprintInterface
* *
* @return \Flarum\User\User|null * @return \Flarum\User\User|null
*/ */
public function getSender(); public function getFromUser();
/** /**
* Get the model that is the subject of this activity. * Get the model that is the subject of this activity.

View File

@ -32,7 +32,7 @@ class DiscussionRenamedBlueprint implements BlueprintInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSender() public function getFromUser()
{ {
return $this->post->user; return $this->post->user;
} }

View File

@ -31,7 +31,7 @@ use Flarum\User\User;
* *
* @property int $id * @property int $id
* @property int $user_id * @property int $user_id
* @property int|null $sender_id * @property int|null $from_user_id
* @property string $type * @property string $type
* @property int|null $subject_id * @property int|null $subject_id
* @property mixed|null $data * @property mixed|null $data
@ -39,7 +39,7 @@ use Flarum\User\User;
* @property \Carbon\Carbon $read_at * @property \Carbon\Carbon $read_at
* @property \Carbon\Carbon $deleted_at * @property \Carbon\Carbon $deleted_at
* @property \Flarum\User\User|null $user * @property \Flarum\User\User|null $user
* @property \Flarum\User\User|null $sender * @property \Flarum\User\User|null $fromUser
* @property \Flarum\Database\AbstractModel|null $subject * @property \Flarum\Database\AbstractModel|null $subject
*/ */
class Notification extends AbstractModel class Notification extends AbstractModel

View File

@ -226,7 +226,7 @@ class NotificationSyncer
{ {
return [ return [
'type' => $blueprint::getType(), 'type' => $blueprint::getType(),
'from_user_id' => ($sender = $blueprint->getSender()) ? $sender->id : null, 'from_user_id' => ($fromUser = $blueprint->getFromUser()) ? $fromUser->id : null,
'subject_id' => ($subject = $blueprint->getSubject()) ? $subject->id : null, 'subject_id' => ($subject = $blueprint->getSubject()) ? $subject->id : null,
'data' => ($data = $blueprint->getData()) ? json_encode($data) : null 'data' => ($data = $blueprint->getData()) ? json_encode($data) : null
]; ];