Tumblr: Users can now follow tags #1378
No reviewers
Labels
No labels
2018.09
2019.01
2019.03
2019.06
2019.09
2019.12
2020.03
2020.06
2020.09
2020.12
2021.03
2021.07
2021.09
2022.02
2022.06
2022.09
2022.12
2023.04
2023.05
2023.09
2024.03
2024.06
2024.09
2024.12
dependencies
Hackathon 2021
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: friendica/friendica-addons#1378
Loading…
Reference in a new issue
No description provided.
Delete branch "heluecht/friendica-addons:tumblr-tags"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Users can now enter tags that they want to follow on Tumblr. Since we have to perform the requests per tag, the maximum number of tags is limited. Also we now store the post reason, so that users can easily see why a Tumblr posts had been imported.
@ -297,6 +296,7 @@ function tumblr_addon_admin(string &$o)
'$submit' => DI::l10n()->t('Save Settings'),
'$consumer_key' => ['consumer_key', DI::l10n()->t('Consumer Key'), DI::config()->get('tumblr', 'consumer_key'), ''],
'$consumer_secret' => ['consumer_secret', DI::l10n()->t('Consumer Secret'), DI::config()->get('tumblr', 'consumer_secret'), ''],
'$max_tags' => ['max_tags', DI::l10n()->t('Maximum tags'), DI::config()->get('tumblr', 'max_tags', TUMBLR_DEFAULT_MAXIMUM_TAGS), DI::l10n()->t('Maximum number of tags that a user can follow. Enter 0 to deactivate the feature.')],
@ -315,7 +316,11 @@ function tumblr_settings(array &$data)
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post', false);
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default', false);
$import = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'import', false);
$tags = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'tags');
@ -317,1 +318,4 @@
$import = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'import', false);
$tags = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'tags');
$max_tags = DI::config()->get('tumblr', 'max_tags', TUMBLR_DEFAULT_MAXIMUM_TAGS);
Now that we fully support the null-coalescing operator
??
, we should be using it instead of the third parameter of theConfig->get
method to prevent the evaluation of the default value if it isn't used.@ -318,1 +320,4 @@
$max_tags = DI::config()->get('tumblr', 'max_tags', TUMBLR_DEFAULT_MAXIMUM_TAGS);
$tags_str = implode(', ', $tags ?? []);
@ -381,2 +387,4 @@
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default', intval($_POST['tumblr_bydefault']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'import', intval($_POST['tumblr_import']));
$max_tags = DI::config()->get('tumblr', 'max_tags', TUMBLR_DEFAULT_MAXIMUM_TAGS);
@ -685,0 +707,4 @@
*/
function tumblr_fetch_tags(int $uid)
{
if (!DI::config()->get('tumblr', 'max_tags', TUMBLR_DEFAULT_MAXIMUM_TAGS)) {
@ -685,0 +711,4 @@
return;
}
foreach (DI::pConfig()->get($uid, 'tumblr', 'tags', []) as $tag) {
What is the advantage of changing this?
It saves having to compute the default value when there isn't any need for it. In these cases the savings are minimal, but in other cases where the default value is another misspelled config value, it would prevent querying it when the corrected value is finally set.