Changeset 921ea8b


Ignore:
Timestamp:
2018-07-31T06:12:25Z (6 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
3b0c1c3
Parents:
c82e4ca
Message:

twitter: show quote tweets when the url isn't in the entities

Which means we recognized that a tweet had a quote in it, but not
finding a matching URL entity meant we didn't have anywhere to show it.
Now it's appended at the end.

This is what changed here: https://twittercommunity.com/t/105473
("Updating how URLs are rendered in the Quote Tweet payload")

Took me way too long to realize it was this and why it happened - if you
create quote tweets by copypasting urls, the behavior doesn't change,
this only applies if you use the retweet button in twitter web and add a
comment.

And initially we disregarded it as some brownout of the userstream, but
it looks like it applies to the REST api too.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter_lib.c

    rc82e4ca r921ea8b  
    704704static void expand_entities(char **text, const json_value *node, const json_value *extended_node)
    705705{
    706         json_value *entities, *extended_entities, *quoted;
    707         char *quote_url = NULL, *quote_text = NULL;
     706        json_value *entities, *extended_entities, *quoted, *quoted_permalink;
     707        char *quote_url = NULL, *quote_text = NULL, *quote_kort = NULL;
     708        gboolean quote_used = FALSE;
    708709
    709710        if (!((entities = json_o_get(node, "entities")) && entities->type == json_object))
     
    716717                quote_text = g_strdup_printf("@%s: %s", txs->user->screen_name, txs->text);
    717718                quote_url = g_strdup_printf("%s/status/%" G_GUINT64_FORMAT, txs->user->screen_name, txs->id);
     719                if ((quoted_permalink = json_o_get(node, "quoted_status_permalink")) && quoted->type == json_object) {
     720                        quote_kort = json_o_strdup(quoted_permalink, "url");
     721                }
    718722                txs_free(txs);
    719723        } else {
     
    759763                                format = "%s<%s> [%s]%s";
    760764                                disp = quote_text;
     765                                quote_used = TRUE;
    761766                        }
    762767
     
    769774                }
    770775        }
     776
     777        if (quote_text && !quote_used) {
     778                const char *url = quote_kort ?: quote_url;
     779                char *new = g_strdup_printf("%s <%s>[%s]", *text, url, quote_text);
     780                g_free(*text);
     781                *text = new;
     782        }
     783
    771784        g_free(quote_text);
    772785        g_free(quote_url);
     786        g_free(quote_kort);
    773787}
    774788
Note: See TracChangeset for help on using the changeset viewer.