From: Friendika <info@friendika.com>
Date: Tue, 14 Jun 2011 03:42:37 +0000 (-0700)
Subject: avoid returning events from getting posted again
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=05eb9ceaba9f87776b61a51a49a967cc578ef58a;p=friendica.git

avoid returning events from getting posted again
---

diff --git a/include/event.php b/include/event.php
index 208ba1e1fd..2cfc524087 100644
--- a/include/event.php
+++ b/include/event.php
@@ -193,6 +193,7 @@ function event_store($arr) {
 	$arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
 	$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );	
 	$arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0);
+	$arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(),$arr['uid']));
 
 	if($arr['cid'])
 		$c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@@ -250,14 +251,12 @@ function event_store($arr) {
 	}
 	else {
 
-		$uri = item_new_uri($a->get_hostname(),local_user());
-
 		$r = q("INSERT INTO `event` ( `uid`,`cid`,`uri`,`created`,`edited`,`start`,`finish`,`desc`,`location`,`type`,
 			`adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`)
 			VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
 			intval($arr['uid']),
 			intval($arr['cid']),
-			dbesc($uri),
+			dbesc($arr['uri']),
 			dbesc($arr['created']),
 			dbesc($arr['edited']),
 			dbesc($arr['start']),
diff --git a/include/items.php b/include/items.php
index 514bd1efa9..dc177c468c 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1338,6 +1338,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee
 					$ev = bbtoevent($datarray['body']);
 					if(x($ev,'desc') && x($ev,'start')) {
 						$ev['uid'] = $importer['uid'];
+						$ev['uri'] = $item_id;
+
 						if(is_array($contact))
 							$ev['cid'] = $contact['id'];
 						$r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php
index 949d9f9ab5..6ca3f9fc2f 100644
--- a/mod/dfrn_notify.php
+++ b/mod/dfrn_notify.php
@@ -599,6 +599,7 @@ function dfrn_notify_post(&$a) {
 				if(x($ev,'desc') && x($ev,'start')) {
 					$ev['cid'] = $importer['id'];
 					$ev['uid'] = $importer['uid'];
+					$ev['uri'] = $item_id;
 
 					$r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
 						dbesc($item_id),