From 105daa49e88be2d6ff4cbdc11d88400c55ff2be2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 9 Oct 2020 11:05:01 +0100 Subject: [PATCH] Record the time when rss posts arrived --- newsdaemon.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/newsdaemon.py b/newsdaemon.py index b4162e3b7..c7567bbe8 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -8,6 +8,7 @@ __status__ = "Production" import os import time +import datetime from collections import OrderedDict from newswire import getDictFromNewswire from posts import createNewsPost @@ -53,6 +54,7 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str, if not os.path.isdir(basePath): os.mkdir(basePath) + # oldest items first newswireReverse = \ OrderedDict(sorted(newswire.items(), reverse=False)) @@ -62,6 +64,8 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str, dateStr = dateStr.replace(' ', 'T') dateStr = dateStr.replace('+00:00', 'Z') + # pubDate = datetime.strptime(dateStr, "%Y-%m-%dT%H:%M:%SZ") + statusNumber, published = getStatusNumber(dateStr) newPostId = \ httpPrefix + '://' + domain + \ @@ -107,6 +111,11 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str, httpPrefix + '://' + domain + '/users/news' + \ '/statuses/' + statusNumber + '/replies' blog['news'] = True + + # note the time of arrival + currTime = datetime.datetime.utcnow() + blog['object']['arrived'] = currTime.strftime("%Y-%m-%dT%H:%M:%SZ") + blog['object']['replies']['id'] = idStr blog['object']['replies']['first']['partOf'] = idStr