Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezones #182

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SINGULARITY_HOSTNAME=localhost.localdomain
SINGULARITY_VERSION="v0.5"
SINGULARITY_DEPLOYMENT_STATUS="(in development)"
SINGULARITY_TIMEZONE="America/New_York"
6 changes: 6 additions & 0 deletions container-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
NGINX_HTTPS_LISTEN: 'unix:/run/nginx/socks/https.sock'
NGINX_SMTPS_LISTEN: 'unix:/run/nginx/socks/smtps.sock'
NGINX_POP3S_LISTEN: 'unix:/run/nginx/socks/pop3s.sock'
environment:
TZ: ${SINGULARITY_TIMEZONE}
volumes:
- type: bind
source: ./socks
Expand Down Expand Up @@ -42,6 +44,8 @@ services:
target: orbit
args:
orbit_version_info: "singularity ${SINGULARITY_VERSION} ${SINGULARITY_DEPLOYMENT_STATUS} https://github.com/underground-software/singularity"
environment:
TZ: ${SINGULARITY_TIMEZONE}
volumes:
- type: volume
source: orbit-db
Expand Down Expand Up @@ -108,6 +112,8 @@ services:
dockerfile: Containerfile
args:
MATRIX_HOSTNAME: ${SINGULARITY_HOSTNAME}
environment:
TZ: ${SINGULARITY_TIMEZONE}
volumes:
- type: volume
source: submatrix-data
Expand Down
1 change: 1 addition & 0 deletions extenginx/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ RUN apk update && apk upgrade && apk add \
nginx \
nginx-mod-mail \
nginx-mod-stream \
tzdata \
;


Expand Down
2 changes: 1 addition & 1 deletion mailman/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def submissions(assignment, username):
query = query.where(db.Submission.user == username)
for sub in query:
print(sub.submission_id,
datetime.fromtimestamp(sub.timestamp).isoformat(),
datetime.fromtimestamp(sub.timestamp).astimezone().isoformat(),
sub.user, sub.recipient)


Expand Down
1 change: 1 addition & 0 deletions orbit/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN apk update && apk upgrade && apk add \
cgit \
libmemcached-dev \
memcached \
tzdata \
;

WORKDIR /usr/local/share/orbit
Expand Down
12 changes: 6 additions & 6 deletions orbit/radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self, env=None, username=None):
if username:
self.username = username
self.token = self.mk_hash(username)
self.expiry = datetime.utcnow() + timedelta(minutes=min_per_ses)
self.expiry = datetime.now() + timedelta(minutes=min_per_ses)
# creates a new session if one does not exist
(db.Session
.replace(username=self.username,
Expand Down Expand Up @@ -123,24 +123,24 @@ def mk_hash(self, username):
return secrets.token_hex()

def expired(self):
if (expiry := self.expiry) is None or datetime.utcnow() > expiry:
if (expiry := self.expiry) is None or datetime.now() > expiry:
self.end()
return True
else:
return False

def expiry_fmt(self):
return self.expiry.strftime('%a, %d %b %Y %H:%M:%S GMT')
return self.expiry.astimezone().isoformat()

def expiry_ts(self):
return self.expiry.timestamp()

def mk_cookie_header(self):
if self.token is None:
return [('Set-Cookie', 'auth=')]
cookie_fmt = 'auth={}; Expires={}; Max-Age={}; Path=/'
cookie_fmt = 'auth={}; Max-Age={}; Path=/'
max_age = sec_per_min * min_per_ses
cookie_val = cookie_fmt.format(self.token, self.expiry_fmt(), max_age)
cookie_val = cookie_fmt.format(self.token, max_age)

return [('Set-Cookie', cookie_val)]

Expand Down Expand Up @@ -388,7 +388,7 @@ def handle_dashboard(rocket):
.order_by(- mailman.db.Submission.timestamp))

def submission_fields(sub):
return (datetime.fromtimestamp(sub.timestamp).isoformat(),
return (datetime.fromtimestamp(sub.timestamp).astimezone().isoformat(),
sub.recipient, sub.email_count, sub.in_reply_to or '-',
sub.submission_id, )

Expand Down
7 changes: 6 additions & 1 deletion submatrix/Containerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
FROM alpine:3.20 as submatrix

RUN apk add synapse envsubst py3-curl
RUN apk add \
synapse \
envsubst \
py3-curl \
tzdata \
;

COPY homeserver.yaml.template /etc/synapse/homeserver.yaml.template

Expand Down