Skip to content

Commit ca72006

Browse files
authored
audio attachments (keybase#20502)
1 parent 080cef7 commit ca72006

110 files changed

Lines changed: 8288 additions & 6845 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎go/chat/attachments/mime_types.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var mimeTypes = map[string]string{
88
".3gp": "video/3gpp",
99
".3gpp": "video/3gpp",
1010
".7z": "application/x-7z-compressed",
11+
".aac": "audio/aac",
1112
".ai": "application/postscript",
1213
".asf": "video/x-ms-asf",
1314
".asx": "video/x-ms-asf",

‎shared/__mocks__/feature-flags.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ if (!__STORYBOOK__) {
77
const ff: FeatureFlags = {
88
admin: false,
99
airdrop: true,
10+
audioAttachments: true,
1011
chatIndexProfilingEnabled: false,
1112
conflictResolution: false,
1213
dbCleanEnabled: false,

‎shared/actions/chat2-gen.tsx‎

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎shared/actions/chat2/index.tsx‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,6 +2090,44 @@ const attachmentPasted = async (_: TypedState, action: Chat2Gen.AttachmentPasted
20902090
})
20912091
}
20922092

2093+
const sendAudioRecording = async (
2094+
state: TypedState,
2095+
action: Chat2Gen.SendAudioRecordingPayload,
2096+
logger: Saga.SagaLogger
2097+
) => {
2098+
// TODO: add preview call
2099+
// sit here for 400ms for animations
2100+
await Saga.delay(400)
2101+
const conversationIDKey = action.payload.conversationIDKey
2102+
const audioRecording = state.chat2.audioRecording.get(conversationIDKey)
2103+
if (!audioRecording) {
2104+
logger.info('sendAudioRecording: no audio info for send')
2105+
return
2106+
}
2107+
const meta = state.chat2.metaMap.get(conversationIDKey)
2108+
if (!meta) {
2109+
logger.warn('sendAudioRecording: no meta for send')
2110+
return
2111+
}
2112+
const clientPrev = Constants.getClientPrev(state, conversationIDKey)
2113+
const ephemeralLifetime = Constants.getConversationExplodingMode(state, conversationIDKey)
2114+
const ephemeralData = ephemeralLifetime !== 0 ? {ephemeralLifetime} : {}
2115+
await RPCChatTypes.localPostFileAttachmentLocalNonblockRpcPromise({
2116+
arg: {
2117+
...ephemeralData,
2118+
conversationID: Types.keyToConversationID(conversationIDKey),
2119+
filename: audioRecording.path,
2120+
identifyBehavior: RPCTypes.TLFIdentifyBehavior.chatGui,
2121+
metadata: Buffer.from([]),
2122+
outboxID: audioRecording.outboxID,
2123+
title: '',
2124+
tlfName: meta.tlfname,
2125+
visibility: RPCTypes.TLFVisibility.private,
2126+
},
2127+
clientPrev,
2128+
})
2129+
}
2130+
20932131
// Upload an attachment
20942132
function* attachmentsUpload(
20952133
state: TypedState,
@@ -3628,6 +3666,8 @@ function* chat2Saga() {
36283666

36293667
yield* Saga.chainAction2(Chat2Gen.selectConversation, fetchConversationBio)
36303668

3669+
yield* Saga.chainAction2(Chat2Gen.sendAudioRecording, sendAudioRecording, 'sendAudioRecording')
3670+
36313671
yield* Saga.chainAction2(EngineGen.connected, onConnect, 'onConnect')
36323672

36333673
yield* chatTeamBuildingSaga()

‎shared/actions/json/chat2.json‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,28 @@
767767
"setChannelSearchText": {
768768
"_description": "Set filter for channel search",
769769
"text": "string"
770+
},
771+
"enableAudioRecording": {
772+
"conversationIDKey": "Types.ConversationIDKey"
773+
},
774+
"startAudioRecording": {
775+
"conversationIDKey": "Types.ConversationIDKey",
776+
"meteringCb": "(amp: number) => void"
777+
},
778+
"stopAudioRecording": {
779+
"conversationIDKey": "Types.ConversationIDKey",
780+
"stopType": "Types.AudioStopType"
781+
},
782+
"lockAudioRecording": {
783+
"conversationIDKey": "Types.ConversationIDKey"
784+
},
785+
"sendAudioRecording": {
786+
"conversationIDKey": "Types.ConversationIDKey"
787+
},
788+
"setAudioRecordingPostInfo": {
789+
"conversationIDKey": "Types.ConversationIDKey",
790+
"path": "string",
791+
"outboxID": "Buffer"
770792
}
771793
}
772794
}

‎shared/actions/platform-specific/index.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export declare function showShareActionSheet(options: {
1515
export declare function saveAttachmentDialog(filePath: string): Promise<NextURI>
1616
export declare function saveAttachmentToCameraRoll(fileURL: string, mimeType: string): Promise<void>
1717
export declare function requestLocationPermission(mode: RPCChatTypes.UIWatchPositionPerm): Promise<void>
18+
export declare function requestAudioPermission(): Promise<void>
1819
export declare function clearWatchPosition(watchID: number): void
1920
export declare function watchPositionForMap(errFn: () => void): Promise<number>
2021

‎shared/actions/platform-specific/index.desktop.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ const setNixOnLoginStartup = async (enabled: boolean) => {
401401
}
402402

403403
export const requestLocationPermission = () => Promise.resolve()
404+
export const requestAudioPermission = () => Promise.resolve()
404405
export const clearWatchPosition = () => {}
405406
export const watchPositionForMap = () => Promise.resolve(0)
406407

0 commit comments

Comments
 (0)