-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #546 from xmtp/np/consent-streaming
Add ability to stream consent
- Loading branch information
Showing
21 changed files
with
1,212 additions
and
754 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
460 changes: 250 additions & 210 deletions
460
android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt
Large diffs are not rendered by default.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ConsentWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.GsonBuilder | ||
import org.xmtp.android.library.ConsentRecord | ||
import org.xmtp.android.library.ConsentState | ||
|
||
class ConsentWrapper { | ||
|
||
companion object { | ||
fun encode(model: ConsentRecord): String { | ||
val gson = GsonBuilder().create() | ||
val message = encodeMap(model) | ||
return gson.toJson(message) | ||
} | ||
|
||
fun encodeMap(model: ConsentRecord): Map<String, Any> = mapOf( | ||
"type" to model.entryType.name.lowercase(), | ||
"value" to model.value.lowercase(), | ||
"state" to consentStateToString(model.consentType), | ||
) | ||
|
||
fun consentStateToString(state: ConsentState): String { | ||
return when (state) { | ||
ConsentState.ALLOWED -> "allowed" | ||
ConsentState.DENIED -> "denied" | ||
ConsentState.UNKNOWN -> "unknown" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.