]> git.mxchange.org Git - friendica.git/commitdiff
Statistics: Inbound/Outbound for more protocols
authorMichael <heluecht@pirati.ca>
Mon, 5 Aug 2024 20:34:17 +0000 (20:34 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 5 Aug 2024 20:34:17 +0000 (20:34 +0000)
src/Module/Feed.php
src/Module/Stats.php
src/Protocol/Email.php
src/Worker/OnePoll.php

index 6289ad2b2849f890bf53f1f2d5d93fc6633f167a..a88936470e9fd55d4830121b75b9ffed0f5d0080 100644 (file)
@@ -22,6 +22,8 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
+use Friendica\Core\Protocol;
+use Friendica\Model\Item;
 use Friendica\Model\User;
 use Friendica\Network\HTTPException;
 use Friendica\Protocol\Feed as ProtocolFeed;
@@ -68,6 +70,8 @@ class Feed extends BaseModule
                        throw new HTTPException\UnauthorizedException($this->t('Access to this profile has been restricted.'));
                }
 
+               Item::incrementOutbound(Protocol::FEED);
+
                $feed = ProtocolFeed::atom($owner, $last_update, 10, $type);
 
                $this->httpExit($feed, Response::TYPE_ATOM);
index d8bc317fc47718b666e2199c9e348b1ca618103b..9e77fc65e9a6f83382358956d038cfd04ac61d3d 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module;
 
 use Friendica\App;
 use Friendica\BaseModule;
+use Friendica\Core\Addon;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
 use Friendica\Core\L10n;
@@ -123,12 +124,16 @@ class Stats extends BaseModule
                                        Protocol::DFRN        => intval($this->keyValue->get('stats_packets_inbound_' . Protocol::DFRN) ?? 0),
                                        Protocol::DIASPORA    => intval($this->keyValue->get('stats_packets_inbound_' . Protocol::DIASPORA) ?? 0),
                                        Protocol::OSTATUS     => intval($this->keyValue->get('stats_packets_inbound_' . Protocol::OSTATUS) ?? 0),
+                                       Protocol::FEED        => intval($this->keyValue->get('stats_packets_inbound_' . Protocol::FEED) ?? 0),
+                                       Protocol::MAIL        => intval($this->keyValue->get('stats_packets_inbound_' . Protocol::MAIL) ?? 0),
                                ],
                                'outbound' => [
                                        Protocol::ACTIVITYPUB => intval($this->keyValue->get('stats_packets_outbound_' . Protocol::ACTIVITYPUB) ?? 0),
                                        Protocol::DFRN        => intval($this->keyValue->get('stats_packets_outbound_' . Protocol::DFRN) ?? 0),
                                        Protocol::DIASPORA    => intval($this->keyValue->get('stats_packets_outbound_' . Protocol::DIASPORA) ?? 0),
                                        Protocol::OSTATUS     => intval($this->keyValue->get('stats_packets_outbound_' . Protocol::OSTATUS) ?? 0),
+                                       Protocol::FEED        => intval($this->keyValue->get('stats_packets_outbound_' . Protocol::FEED) ?? 0),
+                                       Protocol::MAIL        => intval($this->keyValue->get('stats_packets_outbound_' . Protocol::MAIL) ?? 0),
                                ]
                        ],
                        'reports' => [
@@ -141,6 +146,15 @@ class Stats extends BaseModule
                        ]
                ];
 
+               if (Addon::isEnabled('bluesky')) {
+                       $statistics['packets']['inbound'][Protocol::BLUESKY] = intval($this->keyValue->get('stats_packets_inbound_' . Protocol::BLUESKY) ?? 0);
+                       $statistics['packets']['outbound'][Protocol::BLUESKY] = intval($this->keyValue->get('stats_packets_outbound_' . Protocol::BLUESKY) ?? 0);
+               }
+               if (Addon::isEnabled('tumblr')) {
+                       $statistics['packets']['inbound'][Protocol::TUMBLR] = intval($this->keyValue->get('stats_packets_inbound_' . Protocol::TUMBLR) ?? 0);
+                       $statistics['packets']['outbound'][Protocol::TUMBLR] = intval($this->keyValue->get('stats_packets_outbound_' . Protocol::TUMBLR) ?? 0);
+               }
+
                $statistics = $this->getJobsPerPriority($statistics);
 
                $this->jsonExit($statistics);
index 836235105cae56194042903270457a112795849d..d52f159c15b0ad97f4f31894c13d3943aee3e75e 100644 (file)
@@ -25,6 +25,7 @@ use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
+use Friendica\Core\Protocol;
 use Friendica\Model\Item;
 use Friendica\Util\Strings;
 use \IMAP\Connection;
@@ -47,6 +48,7 @@ class Email
                        return false;
                }
 
+               Item::incrementInbound(Protocol::MAIL);
                $mbox = @imap_open($mailbox, $username, $password);
 
                $errors = imap_errors();
@@ -74,6 +76,7 @@ class Email
                        return [];
                }
 
+               Item::incrementInbound(Protocol::MAIL);
                $search1 = @imap_search($mbox, 'UNDELETED FROM "' . $email_addr . '"', SE_UID);
                if (!$search1) {
                        $search1 = [];
@@ -81,6 +84,7 @@ class Email
                        Logger::debug("Found mails from ".$email_addr);
                }
 
+               Item::incrementInbound(Protocol::MAIL);
                $search2 = @imap_search($mbox, 'UNDELETED TO "' . $email_addr . '"', SE_UID);
                if (!$search2) {
                        $search2 = [];
@@ -88,6 +92,7 @@ class Email
                        Logger::debug("Found mails to ".$email_addr);
                }
 
+               Item::incrementInbound(Protocol::MAIL);
                $search3 = @imap_search($mbox, 'UNDELETED CC "' . $email_addr . '"', SE_UID);
                if (!$search3) {
                        $search3 = [];
@@ -136,7 +141,7 @@ class Email
        public static function getMessage($mbox, int $uid, string $reply, array $item): array
        {
                $ret = $item;
-
+               Item::incrementInbound(Protocol::MAIL);
                $struc = (($mbox && $uid) ? @imap_fetchstructure($mbox, $uid, FT_UID) : null);
 
                if (!$struc) {
@@ -403,6 +408,7 @@ class Email
                //$message = '<html><body>' . $html . '</body></html>';
                //$message = html2plain($html);
                Logger::notice('notifier: email delivery to ' . $addr);
+               Item::incrementOutbound(Protocol::MAIL);
                return mail($addr, $subject, $body, $headers);
        }
 
index 838f30a4e431667b9d105184474ecd79e681b8ae..dcfc55d0570177d383219985e1a57df7f1cb1422 100644 (file)
@@ -165,6 +165,7 @@ class OnePoll
                }
 
                $cookiejar = tempnam(System::getTempPath(), 'cookiejar-onepoll-');
+               Item::incrementInbound(Protocol::FEED);
                $curlResult = DI::httpClient()->get($contact['poll'], HttpClientAccept::FEED_XML, [HttpClientOptions::COOKIEJAR => $cookiejar, HttpClientOptions::REQUEST => HttpClientRequest::FEEDFETCHER]);
                unlink($cookiejar);