twindle-co / twindle

Twindle - an open source project for beginners. Converting twitter threads to pdf, epub, and mobi format to be read by Kindle.
https://www.twindle.co
MIT License
134 stars 133 forks source link

Structure for the thread that needs to be passed to the handlebars template #821

Closed Mira-Alf closed 3 years ago

Mira-Alf commented 3 years ago

Important attributes explained

Questions

Will be good to have some clarity before making changes in the code.

Currently we have our code producing pdf for the three different scenarios:

Things to do:

Will need an elaborate discussion on this.

Proful commented 3 years ago

For issue #818, @proful wanted replies by a user on a thread to which the original author of the thread has replied, what about the json structure for this scenario.

For this I think it should be different flow, json and templates. Just a thought.

johnjacobkenny commented 3 years ago

@Mira-Alf Correct me if I'm wrong, but the structure that you have shared has many similarities with the twitter response structure. Do we need to have all of the fields and the structure as twitter gives us?

Mira-Alf commented 3 years ago

@Mira-Alf Correct me if I'm wrong, but the structure that you have shared has many similarities with the twitter response structure. Do we need to have all of the fields and the structure as twitter gives us?

Hey @johnjacobkenny the structure that I have displayed here has all the elements that the pdf template needs for complex tweets rendering. So @PuruVJ has basically picked off the elements that we will need from the twitter API response - sometimes, he has picked objects without destructuring, so it looks more complex than it needs to be.

But now I hope you understand my hesitation in cleaning this up because there are too many elements involved. So it will be good to have a discussion to get a clean structure which we can also replicate for other structures.

johnjacobkenny commented 3 years ago

@Mira-Alf I feel that it would be good if we could come up with a structure that is not tied to twitter API, then we would be able to know better which parts go where.

Mira-Alf commented 3 years ago

@PuruVJ, @johnjacobkenny and I had a call about this issue. And @PuruVJ suggested a structure like this:

{
   "data":[
      {
         "id":"id",
         "date":"date",
         "text":"berirv",
         "type":"original"
      },
      {
         "id":"bev",
         "date":"bbf",
         "text":"bebrkv",
         "type":"question",
         "reply":{
            "id":"jbvbkvjbj",
            "date":"bekjv",
            "text":"bvj",
            "userInfo":{

            }
         }
      }
   ]
}

There is one issue with this structure - it doesnt record what tweet of the thread the reply tweet is a reply to.. I am going to work on this structure with an example tweet and update this issue.

Others please leave comments on what you guys think

johnjacobkenny commented 3 years ago

@Mira-Alf could you please format the content so it is readable

Mira-Alf commented 3 years ago

@Mira-Alf could you please format the content so it is readable

Does it not look formatted? It looks like that to me.

The new structure is in this updated gist: https://gist.github.com/Mira-Alf/29262cec0252cbd72e1f93358fc28c20

Here are the key attributes:

So now every reply is tied to one tweet of the thread and every reply has user information and answer provided by the author of the thread

Let me know if you guys have any questions

johnjacobkenny commented 3 years ago

Sounds good to me! 🥳

PuruVJ commented 3 years ago

We have standardized on a structure (For now 🙄). See https://github.com/twindle-co/twindle/blob/main/twindle-cli/src/twitter/types/types.d.ts#L155

A little snippet here:

export interface CustomTweetData {
  id: string;
  created_at: string;
  tweet: string;
  customMedia?: CustomMedia;

  linkWithImage?: Partial<LinkWithImage>;

  embeddedTweet?: ConversationResponseData;
  embeddedTweetUser?: User;

  replies?: Reply[];
}

export interface CustomTweets {
  common: {
    id: string;
    count: number;
    created_at?: string;
    user?: Partial<User>;
  };
  data: CustomTweetData[];
}