/** * @param ContentInterface|PosterInterface $item * * @return bool */ public function isPoster($item) { if (!$this->logged()) { return false; } return (bool) array_intersect([$this->getId(), $this->getUserId()], [$item->getId(), $item->getPosterId(), $item->getUserId()]); }
/** * @param string $feedType * @param ContentInterface $about * @param array $params * * @return Feed * @throws \InvalidArgumentException */ public function addItemFeed($feedType, ContentInterface $about, $params = []) { list($privacyType, $privacyValue) = $about->getPrivacy('view'); $poster = app()->find($about->getPosterType(), $about->getPosterId()); $parent = app()->find($about->getParentType(), $about->getParentId()); $story = null; $hashtag = null; $peopletag = null; $story = $about->getStory(); $peopletag = $about->getPeople(); if (!empty($story)) { $hashtag = $this->getHashTagsInStory($story); } // parse story content to load hash tags. $feed = new Feed(['feed_type' => $feedType, 'poster_id' => $about->getPosterId(), 'poster_type' => $about->getPosterType(), 'parent_id' => $about->getParentId(), 'parent_type' => $about->getParentType(), 'about_id' => $about->getId(), 'about_type' => $about->getType(), 'privacy_type' => (int) $privacyType, 'privacy_value' => (int) $privacyValue, 'created_at' => KENDO_DATE_TIME, 'params_text' => json_encode($params)]); $feed->save(); $feed->validate(true, false); /** * add feed to hashtag list */ if (!empty($hashtag)) { foreach ($hashtag as $tag) { $this->addHashTag($feed, $tag); } } $this->putFeedToStream($feed, $poster, $parent, $peopletag); app()->notificationService()->subscribe($poster, $about); return $feed; }