Skip to content

Commit

Permalink
record message sent
Browse files Browse the repository at this point in the history
  • Loading branch information
ratik21 committed Oct 18, 2023
1 parent 4ab611c commit 72d342a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lib/chat/matrix-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { EditMessageOptions, MessagesResponse } from '../../store/messages';
import { FileUploadResult } from '../../store/messages/saga';
import { ParentMessage, User } from './types';
import { config } from '../../config';
import { get } from '../api/rest';
import { get, post } from '../api/rest';
import { MemberNetworks } from '../../store/users/types';
import { ConnectionStatus, MatrixConstants, MembershipStateType } from './matrix/types';
import { getFilteredMembersForAutoComplete, setAsDM } from './matrix/utils';
Expand Down Expand Up @@ -266,12 +266,22 @@ export class MatrixClient implements IChatClient {

const messageResult = await this.matrix.sendMessage(channelId, content);
const newMessage = await this.getMessageByRoomId(channelId, messageResult.event_id);
await this.recordMessageSent(channelId, newMessage.createdAt);
return {
...newMessage,
optimisticId,
};
}

async recordMessageSent(roomId: string, sentAt: number): Promise<void> {
const data = { roomId, sentAt };

await post<any>('/matrix/message')
.send(data)
.catch((_error) => null)
.then((response) => response?.body || []);
}

async editMessage(
roomId: string,
messageId: string,
Expand Down

0 comments on commit 72d342a

Please sign in to comment.