gemini.git

going-flying.com gemini git repository

summary

tree

log

refs

5126de863bc369d49ba17762bcf1441318ea3a32 - Matthew Ernisse - 1649440925

logic and dates are hard.

view tree

view raw

diff --git a/build/build.py b/build/build.py
index 764570f..0c09039 100755
--- a/build/build.py
+++ b/build/build.py
@@ -135,7 +135,10 @@ class GeminiFeed(object):
 		# If there is already a gemlog atom feed sitting on disk save
 		# the date of it so that we can notify Antenna if we end up
 		# having new posts in it.
-		self.last_date = 0
+		self.last_date = datetime.datetime.fromisoformat(
+			'1970-01-01T00:00:00+00:00'
+		)
+
 		if os.path.exists(self.file_name):
 			try:
 				parsed = feedparser.parse(self.file_name)
@@ -143,7 +146,13 @@ class GeminiFeed(object):
 				print(f'Failed to load {fn}: {e!s}')
 				return
 
-			self.last_date = parsed['feed']['updated']
+			for entry in feed.entries:
+				entry_date = datetime.datetime.fromisoformat(
+					entry.updated
+				)
+
+				if entry_date > self.last_date:
+					self.last_date = entry_date
 
 	def add(self, title, link, pubdate):
 		''' Add an entry to the feed. '''
@@ -156,13 +165,10 @@ class GeminiFeed(object):
 	def should_notify(self):
 		''' Return True if we should notifiy services that we've
 		updated the feed.'''
-		if self.last_date == 0:
-			return False
-
-		if self.feed.updated() <= datetime.datetime.fromisoformat(self.last_date):
-			return False
+		if self.feed.updated() > self.last_date:
+			return True
 
-		return True
+		return False
 
 	def write(self):
 		self.feed.atom_file(self.file_name)
@@ -288,7 +294,7 @@ if __name__ == '__main__':
 	print('Trying to notify Antenna')
 
 	try:
-		resp = gemini.fetch(
+		resp = gemini.request(
 			'gemini://warmedal.se/~antenna/submit',
 			query='gemini://going-flying.com/~mernisse/atom.xml'
 		)