Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: V3 split towards a V3 Only World #1189

Open
wants to merge 16 commits into
base: release/3.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class PushNotificationsService : FirebaseMessagingService() {
val newNotificationDataJson = Klaxon().toJsonString(newNotificationData)
remoteMessage.data["body"] = newNotificationDataJson
}
} else if (isGroupWelcomeTopic(notificationData.contentTopic)) {
} else if (isV3WelcomeTopic(notificationData.contentTopic)) {
val group = getNewGroup(xmtpClient, notificationData.contentTopic)
if (group != null) {
result = handleGroupWelcome(
Expand All @@ -168,7 +168,7 @@ class PushNotificationsService : FirebaseMessagingService() {
shouldShowNotification = result.shouldShowNotification
}
}
} else if (isGroupMessageTopic(notificationData.contentTopic)) {
} else if (isV3MessageTopic(notificationData.contentTopic)) {
Log.d(TAG, "Handling an ongoing group message notification")
result = handleGroupMessage(
applicationContext,
Expand Down Expand Up @@ -289,7 +289,7 @@ class PushNotificationsService : FirebaseMessagingService() {
)
return@launch
}
val groupId = getGroupIdFromTopic(notification.contentTopic)
val groupId = getV3IdFromTopic(notification.contentTopic)
val group = getGroup(xmtpClient, groupId)
if (group != null) {
group.sync()
Expand Down
6 changes: 3 additions & 3 deletions android/app/src/main/java/com/converse/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ fun isIntroTopic(topic: String): Boolean {
return topic.startsWith("/xmtp/0/intro-")
}

fun isGroupMessageTopic(topic: String): Boolean {
fun isV3MessageTopic(topic: String): Boolean {
return topic.startsWith("/xmtp/mls/1/g-")
}

fun getGroupIdFromTopic(topic: String): String {
fun getV3IdFromTopic(topic: String): String {
return topic.replace("/xmtp/mls/1/g-", "").replace("/proto", "")
}

fun isGroupWelcomeTopic(topic: String): Boolean {
fun isV3WelcomeTopic(topic: String): Boolean {
return topic.startsWith("/xmtp/mls/1/w-")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fun persistNewConversation(appContext:Context, account: String, conversation: Co

suspend fun getNewGroup(xmtpClient: Client, contentTopic: String): Group? {
return try {
if (isGroupWelcomeTopic(contentTopic)) {
if (isV3WelcomeTopic(contentTopic)) {
// Welcome envelopes are too large to send in a push, so a bit of a hack to get the latest group
xmtpClient.conversations.syncGroups()
val groups = xmtpClient.conversations.listGroups()
Expand Down
5 changes: 2 additions & 3 deletions android/app/src/main/java/com/converse/xmtp/Messages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@ suspend fun handleGroupMessage(
envelope: Envelope,
remoteMessage: RemoteMessage,
): NotificationDataResult {
// No need to sync groups here, because it's already a known group
val group = xmtpClient.findGroup(getGroupIdFromTopic(envelope.contentTopic))
val group = xmtpClient.findGroup(getV3IdFromTopic(envelope.contentTopic))
if (group == null) {
Log.d("PushNotificationsService", "No group found for ${envelope.contentTopic}")
return NotificationDataResult()
Expand Down Expand Up @@ -357,7 +356,7 @@ fun handleMessageByContentType(
val schema = reaction?.schema?.javaClass?.simpleName?.lowercase()
val content = reaction?.content
referencedMessageId = reaction?.reference
forceIgnore = action == "removed" || (isGroupMessageTopic(decodedMessage.topic) && referencedMessageId !== null && !isGroupMessageFromMe(xmtpClient, referencedMessageId))
forceIgnore = action == "removed" || (isV3MessageTopic(decodedMessage.topic) && referencedMessageId !== null && !isGroupMessageFromMe(xmtpClient, referencedMessageId))
contentToSave = getJsonReaction(decodedMessage)
contentToReturn = when {
action != "removed" && schema == "unicode" && content != null -> "Reacted $content to a message"
Expand Down
2 changes: 1 addition & 1 deletion components/Chat/Attachment/AddAttachmentButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { Platform, StyleSheet, useColorScheme } from "react-native";
import { v4 as uuidv4 } from "uuid";

import { useAccountsStore } from "../../../data/store/accountsStore";
import { uploadRemoteAttachment } from "../../../utils/attachment";
import { useConversationContext } from "../../../utils/conversation";
import { converseEventEmitter } from "../../../utils/events";
import {
Expand All @@ -22,6 +21,7 @@ import {
import { sentryTrackMessage } from "../../../utils/sentry";
import { encryptRemoteAttachment } from "../../../utils/xmtpRN/attachments";
import ActionButton from "../ActionButton";
import { uploadRemoteAttachment } from "@utils/attachment/uploadRemoteAttachment";

const DATA_MIMETYPE_REGEX = /data:(.*?);/;

Expand Down
2 changes: 1 addition & 1 deletion components/Chat/Attachment/AttachmentMessagePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import {
TouchableOpacity,
} from "react-native";

import { useAttachmentForMessage } from "../../../utils/attachment";
import { converseEventEmitter } from "../../../utils/events";
import { navigate } from "../../../utils/navigation";
import ActivityIndicator from "../../ActivityIndicator/ActivityIndicator";
import Picto from "../../Picto/Picto";
import { MessageToDisplay } from "../Message/Message";
import MessageTimestamp from "../Message/MessageTimestamp";
import { useAttachmentForMessage } from "@utils/attachment/useAttachmentForMessage";

type Props = {
message: MessageToDisplay;
Expand Down
14 changes: 2 additions & 12 deletions components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,20 @@ import {
ReanimatedView,
} from "../../utils/animations";
import { useKeyboardAnimation } from "../../utils/animations/keyboardAnimation";
import { isAttachmentMessage } from "../../utils/attachment/helpers";
import { isAttachmentMessage } from "@utils/attachment/isAttachmentMessage";
import { useConversationContext } from "../../utils/conversation";
import { converseEventEmitter } from "../../utils/events";
import { getProfile, getProfileData } from "../../utils/profile";
import { UUID_REGEX } from "../../utils/regex";
import { isContentType } from "../../utils/xmtpRN/contentTypes";
import { Recommendation } from "../Recommendations/Recommendation";
import ChatPlaceholder from "./ChatPlaceholder/ChatPlaceholder";
import { GroupChatPlaceholder } from "./ChatPlaceholder/GroupChatPlaceholder";
import ConsentPopup from "./ConsentPopup/ConsentPopup";
import { GroupConsentPopup } from "./ConsentPopup/GroupConsentPopup";
import ChatInput from "./Input/Input";
import CachedChatMessage, { MessageToDisplay } from "./Message/Message";
import { useMessageReactionsStore } from "./Message/MessageReactions/MessageReactionsDrawer/MessageReactions.store";
import { MessageReactionsDrawer } from "./Message/MessageReactions/MessageReactionsDrawer/MessageReactionsDrawer";
import TransactionInput from "./Transaction/TransactionInput";

const usePeerSocials = () => {
const conversation = useConversationContext("conversation");
Expand Down Expand Up @@ -293,7 +291,6 @@ export function Chat() {
const AnimatedListView = useAnimatedListView(conversation);
const isBlockedPeer = useConversationContext("isBlockedPeer");
const onReadyToFocus = useConversationContext("onReadyToFocus");
const transactionMode = useConversationContext("transactionMode");
const frameTextInputFocused = useConversationContext("frameTextInputFocused");
const rolledUpReactions =
useMessageReactionsStore.getState().rolledUpReactions;
Expand Down Expand Up @@ -499,9 +496,6 @@ export function Chat() {
{showPlaceholder && !conversation?.isGroup && (
<ChatPlaceholder messagesCount={listArray.length} />
)}
{showPlaceholder && conversation?.isGroup && (
<GroupChatPlaceholder messagesCount={listArray.length} />
)}
{conversation?.isGroup ? <GroupConsentPopup /> : <ConsentPopup />}
</Animated.View>
{showChatInput && (
Expand All @@ -514,8 +508,7 @@ export function Chat() {
},
]}
>
{!transactionMode && <ChatInput inputHeight={chatInputHeight} />}
{transactionMode && <TransactionInput />}
<ChatInput inputHeight={chatInputHeight} />
</ReanimatedView>
<View
style={[
Expand Down Expand Up @@ -626,9 +619,6 @@ export function ChatPreview() {
{showPlaceholder && !conversation?.isGroup && (
<ChatPlaceholder messagesCount={listArray.length} />
)}
{showPlaceholder && conversation?.isGroup && (
<GroupChatPlaceholder messagesCount={listArray.length} />
)}
</Animated.View>
</View>
);
Expand Down
Loading
Loading