Skip to content

Commit

Permalink
GrindrPlus: Fix AntiBlock formatting
Browse files Browse the repository at this point in the history
Change-Id: I3e262ec17a3f2bc2f036e04ca26e83317d10fa4a
  • Loading branch information
R0rt1z2 committed Jan 2, 2025
1 parent 97e20bf commit b8e2c67
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions app/src/main/java/com/grindrplus/hooks/AntiBlock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,48 +96,48 @@ class AntiBlock : Hook(
}
}

private fun handleProfileResponse(profileId: Long, conversationIds: String, response: String) {
try {
val jsonResponse = JSONObject(response)
val profilesArray = jsonResponse.optJSONArray("profiles")
private fun handleProfileResponse(profileId: Long, conversationIds: String, response: String) {
try {
val jsonResponse = JSONObject(response)
val profilesArray = jsonResponse.optJSONArray("profiles")

if (profilesArray == null || profilesArray.length() == 0) {
var name = (DatabaseHelper.query(
"SELECT name FROM chat_conversations WHERE conversation_id = ?",
arrayOf(conversationIds)
).firstOrNull()?.get("name") as? String)?.takeIf {
name -> name.isNotEmpty() } ?: profileId.toString()
name = if (name == profileId.toString() || name == "null")
{ profileId.toString() } else { "$name ($profileId)" }
GrindrPlus.logger.log("User $name has blocked you")
if (Config.get("anti_block_use_toasts", false) as Boolean) {
GrindrPlus.showToast(Toast.LENGTH_LONG, "Blocked by $name")
} else {
sendNotification(
GrindrPlus.context,
"Blocked by User",
"You have been blocked by user $name",
profileId.toInt()
)
}
} else {
val profile = profilesArray.getJSONObject(0)
val displayName = profile.optString("displayName", profileId.toString())
.takeIf { it.isNotEmpty() && it != "null" } ?: profileId.toString()
GrindrPlus.logger.log("User $profileId (Name: $displayName) unblocked you")
if (Config.get("anti_block_use_toasts", false) as Boolean) {
GrindrPlus.showToast(Toast.LENGTH_LONG, "Unblocked by $displayName")
if (profilesArray == null || profilesArray.length() == 0) {
var name = (DatabaseHelper.query(
"SELECT name FROM chat_conversations WHERE conversation_id = ?",
arrayOf(conversationIds)
).firstOrNull()?.get("name") as? String)?.takeIf {
name -> name.isNotEmpty() } ?: profileId.toString()
name = if (name == profileId.toString() || name == "null")
{ profileId.toString() } else { "$name ($profileId)" }
GrindrPlus.logger.log("User $name has blocked you")
if (Config.get("anti_block_use_toasts", false) as Boolean) {
GrindrPlus.showToast(Toast.LENGTH_LONG, "Blocked by $name")
} else {
sendNotification(
GrindrPlus.context,
"Blocked by User",
"You have been blocked by user $name",
profileId.toInt()
)
}
} else {
sendNotification(
GrindrPlus.context,
"Unblocked by $displayName",
"$displayName has unblocked you.",
profileId.toInt(),
)
val profile = profilesArray.getJSONObject(0)
val displayName = profile.optString("displayName", profileId.toString())
.takeIf { it.isNotEmpty() && it != "null" } ?: profileId.toString()
GrindrPlus.logger.log("User $profileId (Name: $displayName) unblocked you")
if (Config.get("anti_block_use_toasts", false) as Boolean) {
GrindrPlus.showToast(Toast.LENGTH_LONG, "Unblocked by $displayName")
} else {
sendNotification(
GrindrPlus.context,
"Unblocked by $displayName",
"$displayName has unblocked you.",
profileId.toInt(),
)
}
}
} catch (e: Exception) {
GrindrPlus.logger.log("Error handling profile response: ${e.message}")
}
} catch (e: Exception) {
GrindrPlus.logger.log("Error handling profile response: ${e.message}")
}
}
}

0 comments on commit b8e2c67

Please sign in to comment.