Merge pull request #1026 from davotoula/chage-twitter-to-x

Change twitter proof to use x.com
This commit is contained in:
Vitor Pamplona 2024-08-21 07:51:04 -04:00 committed by GitHub
commit d61d14ea75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 18 additions and 39 deletions

View File

@ -26,11 +26,9 @@ import com.vitorpamplona.amethyst.commons.richtext.RichTextViewerState
import com.vitorpamplona.quartz.events.ImmutableListOfLists
object CachedRichTextParser {
val richTextCache = LruCache<Int, RichTextViewerState>(50)
private val richTextCache = LruCache<Int, RichTextViewerState>(50)
// fun getCached(content: String): RichTextViewerState? = richTextCache[content]
fun hashCodeCache(
private fun hashCodeCache(
content: String,
tags: ImmutableListOfLists<String>,
callbackUri: String?,

View File

@ -954,7 +954,7 @@ fun WatchIsHiddenUser(
fun getIdentityClaimIcon(identity: IdentityClaim): Int =
when (identity) {
is TwitterIdentity -> R.drawable.twitter
is TwitterIdentity -> R.drawable.x
is TelegramIdentity -> R.drawable.telegram
is MastodonIdentity -> R.drawable.mastodon
is GitHubIdentity -> R.drawable.github

View File

@ -1,7 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="128dp" android:viewportHeight="512"
android:viewportWidth="512" android:width="128dp">
<path
android:pathData="M437,152a72,72 0,0 1,-40 12a72,72 0,0 0,32 -40a72,72 0,0 1,-45 17a72,72 0,0 0,-122 65a200,200 0,0 1,-145 -74a72,72 0,0 0,22 94a72,72 0,0 1,-32 -7a72,72 0,0 0,56 69a72,72 0,0 1,-32 1a72,72 0,0 0,67 50a200,200 0,0 1,-105 29a200,200 0,0 0,309 -179a200,200 0,0 0,35 -37"
android:fillColor="#1da1f2"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="24"
android:viewportHeight="24"
android:width="128dp"
android:height="128dp">
<path
android:fillColor="#1da1f2"
android:pathData="M10.053 7.988l5.631 8.024h-1.497L8.566 7.988H10.053zM21 6v12c0 1.657 -1.343 3 -3 3H6c-1.657 0 -3 -1.343 -3 -3V6c0 -1.657 1.343 -3 3 -3h12C19.657 3 21 4.343 21 6zM17.538 17l-4.186 -5.99L16.774 7h-1.311l-2.704 3.16L10.552 7H6.702l3.941 5.633L6.906 17h1.333l3.001 -3.516L13.698 17H17.538z" />
</vector>

View File

@ -255,11 +255,11 @@
<string name="github" translatable="false">Github Gist w/ Proof</string>
<string name="telegram" translatable="false">Telegram</string>
<string name="mastodon" translatable="false">Mastodon Post ID w/ Proof</string>
<string name="twitter" translatable="false">Twitter Status w/ Proof</string>
<string name="twitter" translatable="false">X Status w/ Proof</string>
<string name="github_proof_url_template" translatable="false">https://gist.github.com/&lt;user&gt;/&lt;gist&gt;</string>
<string name="telegram_proof_url_template" translatable="false">https://t.me/&lt;proof post&gt;</string>
<string name="mastodon_proof_url_template" translatable="false">https://&lt;server&gt;/&lt;user&gt;/&lt;proof post&gt;</string>
<string name="twitter_proof_url_template" translatable="false">https://twitter.com/&lt;user&gt;/status/&lt;proof post&gt;</string>
<string name="twitter_proof_url_template" translatable="false">https://x.com/&lt;user&gt;/status/&lt;proof post&gt;</string>
<string name="private_conversation_notification">"&lt;Unable to decrypt private message&gt;\n\nYou were cited in a private/encrypted conversation between %1$s and %2$s."</string>
<string name="account_switch_add_account_dialog_title">Add New Account</string>
<string name="drawer_accounts">Accounts</string>

View File

@ -45,7 +45,7 @@ abstract class IdentityClaim(
fun create(
platformIdentity: String,
proof: String,
): IdentityClaim? {
): IdentityClaim {
val (platform, identity) = platformIdentity.split(':')
return when (platform.lowercase()) {
@ -87,7 +87,7 @@ class TwitterIdentity(
identity: String,
proof: String,
) : IdentityClaim(identity, proof) {
override fun toProofUrl() = "https://twitter.com/$identity/status/$proof"
override fun toProofUrl() = "https://x.com/$identity/status/$proof"
override fun platform() = platform
@ -97,7 +97,7 @@ class TwitterIdentity(
fun parseProofUrl(proofUrl: String): TwitterIdentity? {
return try {
if (proofUrl.isBlank()) return null
val path = proofUrl.removePrefix("https://twitter.com/").split("?")[0].split("/")
val path = proofUrl.removePrefix("https://x.com/").split("?")[0].split("/")
TwitterIdentity(path[0], path[2])
} catch (e: Exception) {
@ -166,7 +166,7 @@ class MetadataEvent(
.filter { it.firstOrNull() == "i" }
.mapNotNull {
try {
IdentityClaim.create(it.get(1), it.get(2))
IdentityClaim.create(it[1], it[2])
} catch (e: Exception) {
Log.e("MetadataEvent", "Can't parse identity [${it.joinToString { "," }}]", e)
null
@ -265,26 +265,5 @@ class MetadataEvent(
currentJson.put(key, value.trim())
}
}
fun createFromScratch(
newName: String,
signer: NostrSigner,
createdAt: Long = TimeUtils.now(),
onReady: (MetadataEvent) -> Unit,
) {
val prop = ObjectMapper().createObjectNode()
prop.put("name", newName.trim())
val writer = StringWriter()
ObjectMapper().writeValue(writer, prop)
val tags = mutableListOf<Array<String>>()
tags.add(
arrayOf("alt", "User profile for $newName"),
)
signer.sign(createdAt, KIND, tags.toTypedArray(), writer.buffer.toString(), onReady)
}
}
}