Skip to content
Snippets Groups Projects
Verified Commit ff44eb02 authored by Mario Oenning's avatar Mario Oenning
Browse files

feat: add link to mailing list article on requests page


Provides a convenient way to check for responses on the
mailing list prior to Accepting/Rejecting requests.

We compute the Message-ID hash that can be used to
link back to the article in the mailing list archive.

Signed-off-by: default avatarmoson-mo <mo-son@mailbox.org>
parent 154bb239
No related branches found
No related tags found
No related merge requests found
import base64
import hashlib
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import backref, relationship
from aurweb import schema
from aurweb import config, schema
from aurweb.models.declarative import Base
from aurweb.models.package_base import PackageBase as _PackageBase
from aurweb.models.request_type import RequestType as _RequestType
......@@ -103,3 +106,16 @@ class PackageRequest(Base):
def status_display(self) -> str:
"""Return a display string for the Status column."""
return self.STATUS_DISPLAY[self.Status]
def ml_message_id_hash(self) -> str:
"""Return the X-Message-ID-Hash that is used in the mailing list archive."""
# X-Message-ID-Hash is a base32 encoded SHA1 hash
msgid = f"pkg-request-{str(self.ID)}@aur.archlinux.org"
sha1 = hashlib.sha1(msgid.encode()).digest()
return base64.b32encode(sha1).decode()
def ml_message_url(self) -> str:
"""Return the mailing list URL for the request."""
url = config.get("options", "ml_thread_url") % (self.ml_message_id_hash())
return url
......@@ -25,6 +25,7 @@ max_rpc_results = 5000
max_search_results = 2500
max_depends = 1000
aur_request_ml = aur-requests@lists.archlinux.org
ml_thread_url = https://lists.archlinux.org/archives/list/aur-requests@lists.archlinux.org/thread/%s
request_idle_time = 1209600
request_archive_time = 15552000
auto_orphan_age = 15552000
......
......@@ -115,8 +115,11 @@
{% if result.User %}
<a href="/account/{{ result.User.Username }}">
{{ result.User.Username }}
</a>
</a>&nbsp;
{% endif %}
<a target="_blank" rel="noopener noreferrer" href="{{ result.ml_message_url() }}">
(PRQ#{{ result.ID }})
</a>
</td>
{% set idle_time = config_getint("options", "request_idle_time") %}
{% set time_delta = (utcnow - result.RequestTS) | int %}
......
import pytest
from sqlalchemy.exc import IntegrityError
from aurweb import db, time
from aurweb import config, db, time
from aurweb.models.account_type import USER_ID
from aurweb.models.package_base import PackageBase
from aurweb.models.package_request import (
......@@ -190,3 +190,41 @@ def test_package_request_status_display(user: User, pkgbase: PackageBase):
pkgreq.Status = 124
with pytest.raises(KeyError):
pkgreq.status_display()
def test_package_request_ml_message_id_hash(user: User, pkgbase: PackageBase):
with db.begin():
pkgreq = db.create(
PackageRequest,
ID=1,
ReqTypeID=MERGE_ID,
User=user,
PackageBase=pkgbase,
PackageBaseName=pkgbase.Name,
Comments=str(),
ClosureComment=str(),
Status=PENDING_ID,
)
# A hash composed with ID=1 should result in BNNNRWOFDRSQP4LVPT77FF2GUFR45KW5
assert pkgreq.ml_message_id_hash() == "BNNNRWOFDRSQP4LVPT77FF2GUFR45KW5"
def test_package_request_ml_message_url(user: User, pkgbase: PackageBase):
with db.begin():
pkgreq = db.create(
PackageRequest,
ID=1,
ReqTypeID=MERGE_ID,
User=user,
PackageBase=pkgbase,
PackageBaseName=pkgbase.Name,
Comments=str(),
ClosureComment=str(),
Status=PENDING_ID,
)
assert (
config.get("options", "ml_thread_url") % (pkgreq.ml_message_id_hash())
== pkgreq.ml_message_url()
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment