|
|
@ -269,16 +269,31 @@
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param string[] $tags
|
|
|
|
* @param string[] $tags
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function add_tags(array $tags) {
|
|
|
|
public function add_tags(array $tags) {
|
|
|
|
$this->tags = [...$this->tags, ...$tags];
|
|
|
|
$this->tags = [...$this->tags, ...$tags];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function has_nsfw_keywords(): bool {
|
|
|
|
|
|
|
|
// Description not included due to false positives.
|
|
|
|
|
|
|
|
$blob =
|
|
|
|
|
|
|
|
strtolower($this->name) . " " .
|
|
|
|
|
|
|
|
strtolower(join(" ", $this->tags));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (CommunityTag::NSFW_KEYWORDS as $keyword) {
|
|
|
|
|
|
|
|
if (str_contains($blob, $keyword)) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Return the tags associated with this room.
|
|
|
|
* Return the tags associated with this room.
|
|
|
|
* @return \CommunityTag[] Tags as string array.
|
|
|
|
* @return \CommunityTag[] Tags as string array.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function get_room_tags(): array {
|
|
|
|
function get_room_tags(): array {
|
|
|
|
$user_tags = CommunityTag::from_user_tags($this->tags);
|
|
|
|
$user_tags = CommunityTag::from_user_tags($this->tags, remove_redundant: true);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @var \CommunityTag[] $derived_tags
|
|
|
|
* @var \CommunityTag[] $derived_tags
|
|
|
@ -289,6 +304,10 @@
|
|
|
|
$derived_tags[] = new CommunityTag("official", TagType::RESERVED_TAG);
|
|
|
|
$derived_tags[] = new CommunityTag("official", TagType::RESERVED_TAG);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->has_nsfw_keywords()) {
|
|
|
|
|
|
|
|
$derived_tags[] = new CommunityTag("nsfw", TagType::WARNING_TAG);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return [...$derived_tags, ...$user_tags];
|
|
|
|
return [...$derived_tags, ...$user_tags];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|