updated Post.json() topic_tag generation

This commit is contained in:
Jonathan Barrow 2023-10-02 23:06:40 -04:00
parent e529afe540
commit 1fd63bee29
No known key found for this signature in database
GPG Key ID: E86E9FE9049C741F
2 changed files with 8 additions and 6 deletions

View File

@ -142,11 +142,13 @@ PostSchema.method<HydratedPostDocument>('formatScreenshot', function formatScree
}
});
PostSchema.method<HydratedPostDocument>('formatTopicTag', function formatTopicTag(): PostTopicTag {
return {
name: this.topic_tag,
title_id: this.title_id
};
PostSchema.method<HydratedPostDocument>('formatTopicTag', function formatTopicTag(): PostTopicTag | undefined {
if (this.topic_tag?.trim()) {
return {
name: this.topic_tag,
title_id: this.title_id
};
}
});
PostSchema.method<HydratedPostDocument>('json', function json(options: PostToJSONOptions, community?: HydratedCommunityDocument): PostData {

View File

@ -48,7 +48,7 @@ export interface IPostMethods {
cleanedAppData(): string;
formatPainting(): PostPainting | undefined;
formatScreenshot(): PostScreenshot | undefined;
formatTopicTag(): PostTopicTag;
formatTopicTag(): PostTopicTag | undefined;
json(options: PostToJSONOptions, community?: HydratedCommunityDocument): PostData;
}