diff --git a/advancedcontentfilter/advancedcontentfilter.js b/advancedcontentfilter/advancedcontentfilter.js
new file mode 100644
index 00000000..e3c2da54
--- /dev/null
+++ b/advancedcontentfilter/advancedcontentfilter.js
@@ -0,0 +1,132 @@
+$.ajaxSetup({headers: {'X-CSRF-Token': csrfToken}});
+
+$.extend({
+ ajaxJSON: function(method, url, data) {
+ return $.ajax({
+ type: method.toUpperCase(),
+ url: url,
+ data: JSON.stringify(data),
+ contentType: 'application/json; charset=utf-8',
+ dataType: 'json'
+ });
+ }
+});
+
+new Vue({
+ el: '#rules',
+
+ data: {
+ showModal: false,
+ errorMessage: '',
+ editedIndex: null,
+ rule: {id: '', name: '', expression: '', created: ''},
+ rules: existingRules || [],
+ itemUrl: '',
+ itemJson: '',
+ currentTheme: currentTheme,
+ messages: messages,
+ },
+
+ watch: {
+ showModal: function () {
+ if (this.showModal) {
+ $(this.$refs.vuemodal).modal('show');
+ } else {
+ $(this.$refs.vuemodal).modal('hide');
+ }
+ }
+ },
+
+ methods: {
+ resetForm: function() {
+ this.rule = {id: '', name: '', expression: '', created: ''};
+ this.showModal = false;
+ this.editedIndex = null;
+ },
+
+ addRule: function () {
+ if (this.rule.name.trim()) {
+ this.errorMessage = '';
+
+ var self = this;
+ $.ajaxJSON('post', '/advancedcontentfilter/api/rules', this.rule)
+ .then(function (responseJSON) {
+ self.rules.push(responseJSON.rule);
+ self.resetForm();
+ }, function (response) {
+ self.errorMessage = response.responseJSON.message;
+ });
+ }
+ },
+
+ editRule: function (rule) {
+ this.editedIndex = this.rules.indexOf(rule);
+ this.rule = Object.assign({}, rule);
+ this.showModal = true;
+ },
+
+ saveRule: function (rule) {
+ this.errorMessage = '';
+
+ var self = this;
+ $.ajaxJSON('put', '/advancedcontentfilter/api/rules/' + rule.id, rule)
+ .then(function () {
+ self.rules[self.editedIndex] = rule;
+ self.resetForm();
+ }, function (response) {
+ self.errorMessage = response.responseJSON.message;
+ });
+ },
+
+ toggleActive: function (rule) {
+ var previousValue = this.rules[this.rules.indexOf(rule)].active;
+ var newValue = Math.abs(parseInt(rule.active) - 1);
+
+ this.rules[this.rules.indexOf(rule)].active = newValue;
+
+ var self = this;
+ $.ajaxJSON('put', '/advancedcontentfilter/api/rules/' + rule.id, {'active': newValue})
+ .fail(function (response) {
+ self.rules[self.rules.indexOf(rule)].active = previousValue;
+ console.log(response.responseJSON.message);
+ });
+ },
+
+ deleteRule: function (rule) {
+ if (confirm('Are you sure you want to delete this rule?')) {
+ var self = this;
+ $.ajaxJSON('delete', '/advancedcontentfilter/api/rules/' + rule.id)
+ .then(function () {
+ self.rules.splice(self.rules.indexOf(rule), 1);
+ }, function (response) {
+ console.log(response.responseJSON.message);
+ });
+ }
+ },
+
+ showVariables: function () {
+ var urlParts = this.itemUrl.split('/');
+ var guid = urlParts[urlParts.length - 1];
+
+ this.itemJson = '';
+
+ var self = this;
+ $.ajaxJSON('get', '/advancedcontentfilter/api/variables/' + guid)
+ .then(function (responseJSON) {
+ self.itemJson = responseJSON.variables;
+ }, function (response) {
+ self.itemJson = response.responseJSON.message;
+ });
+
+ return false;
+ }
+ },
+
+ // These render functions have been compiled from templates/advancedcontentfilter.vue, check this file out for instructions
+ render: function () {
+ with(this){return _c('div',{attrs:{"id":"rules"}},[_c('p',[_c('a',{attrs:{"href":"settings/addon"}},[_v("🔙 "+_s(messages.backtosettings))])]),_c('h1',[_v(_s(messages.title)+" "),_c('a',{staticClass:"btn btn-default btn-sm",attrs:{"href":"advancedcontentfilter/help","title":messages.help}},[_c('i',{staticClass:"fa fa-question fa-2x",attrs:{"aria-hidden":"true"}})])]),_c('div',[_v(_s(messages.intro))]),_c('h2',[_v(_s(messages.your_rules)+" "),_c('button',{staticClass:"btn btn-primary btn-sm",attrs:{"title":messages.add_a_rule},on:{"click":function($event){showModal = true}}},[_c('i',{staticClass:"fa fa-plus fa-2x",attrs:{"aria-hidden":"true"}})])]),(rules.length === 0)?_c('div',{},[_v(_s(messages.no_rules))]):_e(),_c('ul',{staticClass:"list-group"},_l((rules),function(rule){return _c('li',{staticClass:"list-group-item"},[_c('p',{staticClass:"pull-right"},[(parseInt(rule.active))?_c('button',{staticClass:"btn btn-xs btn-primary",attrs:{"type":"button","aria-label":messages.disable_this_rule,"title":messages.disable_this_rule},on:{"click":function($event){toggleActive(rule)}}},[_c('i',{staticClass:"fa fa-toggle-on",attrs:{"aria-hidden":"true"}}),_v(" "+_s(messages.enabled))]):_c('button',{staticClass:"btn btn-xs btn-default",attrs:{"type":"button","aria-label":messages.enable_this_rule,"title":messages.enable_this_rule},on:{"click":function($event){toggleActive(rule)}}},[_c('i',{staticClass:"fa fa-toggle-off",attrs:{"aria-hidden":"true"}}),_v(" "+_s(messages.disabled))]),_v(" "),_c('button',{staticClass:"btn btn-xs btn-primary",attrs:{"type":"button","aria-label":messages.edit_this_rule,"title":messages.edit_this_rule},on:{"click":function($event){editRule(rule)}}},[_c('i',{staticClass:"fa fa-pencil",attrs:{"aria-hidden":"true"}})]),_v(" "),_c('button',{staticClass:"btn btn-xs btn-default",attrs:{"type":"button","aria-label":messages.delete_this_rule,"title":messages.delete_this_rule},on:{"click":function($event){deleteRule(rule)}}},[_c('i',{staticClass:"fa fa-trash-o",attrs:{"aria-hidden":"true"}})])]),_c('h3',{staticClass:"list-group-item-heading"},[_v(_s(messages.rule)+" #"+_s(rule.id)+": "+_s(rule.name))]),(rule.expression)?_c('pre',{staticClass:"list-group-item-text"},[_v(_s(rule.expression))]):_e()])})),_c('div',{ref:"vuemodal",staticClass:"modal fade",attrs:{"tabindex":"-1","role":"dialog"}},[_c('div',{staticClass:"modal-dialog",attrs:{"role":"document"}},[_c('div',{staticClass:"modal-content"},[_c('div',{staticClass:"modal-header"},[(currentTheme === 'frio')?_c('button',{staticClass:"close",attrs:{"type":"button","data-dismiss":"modal","aria-label":messages.close},on:{"click":function($event){showModal = false}}},[_c('span',{attrs:{"aria-hidden":"true"}},[_v("×")])]):_e(),(rule.id)?_c('h3',[_v(_s(messages.edit_the_rule)+" \""+_s(rule.name)+"\"")]):_e(),(!rule.id)?_c('h3',[_v(_s(messages.add_a_rule))]):_e()]),_c('div',{staticClass:"modal-body"},[_c('form',[(errorMessage)?_c('div',{staticClass:"alert alert-danger",attrs:{"role":"alert"}},[_v(_s(errorMessage))]):_e(),_c('div',{staticClass:"form-group"},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(rule.name),expression:"rule.name"}],staticClass:"form-control",attrs:{"placeholder":messages.rule_name},domProps:{"value":(rule.name)},on:{"input":function($event){if($event.target.composing)return;$set(rule, "name", $event.target.value)}}})]),_c('div',{staticClass:"form-group"},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(rule.expression),expression:"rule.expression"}],staticClass:"form-control",attrs:{"placeholder":messages.rule_expression},domProps:{"value":(rule.expression)},on:{"input":function($event){if($event.target.composing)return;$set(rule, "expression", $event.target.value)}}})])])]),_c('div',{staticClass:"modal-footer"},[_c('button',{staticClass:"btn btn-default",attrs:{"type":"button","data-dismiss":"modal","aria-label":"Close"},on:{"click":function($event){resetForm()}}},[_v(_s(messages.cancel))]),(rule.id)?_c('button',{staticClass:"btn btn-primary",attrs:{"slot":"button","type":"button"},on:{"click":function($event){saveRule(rule)}},slot:"button"},[_v(_s(messages.save_this_rule))]):_e(),(!rule.id)?_c('button',{staticClass:"btn btn-primary",attrs:{"slot":"button","type":"button"},on:{"click":function($event){addRule()}},slot:"button"},[_v(_s(messages.add_a_rule))]):_e()])])])]),_c('form',{staticClass:"form-inline",on:{"submit":function($event){$event.preventDefault();showVariables()}}},[_c('fieldset',[_c('legend',[_v("Show post variables")]),_c('div',{staticClass:"form-group",staticStyle:{"width":"50%"}},[_c('label',{staticClass:"sr-only",attrs:{"for":"itemUrl"}},[_v("Post URL or item guid")]),_c('input',{directives:[{name:"model",rawName:"v-model",value:(itemUrl),expression:"itemUrl"}],staticClass:"form-control",staticStyle:{"width":"100%"},attrs:{"id":"itemUrl","placeholder":"Post URL or item guid"},domProps:{"value":(itemUrl)},on:{"input":function($event){if($event.target.composing)return;itemUrl=$event.target.value}}})]),_c('button',{staticClass:"btn btn-primary",attrs:{"type":"submit"}},[_v("Show Variables")])])]),_c('pre',{},[_v(_s(itemJson))])])}
+ },
+
+ staticRenderFns: [
+ ],
+});
diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php
index 2d1308e7..55a80a80 100644
--- a/advancedcontentfilter/advancedcontentfilter.php
+++ b/advancedcontentfilter/advancedcontentfilter.php
@@ -170,7 +170,7 @@ function advancedcontentfilter_module() {}
function advancedcontentfilter_init(App $a)
{
- if ($a->argv[1] == 'api') {
+ if ($a->argc > 1 && $a->argv[1] == 'api') {
$slim = new \Slim\App();
require __DIR__ . '/src/middlewares.php';
@@ -188,7 +188,7 @@ function advancedcontentfilter_content(App $a)
return Login::form('/' . implode('/', $a->argv));
}
- if ($a->argc > 0 && $a->argv[1] == 'help') {
+ if ($a->argc > 1 && $a->argv[1] == 'help') {
$lang = $a->user['language'];
$default_dir = 'addon/advancedcontentfilter/doc/';
@@ -208,31 +208,31 @@ function advancedcontentfilter_content(App $a)
} else {
$t = get_markup_template('settings.tpl', 'addon/advancedcontentfilter/');
return replace_macros($t, [
+ '$messages' => [
+ 'backtosettings' => L10n::t('Back to Addon Settings'),
+ 'title' => L10n::t('Advanced Content Filter'),
+ 'add_a_rule' => L10n::t('Add a Rule'),
+ 'help' => L10n::t('Help'),
+ 'intro' => L10n::t('Add and manage your personal content filter rules in this screen. Rules have a name and an arbitrary expression that will be matched against post data. For a complete reference of the available operations and variables, check the help page.'),
+ 'your_rules' => L10n::t('Your rules'),
+ 'no_rules' => L10n::t('You have no rules yet! Start adding one by clicking on the button above next to the title.'),
+ 'disabled' => L10n::t('Disabled'),
+ 'enabled' => L10n::t('Enabled'),
+ 'disable_this_rule' => L10n::t('Disable this rule'),
+ 'enable_this_rule' => L10n::t('Enable this rule'),
+ 'edit_this_rule' => L10n::t('Edit this rule'),
+ 'edit_the_rule' => L10n::t('Edit the rule'),
+ 'save_this_rule' => L10n::t('Save this rule'),
+ 'delete_this_rule' => L10n::t('Delete this rule'),
+ 'rule' => L10n::t('Rule'),
+ 'close' => L10n::t('Close'),
+ 'addtitle' => L10n::t('Add new rule'),
+ 'rule_name' => L10n::t('Rule Name'),
+ 'rule_expression' => L10n::t('Rule Expression'),
+ 'cancel' => L10n::t('Cancel'),
+ ],
'$current_theme' => $a->getCurrentTheme(),
- '$backtosettings' => L10n::t('Back to Addon Settings'),
- '$title' => L10n::t('Advanced Content Filter'),
- '$add_a_rule' => L10n::t('Add a Rule'),
- '$help' => L10n::t('Help'),
- '$advanced_content_filter_intro' => addslashes(L10n::t('Add and manage your personal content filter rules in this screen. Rules have a name and an arbitrary expression that will be matched against post data. For a complete reference of the available operations and variables, check the help page.')),
- '$your_rules' => L10n::t('Your rules'),
- '$no_rules' => L10n::t('You have no rules yet! Start adding one by clicking on the button above next to the title.'),
- '$disabled' => L10n::t('Disabled'),
- '$enabled' => L10n::t('Enabled'),
- '$disable_this_rule' => L10n::t('Disable this rule'),
- '$enable_this_rule' => L10n::t('Enable this rule'),
- '$edit_this_rule' => L10n::t('Edit this rule'),
- '$edit_the_rule' => L10n::t('Edit the rule'),
- '$save_this_rule' => L10n::t('Save this rule'),
- '$delete_this_rule' => L10n::t('Delete this rule'),
- '$rule' => L10n::t('Rule'),
- '$close' => L10n::t('Close'),
- '$addtitle' => L10n::t('Add new rule'),
- '$rule_name' => L10n::t('Rule Name'),
- '$rule_expression' => L10n::t('Rule Expression'),
- '$examples' => L10n::t('
Examples:
'),
- '$cancel' => L10n::t('Cancel'),
'$rules' => advancedcontentfilter_get_rules(),
- '$baseurl' => System::baseUrl(true),
'$form_security_token' => get_form_security_token()
]);
}
diff --git a/advancedcontentfilter/templates/vue_dom.tpl b/advancedcontentfilter/templates/advancedcontentfilter.vue
similarity index 54%
rename from advancedcontentfilter/templates/vue_dom.tpl
rename to advancedcontentfilter/templates/advancedcontentfilter.vue
index 24538b86..fded67a9 100644
--- a/advancedcontentfilter/templates/vue_dom.tpl
+++ b/advancedcontentfilter/templates/advancedcontentfilter.vue
@@ -1,51 +1,52 @@
diff --git a/twitter/twitter.php b/twitter/twitter.php
index ab7697bb..a130a1cd 100644
--- a/twitter/twitter.php
+++ b/twitter/twitter.php
@@ -73,7 +73,6 @@ use Friendica\Core\PConfig;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
-use Friendica\Model\Conversation;
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Item;
@@ -96,48 +95,48 @@ define('TWITTER_DEFAULT_POLL_INTERVAL', 5); // given in minutes
function twitter_install()
{
// we need some hooks, for the configuration and for sending tweets
- Addon::registerHook('load_config' , __FILE__, 'twitter_load_config');
- Addon::registerHook('connector_settings' , __FILE__, 'twitter_settings');
- Addon::registerHook('connector_settings_post', __FILE__, 'twitter_settings_post');
- Addon::registerHook('post_local' , __FILE__, 'twitter_post_local');
- Addon::registerHook('notifier_normal' , __FILE__, 'twitter_post_hook');
- Addon::registerHook('jot_networks' , __FILE__, 'twitter_jot_nets');
- Addon::registerHook('cron' , __FILE__, 'twitter_cron');
- Addon::registerHook('queue_predeliver' , __FILE__, 'twitter_queue_hook');
- Addon::registerHook('follow' , __FILE__, 'twitter_follow');
- Addon::registerHook('expire' , __FILE__, 'twitter_expire');
- Addon::registerHook('prepare_body' , __FILE__, 'twitter_prepare_body');
- Addon::registerHook('check_item_notification', __FILE__, 'twitter_check_item_notification');
+ Addon::registerHook('load_config', 'addon/twitter/twitter.php', 'twitter_load_config');
+ Addon::registerHook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
+ Addon::registerHook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
+ Addon::registerHook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
+ Addon::registerHook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
+ Addon::registerHook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets');
+ Addon::registerHook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
+ Addon::registerHook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
+ Addon::registerHook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
+ Addon::registerHook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
+ Addon::registerHook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
+ Addon::registerHook('check_item_notification', 'addon/twitter/twitter.php', 'twitter_check_item_notification');
logger("installed twitter");
}
function twitter_uninstall()
{
- Addon::unregisterHook('load_config' , __FILE__, 'twitter_load_config');
- Addon::unregisterHook('connector_settings' , __FILE__, 'twitter_settings');
- Addon::unregisterHook('connector_settings_post', __FILE__, 'twitter_settings_post');
- Addon::unregisterHook('post_local' , __FILE__, 'twitter_post_local');
- Addon::unregisterHook('notifier_normal' , __FILE__, 'twitter_post_hook');
- Addon::unregisterHook('jot_networks' , __FILE__, 'twitter_jot_nets');
- Addon::unregisterHook('cron' , __FILE__, 'twitter_cron');
- Addon::unregisterHook('queue_predeliver' , __FILE__, 'twitter_queue_hook');
- Addon::unregisterHook('follow' , __FILE__, 'twitter_follow');
- Addon::unregisterHook('expire' , __FILE__, 'twitter_expire');
- Addon::unregisterHook('prepare_body' , __FILE__, 'twitter_prepare_body');
- Addon::unregisterHook('check_item_notification', __FILE__, 'twitter_check_item_notification');
+ Addon::unregisterHook('load_config', 'addon/twitter/twitter.php', 'twitter_load_config');
+ Addon::unregisterHook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
+ Addon::unregisterHook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
+ Addon::unregisterHook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
+ Addon::unregisterHook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
+ Addon::unregisterHook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets');
+ Addon::unregisterHook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
+ Addon::unregisterHook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
+ Addon::unregisterHook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
+ Addon::unregisterHook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
+ Addon::unregisterHook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
+ Addon::unregisterHook('check_item_notification', 'addon/twitter/twitter.php', 'twitter_check_item_notification');
// old setting - remove only
- Addon::unregisterHook('post_local_end' , __FILE__, 'twitter_post_hook');
- Addon::unregisterHook('addon_settings' , __FILE__, 'twitter_settings');
- Addon::unregisterHook('addon_settings_post', __FILE__, 'twitter_settings_post');
+ Addon::unregisterHook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
+ Addon::unregisterHook('addon_settings', 'addon/twitter/twitter.php', 'twitter_settings');
+ Addon::unregisterHook('addon_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
}
function twitter_load_config(App $a)
{
- $a->loadConfigFile(__DIR__ . '/config/twitter.ini.php');
+ $a->loadConfigFile(__DIR__. '/config/twitter.ini.php');
}
-function twitter_check_item_notification(App $a, array &$notification_data)
+function twitter_check_item_notification(App $a, &$notification_data)
{
$own_id = PConfig::get($notification_data["uid"], 'twitter', 'own_id');
@@ -151,7 +150,7 @@ function twitter_check_item_notification(App $a, array &$notification_data)
}
}
-function twitter_follow(App $a, array &$contact)
+function twitter_follow(App $a, &$contact)
{
logger("twitter_follow: Check if contact is twitter contact. " . $contact["url"], LOGGER_DEBUG);
@@ -205,7 +204,7 @@ function twitter_jot_nets(App $a, &$b)
}
}
-function twitter_settings_post(App $a)
+function twitter_settings_post(App $a, $post)
{
if (!local_user()) {
return;
@@ -386,7 +385,7 @@ function twitter_settings(App $a, &$s)
$s .= '';
}
-function twitter_post_local(App $a, array &$b)
+function twitter_post_local(App $a, &$b)
{
if ($b['edit']) {
return;
@@ -446,7 +445,7 @@ function twitter_action(App $a, $uid, $pid, $action)
logger("twitter_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG);
}
-function twitter_post_hook(App $a, array &$b)
+function twitter_post_hook(App $a, &$b)
{
// Post to Twitter
if (!PConfig::get($b["uid"], 'twitter', 'import')
@@ -658,7 +657,7 @@ function twitter_addon_admin(App $a, &$o)
]);
}
-function twitter_cron(App $a)
+function twitter_cron(App $a, $b)
{
$last = Config::get('twitter', 'last_poll');
@@ -726,7 +725,7 @@ function twitter_cron(App $a)
Config::set('twitter', 'last_poll', time());
}
-function twitter_expire(App $a)
+function twitter_expire(App $a, $b)
{
$days = Config::get('twitter', 'expire');
@@ -761,7 +760,7 @@ function twitter_expire(App $a)
logger('twitter_expire: expire_end');
}
-function twitter_prepare_body(App $a, array &$b)
+function twitter_prepare_body(App $a, &$b)
{
if ($b["item"]["network"] != NETWORK_TWITTER) {
return;
@@ -810,13 +809,12 @@ function twitter_prepare_body(App $a, array &$b)
*/
function twitter_do_mirrorpost(App $a, $uid, $post)
{
- $datarray['api_source'] = true;
- $datarray['profile_uid'] = $uid;
- $datarray['extid'] = NETWORK_TWITTER;
- $datarray['message_id'] = Item::newURI($uid, NETWORK_TWITTER . ':' . $post->id);
- $datarray['protocol'] = Conversation::PARCEL_TWITTER;
- $datarray['source'] = json_encode($post);
- $datarray['title'] = '';
+ $datarray["api_source"] = true;
+ $datarray["profile_uid"] = $uid;
+ $datarray["extid"] = NETWORK_TWITTER;
+ $datarray['message_id'] = Item::newURI($uid, NETWORK_TWITTER . ":" . $post->id);
+ // $datarray['object'] = json_encode($post); // Activate for debugging
+ $datarray["title"] = "";
if (!empty($post->retweeted_status)) {
// We don't support nested shares, so we mustn't show quotes as shares on retweets
@@ -826,7 +824,7 @@ function twitter_do_mirrorpost(App $a, $uid, $post)
$item['author-name'],
$item['author-link'],
$item['author-avatar'],
- '',
+ "",
$item['created'],
$item['plink']
);
@@ -838,15 +836,15 @@ function twitter_do_mirrorpost(App $a, $uid, $post)
$datarray['body'] = $item['body'];
}
- $datarray['source'] = $item['app'];
- $datarray['verb'] = $item['verb'];
+ $datarray["source"] = $item['app'];
+ $datarray["verb"] = $item['verb'];
- if (isset($item['location'])) {
- $datarray['location'] = $item['location'];
+ if (isset($item["location"])) {
+ $datarray["location"] = $item["location"];
}
- if (isset($item['coord'])) {
- $datarray['coord'] = $item['coord'];
+ if (isset($item["coord"])) {
+ $datarray["coord"] = $item["coord"];
}
return $datarray;
@@ -921,7 +919,7 @@ function twitter_fetchtimeline(App $a, $uid)
PConfig::set($uid, 'twitter', 'lastid', $lastid);
}
-function twitter_queue_hook(App $a)
+function twitter_queue_hook(App $a, &$b)
{
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
DBA::escape(NETWORK_TWITTER)
@@ -1274,7 +1272,7 @@ function twitter_expand_entities(App $a, $body, $item, $picture)
*
* @return $picture string Image URL or empty string
*/
-function twitter_media_entities($post, array &$postarray)
+function twitter_media_entities($post, &$postarray)
{
// There are no media entities? So we quit.
if (empty($post->extended_entities->media)) {
@@ -1333,15 +1331,14 @@ function twitter_media_entities($post, array &$postarray)
return "";
}
-function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $only_existing_contact, $noquote)
+function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_existing_contact, $noquote)
{
$postarray = [];
$postarray['network'] = NETWORK_TWITTER;
$postarray['uid'] = $uid;
$postarray['wall'] = 0;
$postarray['uri'] = "twitter::" . $post->id_str;
- $postarray['protocol'] = Conversation::PARCEL_TWITTER;
- $postarray['source'] = json_encode($post);
+ // $postarray['object'] = json_encode($post); // Activate for debugging
// Don't import our own comments
if (DBA::exists('item', ['extid' => $postarray['uri'], 'uid' => $uid])) {
@@ -1465,7 +1462,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
if (!empty($post->retweeted_status)) {
$retweet = twitter_createpost($a, $uid, $post->retweeted_status, $self, false, false, $noquote);
- $retweet['source'] = $postarray['source'];
+ //$retweet['object'] = $postarray['object']; // Activate for debugging
$retweet['private'] = $postarray['private'];
$retweet['allow_cid'] = $postarray['allow_cid'];
$retweet['contact-id'] = $postarray['contact-id'];
@@ -1496,7 +1493,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
return $postarray;
}
-function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, array $self)
+function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, $self, $own_id)
{
logger("twitter_fetchparentposts: Fetching for user " . $uid . " and post " . $post->id_str, LOGGER_DEBUG);
@@ -1655,7 +1652,7 @@ function twitter_fetchhometimeline(App $a, $uid)
}
if ($post->in_reply_to_status_id_str != "") {
- twitter_fetchparentposts($a, $uid, $post, $connection, $self);
+ twitter_fetchparentposts($a, $uid, $post, $connection, $self, $own_id);
}
$postarray = twitter_createpost($a, $uid, $post, $self, $create_user, true, false);
@@ -1717,7 +1714,7 @@ function twitter_fetchhometimeline(App $a, $uid)
}
if ($post->in_reply_to_status_id_str != "") {
- twitter_fetchparentposts($a, $uid, $post, $connection, $self);
+ twitter_fetchparentposts($a, $uid, $post, $connection, $self, $own_id);
}
$postarray = twitter_createpost($a, $uid, $post, $self, false, false, false);