Every time user enters a tribe chat, we are getting the updated info of that tribe from tribes server (using the host of the chat object). If feedUrl
is not empty on that tribe info coming from tribes server host, then we should get the podcast feed data requesting a new endpoint:
The response will be a json object containing information about podcast, episodes and payments destinations. Here is an example with just one episode to make it shorter:
{
"id": 226249,
"title": "Tales from the Crypt: A Bitcoin Podcast",
"url": "https://anchor.fm/s/558f520/podcast/rss",
"description": "Tales from the Crypt is a podcast hosted by Marty Bent about Bitcoin. Join Marty, Editor in Chief of \"the best newsletter in Bitcoin\", as he sits down to discuss Bitcoin with interesting people.",
"author": "Marty Bent",
"image": "https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded_nologo/797160/797160-1579811341935-88e5cd5024bf9.jpg",
"link": "https://anchor.fm/tales-from-the-crypt",
"lastUpdateTime": 1622662235,
"contentType": "application/rss+xml; charset=utf-8",
"language": "en-us",
"episodes": [{
"id": 2541203462,
"title": "#258: The morality of ESG with Untapped Growth",
"description": "\u003cp\u003eJoin Marty as he sits down with Untapped Growth to discuss:\u003c/p\u003e\n\u003cp\u003e- ESG\u003c/p\u003e\n\u003cp\u003e- Is it moral?\u003c/p\u003e\n\u003cp\u003e- Can it be leveraged to speculative attack the fiat standard?\u003c/p\u003e\n\u003cp\u003e- How can Bitcoin lead to better culture\u003c/p\u003e\n\u003cp\u003e- Seeking objective truth\u003c/p\u003e\n\u003cp\u003e- much more\u003c/p\u003e\n\u003cp\u003eFollow Untapped Growth on Twitter\u003c/p\u003e\n\u003cp\u003eShoutout to this week's sponsors.\u003c/p\u003e\n\u003cp\u003eCash App. Start #stackingsats today. Use the promo code: \"stackingsats\" to receive $10 and contribute $10 to OWLS Lacrosse when you download the app.\u003c/p\u003e\n\u003cp\u003eLend at Hodl Hodl...",
"datePublished": 1622638800,
"enclosureUrl": "https://anchor.fm/s/558f520/podcast/play/34682465/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fstaging%2F2021-5-2%2F192649643-44100-2-c36483521f93a.m4a",
"enclosureType": "audio/x-m4a",
"enclosureLength": 121008979,
"image": "https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded_nologo/797160/797160-1579811341935-88e5cd5024bf9.jpg",
"link": "https://anchor.fm/tales-from-the-crypt/episodes/258-The-morality-of-ESG-with-Untapped-Growth-e120u51"
}],
"value": {
"model": {
"type": "lightning",
"suggested": "0.00000005000"
},
"destinations": [{
"address": "02c6aa9067f0b31be4abc5fd811a93266f1f4bf4c4b57d4663fe5b7e3ed1a9860b",
"split": 100,
"type": "node"
}, {
"address": "03ae9f91a0cb8ff43840e3c322c4c61f019d8c1c3cea15a25cfc425ac605e61a4a",
"split": 1,
"type": "node"
}]
}
}
On iOS we are not storing this permanently on db since it will be fetched every time you go into the chat, and it should just show the player if feed_url is not empty on tribe at that time, and if episodes array contains at least 1 episode. The enclosureUrl of each episode points to the audio file that should be played.
In addition, to be in sync between platform we are sending to relay the information about current podcast state using the updateChat endpoint:
This endpoint is hit when playing or pausing an episode, when finishing moving on timestamp slider, and when an episode ends.
In the other hand, on every chats fetch, we are getting the "meta" of each chat and storing it on UserDefaults so then it can be used to set the player controls on the latest state on other platforms. I think it's ok to store all this information in UserDefaults since it's not sensitive information.