Some fixes / subject cleaning

This commit is contained in:
Michael 2019-11-26 18:59:50 +00:00
parent 57f689faf1
commit fae6bbe92c
2 changed files with 7 additions and 10 deletions

View File

@ -16,7 +16,7 @@ The mailing list mode in Discourse knows two different options:
2. Don't get your own posts. Then you will missing all your posts 2. Don't get your own posts. Then you will missing all your posts
that you made directly on Discourse. Since you cannot create that you made directly on Discourse. Since you cannot create
a new post via this connector (only comments are possible) a new post via this connector (only comments are possible)
this is not a goog choice either. this is not a good choice either.
Known problems Known problems
-------------- --------------

View File

@ -7,8 +7,6 @@
* Author: Michael Vogel <http://pirati.ca/profile/heluecht> * Author: Michael Vogel <http://pirati.ca/profile/heluecht>
* *
*/ */
//use DOMDocument;
//use DOMXPath;
use Friendica\App; use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -40,13 +38,6 @@ function discourse_install()
Hook::register('connector_settings_post', __FILE__, 'discourse_settings_post'); Hook::register('connector_settings_post', __FILE__, 'discourse_settings_post');
} }
function discourse_uninstall()
{
Hook::unregister('email_getmessage', __FILE__, 'discourse_email_getmessage');
Hook::unregister('connector_settings', __FILE__, 'discourse_settings');
Hook::unregister('connector_settings_post', __FILE__, 'discourse_settings_post');
}
function discourse_settings(App $a, &$s) function discourse_settings(App $a, &$s)
{ {
if (!local_user()) { if (!local_user()) {
@ -249,6 +240,12 @@ function discourse_process_post($message, $post, $hostaddr)
if ($post['post_number'] == 1) { if ($post['post_number'] == 1) {
$message['item']['parent-uri'] = $message['item']['uri'] = 'topic/' . $post['topic_id'] . '@' . $host; $message['item']['parent-uri'] = $message['item']['uri'] = 'topic/' . $post['topic_id'] . '@' . $host;
// Remove the Discourse forum name from the subject
$pattern = '=\[.*\].*\s(\[.*\].*)=';
if (preg_match($pattern, $message['item']['title'])) {
$message['item']['title'] = preg_replace($pattern, '$1', $message['item']['title']);
}
/// @ToDo Fetch thread information /// @ToDo Fetch thread information
} else { } else {
$message['item']['uri'] = 'topic/' . $post['topic_id'] . '/' . $post['id'] . '@' . $host; $message['item']['uri'] = 'topic/' . $post['topic_id'] . '/' . $post['id'] . '@' . $host;