+ /**
+ * Set the channel post frequency for contact id and user id
+ *
+ * @param int $cid Either public contact id or user's contact id
+ * @param int $uid User ID
+ * @param int $frequency Type of post frequency in channels
+ * @return void
+ * @throws \Exception
+ */
+ public static function setChannelFrequency(int $cid, int $uid, int $frequency)
+ {
+ $cdata = Contact::getPublicAndUserContactID($cid, $uid);
+ if (empty($cdata)) {
+ return;
+ }
+
+ DBA::update('user-contact', ['channel-frequency' => $frequency], ['cid' => $cdata['public'], 'uid' => $uid], true);
+ }
+
+ /**
+ * Returns the channel frequency state for contact id and user id
+ *
+ * @param int $cid Either public contact id or user's contact id
+ * @param int $uid User ID
+ * @return int Type of post frequency in channels
+ * @throws HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ public static function getChannelFrequency(int $cid, int $uid): int
+ {
+ $cdata = Contact::getPublicAndUserContactID($cid, $uid);
+ if (empty($cdata)) {
+ return false;
+ }
+
+ $frequency = self::FREQUENCY_DEFAULT;
+
+ if (!empty($cdata['public'])) {
+ $public_contact = DBA::selectFirst('user-contact', ['channel-frequency'], ['cid' => $cdata['public'], 'uid' => $uid]);
+ if (DBA::isResult($public_contact)) {
+ $frequency = $public_contact['channel-frequency'] ?? self::FREQUENCY_DEFAULT;
+ }
+ }
+
+ return $frequency;
+ }
+