reflect paid content status
This commit is contained in:
parent
a37993c80e
commit
fc2821f78c
1 changed files with 25 additions and 2 deletions
|
|
@ -1293,9 +1293,10 @@ const setLastSeenApp = () =>
|
||||||
* @param {string[]} tags
|
* @param {string[]} tags
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {Common.Schema.ContentItem[]} content
|
* @param {Common.Schema.ContentItem[]} content
|
||||||
|
* @param {ISEA} SEA
|
||||||
* @returns {Promise<[string, Common.Schema.RawPost]>}
|
* @returns {Promise<[string, Common.Schema.RawPost]>}
|
||||||
*/
|
*/
|
||||||
const createPostNew = async (tags, title, content) => {
|
const createPostNew = async (tags, title, content, SEA) => {
|
||||||
/** @type {Common.Schema.RawPost} */
|
/** @type {Common.Schema.RawPost} */
|
||||||
const newPost = {
|
const newPost = {
|
||||||
date: Date.now(),
|
date: Date.now(),
|
||||||
|
|
@ -1311,6 +1312,23 @@ const createPostNew = async (tags, title, content) => {
|
||||||
newPost.contentItems[uuid] = c
|
newPost.contentItems[uuid] = c
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const mySecret = require('../Mediator').getMySecret()
|
||||||
|
|
||||||
|
await Common.Utils.asyncForEach(content, async c => {
|
||||||
|
// @ts-expect-error
|
||||||
|
const uuid = Gun.text.random()
|
||||||
|
newPost.contentItems[uuid] = c
|
||||||
|
if (
|
||||||
|
(c.type === 'image/embedded' || c.type === 'video/embedded') &&
|
||||||
|
c.isPrivate
|
||||||
|
) {
|
||||||
|
const encryptedMagnet = await SEA.encrypt(c.magnetURI, mySecret)
|
||||||
|
newPost.contentItems[uuid] = { ...c, magnetURI: encryptedMagnet }
|
||||||
|
} else {
|
||||||
|
newPost.contentItems[uuid] = c
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
const postID = await Common.makePromise((res, rej) => {
|
const postID = await Common.makePromise((res, rej) => {
|
||||||
const _n = require('../Mediator')
|
const _n = require('../Mediator')
|
||||||
|
|
@ -1415,7 +1433,12 @@ const createPost = async (tags, title, content) => {
|
||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const [postID, newPost] = await createPostNew(tags, title, content)
|
const [postID, newPost] = await createPostNew(
|
||||||
|
tags,
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
require('../Mediator').mySEA
|
||||||
|
)
|
||||||
|
|
||||||
await Common.makePromise((res, rej) => {
|
await Common.makePromise((res, rej) => {
|
||||||
require('../Mediator')
|
require('../Mediator')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue