Update comment tags and hashtag payload
This commit is contained in:
@@ -250,6 +250,17 @@ export interface PostCommentResponse {
|
||||
export const postComment = async (commentData: PostCommentRequest): Promise<PostCommentResponse> => {
|
||||
try {
|
||||
const identity = await get_id_token();
|
||||
const hashtopic: string[] = [];
|
||||
const regex = /#\S+/g;
|
||||
const matches = commentData.content.match(regex);
|
||||
if (matches) {
|
||||
matches.forEach(tag => {
|
||||
const cleanTag = tag.substring(1);
|
||||
if (!hashtopic.includes(cleanTag)) {
|
||||
hashtopic.push(cleanTag);
|
||||
}
|
||||
});
|
||||
}
|
||||
const response = await fetch('/api/comment', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -257,6 +268,7 @@ export const postComment = async (commentData: PostCommentRequest): Promise<Post
|
||||
},
|
||||
body: JSON.stringify({
|
||||
...commentData,
|
||||
hashtopic,
|
||||
identity,
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user