summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/M2F.php35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/M2F.php b/src/M2F.php
index 7dd56b0..fd2901f 100644
--- a/src/M2F.php
+++ b/src/M2F.php
@@ -3,7 +3,7 @@
require_once(__DIR__ . '/Bridge.php');
require_once(__DIR__ . '/MailmanLib.php');
require_once(__DIR__ . '/MailmanMessage.php');
-require_once(__DIR__ . '/PhpBB3Lib.php');
+require_once(__DIR__ . '/PhpBB3.php');
# Read the message from STDIN
$url = 'php://stdin';
@@ -11,24 +11,41 @@ $url = 'php://stdin';
$input = read_raw_message($url);
$msg = new MailmanMessage($input);
-$user = get_user_id($msg->getFrom());
-$userName = get_user_name($userId);
-
$bridge = new Bridge();
+$seen = $bridge->registerMessage($msg->getMessageId(),
+ $msg->getInReplyTo(),
+ $msg->getReferences());
+
+if ($seen) {
+ # This message has already been processed.
+ exit;
+}
+
+$phpbb = new PhpBB3();
+
$inReplyTo = $msg->getInReplyTo();
+$forumId = $topicId = -1;
+$postType = null;
+
if ($inReplyTo) {
- # Is this a reply?
+ # A reply to an existing topic
# FIXME: we don't want exceptions here?
$parentId = $bridge->getPostId($inReplyTo);
- $topicId = get_topic_id($parentId);
+ $ids = $phpbb->getTopicAndForumIds($parentId);
+ $forumId = $ids['forum_id'];
+ $topicId = $ids['topic_id'];
+ $postType = 'reply';
}
else {
- # a new message
-
+ # A message starting a new topic
+ $forumId = $bridge->getDefaultForumId($msg->getSource());
+ $postType = 'post';
}
-#$forumId = get_default_forum_id($msg->getSource());
+# Post the message to the forum
+$phpbb->postMessage($postType, $forumId, $topicId, $msg);
+$bridge->setPostId($messageId, $postId);
?>