@@ -36,6 +36,7 @@ import {
3636 PollContentProps ,
3737 StopMessageStreamingButtonProps ,
3838} from '../../components' ;
39+ import { parseLinksFromText } from '../../components/Message/MessageSimple/utils/parseLinks' ;
3940import type { AttachButtonProps } from '../../components/MessageInput/AttachButton' ;
4041import type { CommandsButtonProps } from '../../components/MessageInput/CommandsButton' ;
4142import type { AttachmentUploadProgressIndicatorProps } from '../../components/MessageInput/components/AttachmentPreview/AttachmentUploadProgressIndicator' ;
@@ -75,6 +76,7 @@ import {
7576import { useChannelContext } from '../channelContext/ChannelContext' ;
7677import { useChatContext } from '../chatContext/ChatContext' ;
7778import { useMessageComposerAPIContext } from '../messageComposerContext/MessageComposerAPIContext' ;
79+ import { useOwnCapabilitiesContext } from '../ownCapabilitiesContext/OwnCapabilitiesContext' ;
7880import { useThreadContext } from '../threadContext/ThreadContext' ;
7981import { useTranslationContext } from '../translationContext/TranslationContext' ;
8082import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue' ;
@@ -183,9 +185,12 @@ export type InputMessageInputContextValue = {
183185 AutoCompleteSuggestionList : React . ComponentType < AutoCompleteSuggestionListProps > ;
184186
185187 /**
186- * Custom UI component to render [draggable handle](https://github.com/GetStream/stream-chat-react-native/blob/main/screenshots/docs/1.png) of attachment picker.
188+ * Custom UI component to render [draggable
189+ * handle](https://github.com/GetStream/stream-chat-react-native/blob/main/screenshots/docs/1.png) of attachment
190+ * picker.
187191 *
188- * **Default** [AttachmentPickerBottomSheetHandle](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/AttachmentPickerBottomSheetHandle.tsx)
192+ * **Default**
193+ * [AttachmentPickerBottomSheetHandle](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/AttachmentPickerBottomSheetHandle.tsx)
189194 */
190195 AttachmentPickerBottomSheetHandle : React . FC < BottomSheetHandleProps > ;
191196 /**
@@ -203,7 +208,8 @@ export type InputMessageInputContextValue = {
203208 /**
204209 * Custom UI component for AttachmentPickerSelectionBar
205210 *
206- * **Default: ** [AttachmentPickerSelectionBar](https://github.com/GetStream/stream-chat-react-native/blob/develop/package/src/components/AttachmentPicker/components/AttachmentPickerSelectionBar.tsx)
211+ * **Default: **
212+ * [AttachmentPickerSelectionBar](https://github.com/GetStream/stream-chat-react-native/blob/develop/package/src/components/AttachmentPicker/components/AttachmentPickerSelectionBar.tsx)
207213 */
208214 AttachmentPickerSelectionBar : React . ComponentType ;
209215 /**
@@ -214,33 +220,41 @@ export type InputMessageInputContextValue = {
214220 attachmentSelectionBarHeight : number ;
215221
216222 /**
217- * Custom UI component for [camera selector icon](https://github.com/GetStream/stream-chat-react-native/blob/main/screenshots/docs/1.png)
223+ * Custom UI component for [camera selector
224+ * icon](https://github.com/GetStream/stream-chat-react-native/blob/main/screenshots/docs/1.png)
218225 *
219- * **Default: ** [CameraSelectorIcon](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/CameraSelectorIcon.tsx)
226+ * **Default: **
227+ * [CameraSelectorIcon](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/CameraSelectorIcon.tsx)
220228 */
221229 CameraSelectorIcon : React . ComponentType < AttachmentPickerIconProps > ;
222230 /**
223231 * Custom UI component for the poll creation icon.
224232 *
225- * **Default: ** [CreatePollIcon](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/CreatePollIcon.tsx)
233+ * **Default: **
234+ * [CreatePollIcon](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/CreatePollIcon.tsx)
226235 */
227236 CreatePollIcon : React . ComponentType ;
228237 /**
229- * Custom UI component for [file selector icon](https://github.com/GetStream/stream-chat-react-native/blob/main/screenshots/docs/1.png)
238+ * Custom UI component for [file selector
239+ * icon](https://github.com/GetStream/stream-chat-react-native/blob/main/screenshots/docs/1.png)
230240 *
231- * **Default: ** [FileSelectorIcon](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/FileSelectorIcon.tsx)
241+ * **Default: **
242+ * [FileSelectorIcon](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/FileSelectorIcon.tsx)
232243 */
233244 FileSelectorIcon : React . ComponentType < AttachmentPickerIconProps > ;
234245 /**
235- * Custom UI component for [image selector icon](https://github.com/GetStream/stream-chat-react-native/blob/main/screenshots/docs/1.png)
246+ * Custom UI component for [image selector
247+ * icon](https://github.com/GetStream/stream-chat-react-native/blob/main/screenshots/docs/1.png)
236248 *
237- * **Default: ** [ImageSelectorIcon](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/ImageSelectorIcon.tsx)
249+ * **Default: **
250+ * [ImageSelectorIcon](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/ImageSelectorIcon.tsx)
238251 */
239252 ImageSelectorIcon : React . ComponentType < AttachmentPickerIconProps > ;
240253 /**
241254 * Custom UI component for Android's video recorder selector icon.
242255 *
243- * **Default: ** [VideoRecorderSelectorIcon](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/VideoRecorderSelectorIcon.tsx)
256+ * **Default: **
257+ * [VideoRecorderSelectorIcon](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/AttachmentPicker/components/VideoRecorderSelectorIcon.tsx)
244258 */
245259 VideoRecorderSelectorIcon : React . ComponentType < AttachmentPickerIconProps > ;
246260 AudioAttachmentUploadPreview : React . ComponentType < AudioAttachmentUploadPreviewProps > ;
@@ -428,6 +442,7 @@ export const MessageInputProvider = ({
428442 const { closePicker, openPicker, selectedPicker, setSelectedPicker } =
429443 useAttachmentPickerContext ( ) ;
430444 const { client, enableOfflineSupport } = useChatContext ( ) ;
445+ const channelCapabilities = useOwnCapabilitiesContext ( ) ;
431446
432447 const { uploadAbortControllerRef } = useChannelContext ( ) ;
433448 const { clearEditingState } = useMessageComposerAPIContext ( ) ;
@@ -456,7 +471,8 @@ export const MessageInputProvider = ({
456471
457472 /**
458473 * These are the RN SDK specific middlewares that are added to the message composer to provide the default behaviour.
459- * TODO: Discuss and decide if we provide them by default in the SDK or leave it to the user to add them if they want the feature.
474+ * TODO: Discuss and decide if we provide them by default in the SDK or leave it to the user to add them if they want
475+ * the feature.
460476 */
461477 useEffect ( ( ) => {
462478 if ( value . doFileUploadRequest ) {
@@ -602,7 +618,15 @@ export const MessageInputProvider = ({
602618
603619 const composition = await messageComposer . compose ( ) ;
604620 if ( ! composition || ! composition . message ) return ;
621+
605622 const { localMessage, message, sendOptions } = composition ;
623+ const linkInfos = parseLinksFromText ( localMessage . text ) ;
624+
625+ if ( ! channelCapabilities . sendLinks && linkInfos . length > 0 ) {
626+ Alert . alert ( t ( 'Links are disabled' ) , t ( 'Sending links is not allowed in this conversation' ) ) ;
627+
628+ return ;
629+ }
606630
607631 if ( editedMessage && editedMessage . type !== 'error' ) {
608632 try {
0 commit comments