Merge pull request #1157 from MrPetovan/task/advancecontentfilter-attachments

[advancedcontentfilter] Add new attachments key in filter
This commit is contained in:
Tobias Diekershoff 2021-08-17 12:41:17 +02:00 committed by GitHub
commit da159e9d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -282,6 +282,7 @@ function advancedcontentfilter_build_fields($data)
'event_created', 'event_edited', 'event_start', 'event_finish', 'event_summary', 'event_created', 'event_edited', 'event_start', 'event_finish', 'event_summary',
'event_desc', 'event_location', 'event_type', 'event_nofinish', 'event_adjust', 'event_ignore', 'event_desc', 'event_location', 'event_type', 'event_nofinish', 'event_adjust', 'event_ignore',
'children', 'pagedrop', 'tags', 'hashtags', 'mentions', 'children', 'pagedrop', 'tags', 'hashtags', 'mentions',
'attachments',
]; ];
$expressionLanguage = new ExpressionLanguage\ExpressionLanguage(); $expressionLanguage = new ExpressionLanguage\ExpressionLanguage();
@ -360,6 +361,8 @@ function advancedcontentfilter_post_rules(ServerRequestInterface $request)
$rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => DBA::lastInsertId()]); $rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => DBA::lastInsertId()]);
DI::cache()->delete('rules_' . local_user());
return json_encode(['message' => DI::l10n()->t('Rule successfully added'), 'rule' => $rule]); return json_encode(['message' => DI::l10n()->t('Rule successfully added'), 'rule' => $rule]);
} }
@ -389,6 +392,8 @@ function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, Res
throw new HTTPException\ServiceUnavailableException(DBA::errorMessage()); throw new HTTPException\ServiceUnavailableException(DBA::errorMessage());
} }
DI::cache()->delete('rules_' . local_user());
return json_encode(['message' => DI::l10n()->t('Rule successfully updated')]); return json_encode(['message' => DI::l10n()->t('Rule successfully updated')]);
} }
@ -410,6 +415,8 @@ function advancedcontentfilter_delete_rules_id(ServerRequestInterface $request,
throw new HTTPException\ServiceUnavailableException(DBA::errorMessage()); throw new HTTPException\ServiceUnavailableException(DBA::errorMessage());
} }
DI::cache()->delete('rules_' . local_user());
return json_encode(['message' => DI::l10n()->t('Rule successfully deleted')]); return json_encode(['message' => DI::l10n()->t('Rule successfully deleted')]);
} }
@ -437,6 +444,10 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques
$item['hashtags'] = $tags['hashtags']; $item['hashtags'] = $tags['hashtags'];
$item['mentions'] = $tags['mentions']; $item['mentions'] = $tags['mentions'];
$attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '');
$item['attachments'] = $attachments;
$return = advancedcontentfilter_get_filter_fields($item); $return = advancedcontentfilter_get_filter_fields($item);
return json_encode(['variables' => str_replace('\\\'', '\'', var_export($return, true))]); return json_encode(['variables' => str_replace('\\\'', '\'', var_export($return, true))]);