Skip to content

Commit

Permalink
Shepherds should be included in mention completion (#346).
Browse files Browse the repository at this point in the history
Also provide mention completion to authors.
  • Loading branch information
kohler committed Jul 3, 2024
1 parent 2b6961d commit ea54800
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
13 changes: 5 additions & 8 deletions scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8019,14 +8019,11 @@ demand_load.mail_templates = demand_load.make(function (resolve) {
})();

demand_load.mentions = demand_load.make(function (resolve) {
if (siteinfo.user.is_pclike)
$.get(hoturl("api/mentioncompletion", {p: siteinfo.paperid}), null, function (v) {
var tlist = ((v && v.mentioncompletion) || []).map(completion_item);
tlist.sort(function (a, b) { return strnatcasecmp(a.s, b.s); });
resolve(tlist);
});
else
resolve([]);
$.get(hoturl("api/mentioncompletion", {p: siteinfo.paperid}), null, function (v) {
var tlist = ((v && v.mentioncompletion) || []).map(completion_item);
tlist.sort(function (a, b) { return strnatcasecmp(a.s, b.s); });
resolve(tlist);
});
});

demand_load.emoji_codes = demand_load.make(function (resolve) {
Expand Down
28 changes: 24 additions & 4 deletions src/api/api_completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ static function searchcompletion_api(Contact $user, $qreq) {
* @return list<list<Contact|Author>> */
static function mention_lists($user, $prow, $cvis, $reason) {
$alist = $rlist = $pclist = [];
$is_author = $prow && $prow->has_author($user);
$saw_shepherd = false;

if ($prow
&& $user->can_view_authors($prow)
Expand All @@ -224,7 +226,8 @@ static function mention_lists($user, $prow, $cvis, $reason) {
$prow->ensure_reviewer_names();
$xview = $user->conf->time_some_external_reviewer_view_comment();
foreach ($prow->reviews_as_display() as $rrow) {
if ($rrow->reviewType < REVIEW_PC && !$xview) {
if (($rrow->reviewType < REVIEW_PC && !$xview)
|| $rrow->contactId === $user->contactId) {
continue;
}
$viewid = $user->can_view_review_identity($prow, $rrow);
Expand All @@ -237,17 +240,34 @@ static function mention_lists($user, $prow, $cvis, $reason) {
$rlist[] = $au;
}
if ($viewid
&& $rrow->contactId !== $user->contactId
&& ($cvis >= CommentInfo::CTVIS_REVIEWER || $rrow->reviewType >= REVIEW_PC)
&& !$rrow->reviewer()->is_dormant()) {
$rlist[] = $rrow->reviewer();
$saw_shepherd = $saw_shepherd || $rrow->contactId === $prow->shepherdContactId;
}
}
// XXX todo: list previous commentees in privileged position?
// XXX todo: list lead and shepherd?
// XXX todo: list lead?
}

if ($user->can_view_pc()) {
if ($prow
&& $prow->shepherdContactId > 0
&& $prow->shepherdContactId !== $user->contactId) {
$viewid = $user->can_view_shepherd($prow);
$au = new Author;
$au->lastName = "Shepherd";
$au->contactId = $prow->shepherdContactId;
$au->status = $viewid ? Author::STATUS_REVIEWER : Author::STATUS_ANONYMOUS_REVIEWER;
$rlist[] = $au;
if ($viewid
&& !$saw_shepherd
&& ($shepherd = $user->conf->user_by_id($prow->shepherdContactId, USER_SLICE))
&& !$shepherd->is_dormant()) {
$rlist[] = $shepherd;
}
}

if (!$is_author && $user->can_view_pc()) {
if (!$prow
|| $reason === self::MENTION_PARSE
|| !$user->conf->check_track_view_sensitivity()) {
Expand Down

0 comments on commit ea54800

Please sign in to comment.