adding post type to json_metadata

This commit is contained in:
Nouman Tahir 2023-09-22 17:37:03 +05:00
parent f23476638a
commit d190ecd3d2
2 changed files with 11 additions and 3 deletions

View File

@ -27,7 +27,7 @@ export const usePostSubmitter = () => {
// handle submit reply
const _submitReply = async (commentBody: string, parentPost: any) => {
const _submitReply = async (commentBody: string, parentPost: any, postType: PostTypes) => {
if (!commentBody) {
return false ;
}
@ -49,7 +49,8 @@ export const usePostSubmitter = () => {
//adding jsonmeta with image ratios here....
const meta = await extractMetadata({
body:commentBody,
fetchRatios:true
fetchRatios:true,
postType
})
const jsonMetadata = makeJsonMetadata(meta, parentTags || ['ecency'])
@ -143,7 +144,7 @@ export const usePostSubmitter = () => {
const _wavesHost = 'ecency.waves' //TODO: make waves host selection dynamic
const latestWavesPost = await wavesQueries.fetchLatestWavesContainer(_wavesHost);
const _cacheCommentData = await _submitReply(body, latestWavesPost)
const _cacheCommentData = await _submitReply(body, latestWavesPost, PostTypes.WAVE)
if(_cacheCommentData){
pusblishWaveMutation.mutate(_cacheCommentData)

View File

@ -3,6 +3,7 @@ import { Image } from 'react-native';
import { diff_match_patch as diffMatchPatch } from 'diff-match-patch';
import VersionNumber from 'react-native-version-number';
import MimeTypes from 'mime-types';
import { PostTypes } from '../constants/postTypes';
export const getWordsCount = (text) =>
text && typeof text === 'string' ? text.replace(/^\s+|\s+$/g, '').split(/\s+/).length : 0;
@ -214,10 +215,12 @@ export const extractMetadata = async ({
body,
thumbUrl,
fetchRatios,
postType
}: {
body: string;
thumbUrl?: string;
fetchRatios?: boolean;
postType?: PostTypes;
}) => {
// NOTE: keepting regex to extract usernames as reference for later usage if any
// const userReg = /(^|\s)(@[a-z][-.a-z\d]+[a-z\d])/gim;
@ -254,6 +257,10 @@ export const extractMetadata = async ({
);
}
if(postType){
out.type = postType
}
return out;
};