|
|
@ -111,8 +111,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
// Custom properties
|
|
|
|
// Custom properties
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @var string[] $tags
|
|
|
|
* @var string[] $string_tags
|
|
|
|
* String tags applied to room by creator or submitter.
|
|
|
|
* String tags originally applied to room.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private array $string_tags = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var CommunityTag[] $tags
|
|
|
|
|
|
|
|
* Tag-based information from multiple sources.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Custom attribute.
|
|
|
|
* Custom attribute.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -126,7 +132,11 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private ?string $language_flag;
|
|
|
|
private ?string $language_flag;
|
|
|
|
|
|
|
|
|
|
|
|
private function __construct(CommunityServer $server, array $details) {
|
|
|
|
private function __construct(
|
|
|
|
|
|
|
|
CommunityServer $server,
|
|
|
|
|
|
|
|
array $details,
|
|
|
|
|
|
|
|
bool $suppress_processing = false
|
|
|
|
|
|
|
|
) {
|
|
|
|
$this->server = $server;
|
|
|
|
$this->server = $server;
|
|
|
|
$this->active_users = $details['active_users'];
|
|
|
|
$this->active_users = $details['active_users'];
|
|
|
|
$this->active_users_cutoff = $details['active_users_cutoff'];
|
|
|
|
$this->active_users_cutoff = $details['active_users_cutoff'];
|
|
|
@ -142,15 +152,25 @@
|
|
|
|
$this->read = $details['read'];
|
|
|
|
$this->read = $details['read'];
|
|
|
|
$this->write = $details['write'];
|
|
|
|
$this->write = $details['write'];
|
|
|
|
$this->upload = $details['upload'];
|
|
|
|
$this->upload = $details['upload'];
|
|
|
|
|
|
|
|
$this->string_tags = $details['string_tags'] ?? [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($suppress_processing) return;
|
|
|
|
|
|
|
|
|
|
|
|
$this->extract_tags_from_description();
|
|
|
|
$this->extract_tags_from_description();
|
|
|
|
|
|
|
|
$this->tags = isset($details['tags'])
|
|
|
|
|
|
|
|
? CommunityTag::from_details_array($details['tags'])
|
|
|
|
|
|
|
|
: $this->get_derived_tags();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Regular expression matching tags specified in the Community description.
|
|
|
|
* Create incomplete CommunityRoom instance from intermediate data.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private const DESCRIPTION_TAGS_SPECIFICATION = '/(#[^#()@., ]+(?:,?\s*|\s+|$))+\s*.?$/';
|
|
|
|
public static function _from_intermediate_data(
|
|
|
|
|
|
|
|
CommunityServer $server,
|
|
|
|
|
|
|
|
array $details
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return new CommunityRoom($server, $details, suppress_processing: true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Return an optional Unicode emoji of region matching
|
|
|
|
* Return an optional Unicode emoji of region matching
|
|
|
@ -178,6 +198,11 @@
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Regular expression matching tags specified in the Community description.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private const DESCRIPTION_TAGS_SPECIFICATION = '/(#[^#()@., ]+(?:,?\s*|\s+|$))+\s*.?$/';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Pre-processes SOGS data by treating description-trailing hashtags as room tags.
|
|
|
|
* Pre-processes SOGS data by treating description-trailing hashtags as room tags.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -218,9 +243,6 @@
|
|
|
|
public function jsonSerialize(): array {
|
|
|
|
public function jsonSerialize(): array {
|
|
|
|
$details = get_object_vars($this);
|
|
|
|
$details = get_object_vars($this);
|
|
|
|
unset($details['server']);
|
|
|
|
unset($details['server']);
|
|
|
|
$details['tags'] = $this->get_raw_tags();
|
|
|
|
|
|
|
|
$details['tags_custom'] = $this->get_derived_tags();
|
|
|
|
|
|
|
|
$details['language_flag'] = $this->get_language_flag();
|
|
|
|
|
|
|
|
return $details;
|
|
|
|
return $details;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -232,12 +254,13 @@
|
|
|
|
unset($details['server']);
|
|
|
|
unset($details['server']);
|
|
|
|
unset($details['tags']);
|
|
|
|
unset($details['tags']);
|
|
|
|
unset($details['language_flag']);
|
|
|
|
unset($details['language_flag']);
|
|
|
|
|
|
|
|
unset($details['string_tags']);
|
|
|
|
return array(
|
|
|
|
return array(
|
|
|
|
"room" => $details,
|
|
|
|
"room" => $details,
|
|
|
|
"room_extra" => array(
|
|
|
|
"room_extra" => array(
|
|
|
|
"join_url" => $this->get_join_url(),
|
|
|
|
"join_url" => $this->get_join_url(),
|
|
|
|
"language_flag" => $this->get_language_flag(),
|
|
|
|
"language_flag" => $this->language_flag,
|
|
|
|
"tags" => $this->get_raw_tags()
|
|
|
|
"tags" => $this->string_tags
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -247,15 +270,7 @@
|
|
|
|
* @param CommunityServer $server
|
|
|
|
* @param CommunityServer $server
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static function from_details($server, array $details) {
|
|
|
|
public static function from_details($server, array $details) {
|
|
|
|
$room = new CommunityRoom($server, $details);
|
|
|
|
return new CommunityRoom($server, $details);
|
|
|
|
$has_tags = isset($details['tags']);
|
|
|
|
|
|
|
|
if ($has_tags) {
|
|
|
|
|
|
|
|
$room->add_tags($details['tags']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($details['language_flag'])) {
|
|
|
|
|
|
|
|
$room->language_flag = $details['language_flag'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $room;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -394,11 +409,17 @@
|
|
|
|
* @param string[] $tags
|
|
|
|
* @param string[] $tags
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function add_tags(array $tags) {
|
|
|
|
public function add_tags(array $tags) {
|
|
|
|
|
|
|
|
$new_string_tags = [];
|
|
|
|
foreach ($tags as $tag) {
|
|
|
|
foreach ($tags as $tag) {
|
|
|
|
if (!$this->parse_language_tag($tag)) {
|
|
|
|
$this->string_tags[] = $tag;
|
|
|
|
$this->tags[] = $tag;
|
|
|
|
if ($this->parse_language_tag($tag)) continue;
|
|
|
|
}
|
|
|
|
$new_string_tags[] = $tag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$new_tags = CommunityTag::from_user_tags($new_string_tags);
|
|
|
|
|
|
|
|
$this->tags = CommunityTag::dedupe_tags([
|
|
|
|
|
|
|
|
...$this->tags,
|
|
|
|
|
|
|
|
...$new_tags
|
|
|
|
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -537,8 +558,8 @@
|
|
|
|
* Return the string tags associated with this Community
|
|
|
|
* Return the string tags associated with this Community
|
|
|
|
* @return string[] Array of unique string tags.
|
|
|
|
* @return string[] Array of unique string tags.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function get_raw_tags(): array {
|
|
|
|
private function get_string_tags(): array {
|
|
|
|
return array_unique(array_values($this->tags));
|
|
|
|
return $this->string_tags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -553,92 +574,38 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$derived_tags = [];
|
|
|
|
$derived_tags = [];
|
|
|
|
|
|
|
|
|
|
|
|
$CHECK_MARK = CommunityTag::CHECK_MARK;
|
|
|
|
|
|
|
|
$WARNING = CommunityTag::WARNING_ICON;
|
|
|
|
|
|
|
|
$USERS_PER_STAFF = CommunityRoom::USERS_PER_STAFF;
|
|
|
|
|
|
|
|
$USERS_PER_STAFF_WARNING = CommunityRoom::USERS_PER_STAFF_WARNING;
|
|
|
|
$USERS_PER_STAFF_WARNING = CommunityRoom::USERS_PER_STAFF_WARNING;
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->is_official_room()) {
|
|
|
|
if ($this->is_official_room()) {
|
|
|
|
$derived_tags[] = new CommunityTag(
|
|
|
|
$derived_tags[] = ReservedTags::official();
|
|
|
|
"official",
|
|
|
|
|
|
|
|
TagType::RESERVED_TAG,
|
|
|
|
|
|
|
|
"This Community is maintained by the Session team. $CHECK_MARK"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->rated_nsfw()) {
|
|
|
|
if ($this->rated_nsfw()) {
|
|
|
|
$derived_tags[] =
|
|
|
|
$derived_tags[] = ReservedTags::nsfw();
|
|
|
|
new CommunityTag(
|
|
|
|
|
|
|
|
"nsfw",
|
|
|
|
|
|
|
|
TagType::WARNING_TAG,
|
|
|
|
|
|
|
|
"This Community may contain adult material. $WARNING"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->write && $this->has_good_staff_rating()) {
|
|
|
|
if ($this->write && $this->has_good_staff_rating()) {
|
|
|
|
$derived_tags[] =
|
|
|
|
$derived_tags[] = ReservedTags::moderated(CommunityRoom::USERS_PER_STAFF);
|
|
|
|
new CommunityTag(
|
|
|
|
|
|
|
|
"moderated",
|
|
|
|
|
|
|
|
TagType::RESERVED_TAG,
|
|
|
|
|
|
|
|
"This Community has at least 1 staff per $USERS_PER_STAFF active users. $CHECK_MARK"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if ($this->write && $this->has_poor_staff_rating()) {
|
|
|
|
|
|
|
|
$derived_tags[] =
|
|
|
|
|
|
|
|
new CommunityTag(
|
|
|
|
|
|
|
|
"not modded",
|
|
|
|
|
|
|
|
TagType::WARNING_TAG,
|
|
|
|
|
|
|
|
"This Community has less than 1 staff per $USERS_PER_STAFF_WARNING active users. $WARNING"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$this->write) {
|
|
|
|
if (!$this->write) {
|
|
|
|
$derived_tags[] =
|
|
|
|
$derived_tags[] = ReservedTags::read_only();
|
|
|
|
new CommunityTag(
|
|
|
|
|
|
|
|
"read-only",
|
|
|
|
|
|
|
|
TagType::RESERVED_TAG,
|
|
|
|
|
|
|
|
"This Community is read-only."
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->write && !$this->upload) {
|
|
|
|
if ($this->write && !$this->upload) {
|
|
|
|
$derived_tags[] =
|
|
|
|
$derived_tags[] = ReservedTags::no_upload_permission();
|
|
|
|
new CommunityTag(
|
|
|
|
|
|
|
|
"uploads off",
|
|
|
|
|
|
|
|
TagType::RESERVED_TAG,
|
|
|
|
|
|
|
|
"This Community does not support uploading files or link previews."
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->created && $this->created > strtotime("-4 week")) {
|
|
|
|
if ($this->created && $this->created > strtotime("-4 week")) {
|
|
|
|
$derived_tags[] =
|
|
|
|
$derived_tags[] = ReservedTags::recently_created();
|
|
|
|
new CommunityTag(
|
|
|
|
|
|
|
|
"new",
|
|
|
|
|
|
|
|
TagType::RESERVED_TAG,
|
|
|
|
|
|
|
|
"This Community was created recently."
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (in_array($this->get_room_identifier(), $ROOMS_USED_BY_PROJECT)) {
|
|
|
|
if (in_array($this->get_room_identifier(), $ROOMS_USED_BY_PROJECT)) {
|
|
|
|
$derived_tags[] =
|
|
|
|
$derived_tags[] = ReservedTags::used_by_project();
|
|
|
|
new CommunityTag(
|
|
|
|
|
|
|
|
"we're here",
|
|
|
|
|
|
|
|
TagType::RESERVED_TAG,
|
|
|
|
|
|
|
|
"The sessioncommunities.online maintainer(s) can post updates "
|
|
|
|
|
|
|
|
. "or respond to feedback in this Community."
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (in_array("test", $this->tags) || $this->matched_by_list($TESTING_INCLUDE)) {
|
|
|
|
if ($this->is_testing_room()) {
|
|
|
|
$derived_tags[] =
|
|
|
|
$derived_tags[] = ReservedTags::testing();
|
|
|
|
new CommunityTag(
|
|
|
|
|
|
|
|
"test",
|
|
|
|
|
|
|
|
TagType::RESERVED_TAG,
|
|
|
|
|
|
|
|
"This Community is intended for testing only."
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $derived_tags;
|
|
|
|
return $derived_tags;
|
|
|
@ -649,8 +616,7 @@
|
|
|
|
* @return CommunityTag[] Array of tags.
|
|
|
|
* @return CommunityTag[] Array of tags.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function get_room_tags(): array {
|
|
|
|
function get_room_tags(): array {
|
|
|
|
$user_tags = CommunityTag::from_user_tags($this->tags, remove_redundant: true);
|
|
|
|
return $this->tags;
|
|
|
|
return [...$this->get_derived_tags(), ...$user_tags];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|