From 942bb00321cadebcb7fa74b4f60255de1e4ad34f Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Sun, 16 Oct 2022 10:40:35 -0500 Subject: [PATCH 1/5] feat: delete tags when deleting profile --- php-classes/Laddr/PeopleRequestHandler.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/php-classes/Laddr/PeopleRequestHandler.php b/php-classes/Laddr/PeopleRequestHandler.php index 948772d2..0a10a96a 100644 --- a/php-classes/Laddr/PeopleRequestHandler.php +++ b/php-classes/Laddr/PeopleRequestHandler.php @@ -76,6 +76,11 @@ protected static function onBeforeRecordDestroyed(\ActiveRecord $Person) $ProjectMembership->destroy(); } + // delete tags + foreach ($Person->Tags as $Tag) { + $Tag->destroy(); + } + // delete comments foreach ($Person->Comments as $Comment) { $Comment->destroy(); From cc6418c1f50bb95d13206066795d089069978367 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Sun, 16 Oct 2022 10:43:39 -0500 Subject: [PATCH 2/5] feat(mueller): add tailored tests for laddr --- .../Mueller/Investigator.config.d/laddr.php | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 php-config/Emergence/Mueller/Investigator.config.d/laddr.php diff --git a/php-config/Emergence/Mueller/Investigator.config.d/laddr.php b/php-config/Emergence/Mueller/Investigator.config.d/laddr.php new file mode 100644 index 00000000..924b4a9b --- /dev/null +++ b/php-config/Emergence/Mueller/Investigator.config.d/laddr.php @@ -0,0 +1,61 @@ + -10, + 'function' => [Investigator::class, 'testHasUserField'], + 'userField' => 'About' +]; + +Investigator::$tests['has-comment'] = [ + 'points' => -10, + 'function' => function (IUser $User, array &$userCache) { + return count(Investigator::getUserComments($User, $userCache)) > 0; + } +]; + +Investigator::$tests['has-project'] = [ + 'points' => 1000, + 'function' => function (IUser $User) { + static $projectMemberIds; + + if ($projectMemberIds === null) { + $projectMemberIds = array_map( + 'intval', + DB::allValues( + 'MemberID', + 'SELECT DISTINCT MemberID FROM `project_members`' + ) + ); + } + + return in_array(strtolower($User->ID), $projectMemberIds); + }, +]; + +if (SlackAPI::isAvailable()) { + Investigator::$tests['has-slack-account'] = [ + 'points' => 1000, + 'function' => function (IUser $User) { + static $slackUsernames; + + if ($slackUsernames === null) { + $slackMembersResponse = SlackAPI::request('users.list'); + $slackUsernames = []; + + foreach ($slackMembersResponse['members'] as $member) { + $slackUsernames[] = strtolower($member['name']); + } + } + + return in_array(strtolower($User->Username), $slackUsernames); + } + ]; +} From 0387d15d9896b7a57cc9a0c70e9ebeaa913de4d1 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Sun, 16 Oct 2022 11:08:32 -0500 Subject: [PATCH 3/5] feat(mueller): check if about is long instead of just present --- .../Emergence/Mueller/Investigator.config.d/laddr.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/php-config/Emergence/Mueller/Investigator.config.d/laddr.php b/php-config/Emergence/Mueller/Investigator.config.d/laddr.php index 924b4a9b..66f1d2aa 100644 --- a/php-config/Emergence/Mueller/Investigator.config.d/laddr.php +++ b/php-config/Emergence/Mueller/Investigator.config.d/laddr.php @@ -8,10 +8,11 @@ Investigator::$tests['email-invalid'] = false; -Investigator::$tests['has-about'] = [ +Investigator::$tests['has-long-about'] = [ 'points' => -10, - 'function' => [Investigator::class, 'testHasUserField'], - 'userField' => 'About' + 'function' => function (IUser $User, array &$userCache) { + return $User->About && strlen($User->About) > 200; + } ]; Investigator::$tests['has-comment'] = [ From 07e8d50ba5d5f5a0ed2bdafa6b54a873eb81743f Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Sun, 16 Oct 2022 12:03:45 -0500 Subject: [PATCH 4/5] feat(mueller): switch from long about check to URL check --- .../Emergence/Mueller/Investigator.config.d/laddr.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/php-config/Emergence/Mueller/Investigator.config.d/laddr.php b/php-config/Emergence/Mueller/Investigator.config.d/laddr.php index 66f1d2aa..f9cb8e6b 100644 --- a/php-config/Emergence/Mueller/Investigator.config.d/laddr.php +++ b/php-config/Emergence/Mueller/Investigator.config.d/laddr.php @@ -8,10 +8,10 @@ Investigator::$tests['email-invalid'] = false; -Investigator::$tests['has-long-about'] = [ - 'points' => -10, +Investigator::$tests['has-about-url'] = [ + 'points' => -100, 'function' => function (IUser $User, array &$userCache) { - return $User->About && strlen($User->About) > 200; + return $User->About && (stripos($User->About, 'http://') !== false || stripos($User->About, 'https://') !== false); } ]; From 329834f6aff01abf30d472a291109177f1959158 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Sun, 16 Oct 2022 12:04:06 -0500 Subject: [PATCH 5/5] feat(mueller): switch from has-comment check to URL check --- .../Mueller/Investigator.config.d/laddr.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/php-config/Emergence/Mueller/Investigator.config.d/laddr.php b/php-config/Emergence/Mueller/Investigator.config.d/laddr.php index f9cb8e6b..859b2fdf 100644 --- a/php-config/Emergence/Mueller/Investigator.config.d/laddr.php +++ b/php-config/Emergence/Mueller/Investigator.config.d/laddr.php @@ -15,10 +15,20 @@ } ]; -Investigator::$tests['has-comment'] = [ - 'points' => -10, +Investigator::$tests['has-comment-url'] = [ + 'points' => -100, 'function' => function (IUser $User, array &$userCache) { - return count(Investigator::getUserComments($User, $userCache)) > 0; + + foreach (Investigator::getUserComments($User, $userCache) as $Comment) { + if ( + stripos($Comment['Message'], 'http://') !== false + || stripos($Comment['Message'], 'https://') !== false + ) { + return true; + } + } + + return false; } ];