From b160aa07b6549f3b334647d038790ae6ff7522b1 Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Mon, 11 Jan 2021 20:00:51 +0000
Subject: [PATCH] Issue 9705: Perform an age check when the post isn't fetched

---
 src/Model/Item.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/Model/Item.php b/src/Model/Item.php
index 35ab929a3..e4266b41e 100644
--- a/src/Model/Item.php
+++ b/src/Model/Item.php
@@ -1698,6 +1698,12 @@ class Item
 		// The contact-id should be set before "self::insert" was called - but there seems to be issues sometimes
 		$item["contact-id"] = self::contactId($item);
 
+		if (!empty($item['direction']) && in_array($item['direction'], [Conversation::PUSH, Conversation::RELAY]) &&
+			self::isTooOld($item)) {
+			Logger::info('Item is too old', ['item' => $item]);
+			return 0;
+		}
+
 		if (!self::isValid($item)) {
 			return 0;
 		}