+ /**
+ * Set direction and post reason
+ *
+ * @param array $datarray
+ * @param integer $direction
+ *
+ * @return array
+ */
+ public static function setDirection(array $datarray, int $direction): array
+ {
+ $datarray['direction'] = in_array($direction, [self::FETCHED, self::FORCED_FETCH]) ? Conversation::PULL : Conversation::PUSH;
+
+ if (in_array($direction, [self::FETCHED, self::FORCED_FETCH])) {
+ $datarray['post-reason'] = Item::PR_FETCHED;
+ } elseif ($datarray['uid'] == 0) {
+ $datarray['post-reason'] = Item::PR_GLOBAL;
+ } else {
+ $datarray['post-reason'] = Item::PR_PUSHED;
+ }
+
+ return $datarray;
+ }
+