...
 
Commits (2)
......@@ -144,7 +144,7 @@ class comments implements Interfaces\Api
break;
case is_numeric($pages[0]):
default:
$entity = new \Minds\Entities\Entity($pages[0]);
$entity = Core\Di\Di::_()->get('EntitiesBuilder')->single($pages[0]);
if ($entity instanceof Entities\Activity && $entity->remind_object) {
$entity = (object) $entity->remind_object;
......@@ -207,7 +207,13 @@ class comments implements Interfaces\Api
$comment->setParentGuidL2($_POST['parentGuidL2']);
}
if ($entity->type == 'group') {
if ($entity instanceof Entities\Group) {
if ($entity->isConversationDisabled()) {
return Factory::response([
'status' => 'error',
'message' => 'Conversation has been disabled for this group',
]);
}
$comment->setGroupConversation(true);
}
......
......@@ -184,6 +184,10 @@ class group implements Interfaces\Api
$group->setVideoChatDisabled($_POST['videoChatDisabled']);
}
if (isset($_POST['conversationDisabled'])) {
$group->setConversationDisabled($_POST['conversationDisabled']);
}
if (isset($_POST['tags'])) {
$tags = $_POST['tags'];
$sanitized_tags = [];
......
......@@ -41,6 +41,7 @@ class Group extends NormalizedEntity
protected $mature = false;
protected $rating = 1;
protected $videoChatDisabled = 0; // enable by default
protected $conversationDisabled = 0; // enable by default
protected $pinned_posts = [];
protected $nsfw = [];
protected $nsfw_lock = [];
......@@ -63,6 +64,7 @@ class Group extends NormalizedEntity
'mature',
'rating',
'videoChatDisabled',
'conversationDisabled',
'pinned_posts',
];
......@@ -103,6 +105,7 @@ class Group extends NormalizedEntity
'rating' => $this->rating,
'mature' => $this->mature,
'videoChatDisabled' => $this->videoChatDisabled,
'conversationDisabled' => $this->conversationDisabled,
'pinned_posts' => $this->pinned_posts,
'nsfw' => $this->getNSFW(),
'nsfw_lock' => $this->getNSFWLock()
......@@ -403,6 +406,24 @@ class Group extends NormalizedEntity
return $this;
}
/**
* @return bool
*/
public function isConversationDisabled()
{
return (bool) $this->conversationDisabled;
}
/**
* @param $value
* @return $this
*/
public function setConversationDisabled($value)
{
$this->conversationDisabled = $value ? 1 : 0;
return $this;
}
/**
* Gets `owner_guids`
* @return mixed
......