Skip to content

Commit

Permalink
Parse @mentions that are email prefixes (part before @)
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Sep 25, 2024
1 parent 73253ae commit cd4725f
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/mentionparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ static function parse($s, ...$user_lists) {
if (in_array($u->contactId, $matchuids)) {
continue;
}
// check email prefix (require 2 or more letters)
$at = (int) strpos($u->email, "@");
if ($at > 1
&& substr_compare($s, $u->email, $pos + 1, $at, true) === 0
&& self::mention_ends_at($s, $pos + 1 + $at)) {
$uset[] = new PossibleMentionParse($u, substr($u->email, 0, $at) . " ", $at + 1, $listindex);
$matchuids[] = $u->contactId;
continue;
}
// check name
if ($u->firstName === "" && $u->lastName === "") {
continue;
Expand Down
3 changes: 2 additions & 1 deletion test/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
{"name": "Van Jacobson", "email": "[email protected]", "affiliation": "Lawrence Berkeley National Laboratory"},
{"name": "Wilma Ojuelegba", "email": "[email protected]", "affiliation": "INRIA", "roles": ["pc"]},
{"name": "Véra Djükuba", "email": "[email protected]", "affiliation": "Bombay Institute", "roles": ["pc"]},
{"name": "Randy H. Katz", "email": "[email protected]", "affiliation": "University of California, Berkeley"}
{"name": "Randy H. Katz", "email": "[email protected]", "affiliation": "University of California, Berkeley"},
{"name": "Dottie Francis", "email": "[email protected]", "affiliation": "Place Investigations", "roles": ["pc"]}
],
"papers": [{
"_id_": 1,
Expand Down
146 changes: 146 additions & 0 deletions test/emails.txt
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,32 @@ concerns.
- Testconf I Submissions
******** [email protected]

******** [email protected]
To: Dottie Francis <[email protected]>
Subject: [Testconf I] Welcome to the program committee

Greetings,

You have been added to the program committee on the Test Conference I
(Testconf I) submission site.

* Site: http://hotcrp.lcdf.org/test/
* Email: [email protected]

You will need a password to sign in. Use this link to set one up:

http://hotcrp.lcdf.org/test/resetpassword/{{}}

Should the link expire, obtain a new one using "Forgot my password".

If you already have an account under a different email address, you may
merge this new account into that one. Go to your profile page and select
"Merge with another account".

Contact Eddie Kohler <[email protected]> with any questions or
concerns.

- Testconf I Submissions
******** [email protected]
To: Mikael Degermark <[email protected]>
Subject: [Testconf I] Account information
Expand Down Expand Up @@ -2186,3 +2212,123 @@ Contact Eddie Kohler <[email protected]> with any questions or
concerns.

- Testconf I Submissions
******** t_comments-email-mentions
To: Mary Baker <[email protected]>, Lixia Zhang <[email protected]>, George Varghese <[email protected]>
Subject: [Testconf I] Comment for #1 "Scalable Timers for Soft State
Protocols"

Comment @3 by Jane Chair <chair@_.com> (Administrator)
---------------------------------------------------------------------------
@Christian Huitema @rguerin @christophe.diot @d.francis2 @veraxx


\***************************************************************************


You’re following comments for Test Conference I (Testconf I) submission
#1. For the most up-to-date comments, or to unsubscribe from email
notification, see the submission site.

* Title: Scalable Timers for Soft State Protocols
* Site: http://hotcrp.lcdf.org/test/paper/1

Contact Eddie Kohler <[email protected]> with any questions or
concerns.

- Testconf I Submissions
******** t_comments-email-mentions
To: Christian Huitema <[email protected]>
Subject: [Testconf I] Mentioned for #1 "Scalable Timers for Soft State
Protocols"

Comment @3 by Jane Chair <chair@_.com> (Administrator)
---------------------------------------------------------------------------
@Christian Huitema @rguerin @christophe.diot @d.francis2 @veraxx


\***************************************************************************


You were mentioned in this comment for Test Conference I (Testconf I)
submission #1. For the most up-to-date comments, see the submission
site.

* Title: Scalable Timers for Soft State Protocols
* Site: http://hotcrp.lcdf.org/test/paper/1

Contact Eddie Kohler <[email protected]> with any questions or
concerns.

- Testconf I Submissions
******** t_comments-email-mentions
To: Roch Guerin <[email protected]>
Subject: [Testconf I] Mentioned for #1 "Scalable Timers for Soft State
Protocols"

Comment @3 by Jane Chair <chair@_.com> (Administrator)
---------------------------------------------------------------------------
@Christian Huitema @rguerin @christophe.diot @d.francis2 @veraxx


\***************************************************************************


You were mentioned in this comment for Test Conference I (Testconf I)
submission #1. For the most up-to-date comments, see the submission
site.

* Title: Scalable Timers for Soft State Protocols
* Site: http://hotcrp.lcdf.org/test/paper/1

Contact Eddie Kohler <[email protected]> with any questions or
concerns.

- Testconf I Submissions
******** t_comments-email-mentions
To: Christophe Diot <[email protected]>
Subject: [Testconf I] Mentioned for #1 "Scalable Timers for Soft State
Protocols"

Comment @3 by Jane Chair <chair@_.com> (Administrator)
---------------------------------------------------------------------------
@Christian Huitema @rguerin @christophe.diot @d.francis2 @veraxx


\***************************************************************************


You were mentioned in this comment for Test Conference I (Testconf I)
submission #1. For the most up-to-date comments, see the submission
site.

* Title: Scalable Timers for Soft State Protocols
* Site: http://hotcrp.lcdf.org/test/paper/1

Contact Eddie Kohler <[email protected]> with any questions or
concerns.

- Testconf I Submissions
******** t_comments-email-mentions
To: Dottie Francis <[email protected]>
Subject: [Testconf I] Mentioned for #1 "Scalable Timers for Soft State
Protocols"

Comment @3 by Jane Chair <chair@_.com> (Administrator)
---------------------------------------------------------------------------
@Christian Huitema @rguerin @christophe.diot @d.francis2 @veraxx


\***************************************************************************


You were mentioned in this comment for Test Conference I (Testconf I)
submission #1. For the most up-to-date comments, see the submission
site.

* Title: Scalable Timers for Soft State Protocols
* Site: http://hotcrp.lcdf.org/test/paper/1

Contact Eddie Kohler <[email protected]> with any questions or
concerns.

- Testconf I Submissions
2 changes: 1 addition & 1 deletion test/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ static function reset_db($rebuild = false) {
if ($user) {
MailChecker::check_db("create-{$c->email}");
} else {
fwrite(STDERR, "* failed to create user $c->email\n");
fwrite(STDERR, "* failed to create user {$c->email}\n");
$ok = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/t_autoassign.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function __construct(Conf $conf) {
$this->cflts[$prow->paperId][$cflt->contactId] = true;
}
}
assert(count($this->pcc) === 16);
assert(count($this->pcc) === 17);
}

function setup() {
Expand Down Expand Up @@ -216,7 +216,7 @@ function test_ensure_reviews_per_user() {

$prows = $this->conf->paper_set(["paperId" => $this->cur_pids]);
foreach ($prows as $prow) {
xassert_le(count($prow->reviews_as_list()), 5);
xassert_le(count($prow->reviews_as_list()), 6);
}

$rbu = $this->reviews_by_user($prows);
Expand Down
10 changes: 10 additions & 0 deletions test/t_comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ function test_multiple_mentions() {
MailChecker::check_db("t_comments-multiple-mentions");
}

function test_email_mentions() {
xassert_eqq($this->conf->setting("viewrev"), null);
$this->conf->save_refresh_setting("viewrev", 1);
$paper1 = $this->conf->checked_paper_by_id(1);
$j = call_api("=comment", $this->u_chair, ["c" => "new", "text" => "@Christian Huitema @rguerin @christophe.diot @d.francis2 @veraxx"], $paper1);
xassert($j->ok);
MailChecker::check_db("t_comments-email-mentions");
$this->conf->save_refresh_setting("viewrev", null);
}

function test_attachments() {
$paper1 = $this->conf->checked_paper_by_id(1);
$qreq = new Qrequest("POST", ["c" => "new", "text" => "Hello", "attachment:1" => "new"]);
Expand Down

0 comments on commit cd4725f

Please sign in to comment.