forked from friendica/friendica-addons
		
	Some fixes / subject cleaning
This commit is contained in:
		
					parent
					
						
							
								57f689faf1
							
						
					
				
			
			
				commit
				
					
						fae6bbe92c
					
				
			
		
					 2 changed files with 7 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
   that you made directly on Discourse. Since you cannot create
 | 
			
		||||
   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
 | 
			
		||||
--------------
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,8 +7,6 @@
 | 
			
		|||
 * Author: Michael Vogel <http://pirati.ca/profile/heluecht>
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
//use DOMDocument;
 | 
			
		||||
//use DOMXPath;
 | 
			
		||||
use Friendica\App;
 | 
			
		||||
use Friendica\Core\Hook;
 | 
			
		||||
use Friendica\Core\L10n;
 | 
			
		||||
| 
						 | 
				
			
			@ -40,13 +38,6 @@ function discourse_install()
 | 
			
		|||
	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)
 | 
			
		||||
{
 | 
			
		||||
	if (!local_user()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -249,6 +240,12 @@ function discourse_process_post($message, $post, $hostaddr)
 | 
			
		|||
 | 
			
		||||
	if ($post['post_number'] == 1) {
 | 
			
		||||
		$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
 | 
			
		||||
	} else {
 | 
			
		||||
		$message['item']['uri'] = 'topic/' . $post['topic_id'] . '/' . $post['id'] . '@' . $host;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue