diff --git a/app/src/main/java/com/futo/polycentric/core/Claims.kt b/app/src/main/java/com/futo/polycentric/core/Claims.kt index a0d5c0484795b6c4600df9eacdd961e85eccfdbf..b44ba9e8502d3864d6ee41f219d8a75d27e2261c 100644 --- a/app/src/main/java/com/futo/polycentric/core/Claims.kt +++ b/app/src/main/java/com/futo/polycentric/core/Claims.kt @@ -40,6 +40,70 @@ class Claims { return claim(ClaimType.BITCOIN.value, id); } + fun twitter(id: String): Protocol.Claim { + return claim(ClaimType.TWITTER.value, id) + } + + fun generic(id: String): Protocol.Claim { + return claim(ClaimType.GENERIC.value, id) + } + + fun github(id: String): Protocol.Claim { + return claim(ClaimType.GITHUB.value, id) + } + + fun minds(id: String): Protocol.Claim { + return claim(ClaimType.MINDS.value, id) + } + + fun patreon(id: String): Protocol.Claim { + return claim(ClaimType.PATREON.value, id) + } + + fun substack(id: String): Protocol.Claim { + return claim(ClaimType.SUBSTACK.value, id) + } + + fun website(id: String): Protocol.Claim { + return claim(ClaimType.WEBSITE.value, id) + } + + fun kick(id: String): Protocol.Claim { + return claim(ClaimType.KICK.value, id) + } + + fun soundcloud(id: String): Protocol.Claim { + return claim(ClaimType.SOUNDCLOUD.value, id) + } + + fun vimeo(id: String): Protocol.Claim { + return claim(ClaimType.VIMEO.value, id) + } + + fun nebula(id: String): Protocol.Claim { + return claim(ClaimType.NEBULA.value, id) + } + + fun occupation(id: String): Protocol.Claim { + return claim(ClaimType.OCCUPATION.value, id) + } + + fun skill(id: String): Protocol.Claim { + return claim(ClaimType.SKILL.value, id) + } + + fun spotify(id: String): Protocol.Claim { + return claim(ClaimType.SPOTIFY.value, id) + } + + fun spreadshop(id: String): Protocol.Claim { + return claim(ClaimType.SPREADSHOP.value, id) + } + + fun polycentric(id: String): Protocol.Claim { + return claim(ClaimType.POLYCENTRIC.value, id) + } + fun claim(claimType: Long, id: String?): Protocol.Claim{ return Protocol.Claim.newBuilder() .setClaimType(claimType) @@ -54,18 +118,65 @@ class Claims { fun Protocol.Claim.toUrl(): String? { return when (claimType) { + ClaimType.HACKER_NEWS.value -> "https://news.ycombinator.com/user?id=${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" ClaimType.YOUTUBE.value -> { - val c = Protocol.ClaimIdentifier.parseFrom(claim).identifier; - if (c.startsWith('@')) "https://www.youtube.com/$c" else "https://www.youtube.com/channel/$c"; - } - ClaimType.ODYSEE.value ->"https://odysee.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" - ClaimType.RUMBLE.value ->"https://rumble.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" - ClaimType.TWITTER.value ->"https://twitter.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" - ClaimType.DISCORD.value ->"https://discordapp.com/users/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" - ClaimType.INSTAGRAM.value ->"https://instagram.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" - ClaimType.TWITCH.value ->"https://www.twitch.tv/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" - ClaimType.PATREON.value ->"https://www.patreon.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + val c = Protocol.ClaimIdentifier.parseFrom(claim).identifier + if (c.startsWith('@')) "https://www.youtube.com/$c" else "https://www.youtube.com/channel/$c" + } + ClaimType.ODYSEE.value -> "https://odysee.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.RUMBLE.value -> "https://rumble.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.TWITTER.value -> "https://twitter.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.BITCOIN.value -> "bitcoin:${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.GENERIC.value -> Protocol.ClaimIdentifier.parseFrom(claim).identifier + ClaimType.DISCORD.value -> "https://discordapp.com/users/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.INSTAGRAM.value -> "https://instagram.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.GITHUB.value -> "https://github.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.MINDS.value -> "https://www.minds.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.PATREON.value -> "https://www.patreon.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.SUBSTACK.value -> "https://${Protocol.ClaimIdentifier.parseFrom(claim).identifier}.substack.com" //TODO: Check this + ClaimType.TWITCH.value -> "https://www.twitch.tv/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.WEBSITE.value -> Protocol.ClaimIdentifier.parseFrom(claim).identifier + ClaimType.KICK.value -> "https://www.kickstarter.com/profile/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" //TODO: Check this + ClaimType.SOUNDCLOUD.value -> "https://soundcloud.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.VIMEO.value -> "https://vimeo.com/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.NEBULA.value -> "https://nebula.tv/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" ClaimType.URL.value -> Protocol.ClaimIdentifier.parseFrom(claim).identifier + ClaimType.OCCUPATION.value -> null + ClaimType.SKILL.value -> null + ClaimType.SPOTIFY.value -> "https://open.spotify.com/user/${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" + ClaimType.SPREADSHOP.value -> "https://${Protocol.ClaimIdentifier.parseFrom(claim).identifier}.spreadshop.com" //TODO: Check this + ClaimType.POLYCENTRIC.value -> "polycentric://${Protocol.ClaimIdentifier.parseFrom(claim).identifier}" else -> null } } + +fun Protocol.Claim.toName(): String? { + return when (claimType) { + ClaimType.HACKER_NEWS.value -> "HackerNews" + ClaimType.YOUTUBE.value -> "YouTube" + ClaimType.ODYSEE.value -> "Odysee" + ClaimType.RUMBLE.value -> "Rumble" + ClaimType.TWITTER.value -> "Twitter" + ClaimType.BITCOIN.value -> "Bitcoin" + ClaimType.GENERIC.value -> "Generic" + ClaimType.DISCORD.value -> "Discord" + ClaimType.INSTAGRAM.value -> "Instagram" + ClaimType.GITHUB.value -> "GitHub" + ClaimType.MINDS.value -> "Minds" + ClaimType.PATREON.value -> "Patreon" + ClaimType.SUBSTACK.value -> "Substack" + ClaimType.TWITCH.value -> "Twitch" + ClaimType.WEBSITE.value -> "Website" + ClaimType.KICK.value -> "Kick" + ClaimType.SOUNDCLOUD.value -> "Soundcloud" + ClaimType.VIMEO.value -> "Vimeo" + ClaimType.NEBULA.value -> "Nebula" + ClaimType.URL.value -> "URL" + ClaimType.OCCUPATION.value -> "Occupation" + ClaimType.SKILL.value -> "Skill" + ClaimType.SPOTIFY.value -> "Spotify" + ClaimType.SPREADSHOP.value -> "Spreadshop" + ClaimType.POLYCENTRIC.value -> "Polycentric" + else -> "unknown" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/futo/polycentric/core/Models.kt b/app/src/main/java/com/futo/polycentric/core/Models.kt index db9831ada01f94f6279fb05fc972ccd18c5c255f..6ac86b88678eedcbe7d6a180544600bf5b8af846 100644 --- a/app/src/main/java/com/futo/polycentric/core/Models.kt +++ b/app/src/main/java/com/futo/polycentric/core/Models.kt @@ -34,11 +34,25 @@ enum class ClaimType(val value: Long) { GENERIC(7), DISCORD(8), INSTAGRAM(9), + GITHUB(10), + MINDS(11), PATREON(12), + SUBSTACK(13), TWITCH(14), - URL(20) + WEBSITE(15), + KICK(16), + SOUNDCLOUD(17), + VIMEO(18), + NEBULA(19), + URL(20), + OCCUPATION(21), + SKILL(22), + SPOTIFY(23), + SPREADSHOP(24), + POLYCENTRIC(25) } + class Blob(val mime: String, val content: ByteArray) { } @Serializable class Digest(val digestType: Long, @Serializable(with = ByteArraySerializer::class) val digest: ByteArray) {