mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-20 20:01:25 +00:00
separated MAX_PINNED_POSTS from MAX_GROUP_PINNED_POSTS variable
This commit is contained in:
parent
1111ccfe94
commit
39264177c0
@ -48,3 +48,4 @@ IMAGOR_SECRET=mysecret
|
||||
|
||||
CATEGORIES_ACTIVE=false
|
||||
MAX_PINNED_POSTS=1
|
||||
MAX_GROUP_PINNED_POSTS=1
|
||||
|
||||
@ -40,3 +40,4 @@ IMAGOR_SECRET=mysecret
|
||||
|
||||
CATEGORIES_ACTIVE=false
|
||||
MAX_PINNED_POSTS=1
|
||||
MAX_GROUP_PINNED_POSTS=1
|
||||
|
||||
@ -138,6 +138,9 @@ const options = {
|
||||
MAX_PINNED_POSTS: Number.isNaN(Number(process.env.MAX_PINNED_POSTS))
|
||||
? 1
|
||||
: Number(process.env.MAX_PINNED_POSTS),
|
||||
MAX_GROUP_PINNED_POSTS: Number.isNaN(Number(process.env.MAX_GROUP_PINNED_POSTS))
|
||||
? 1
|
||||
: Number(process.env.MAX_GROUP_PINNED_POSTS),
|
||||
}
|
||||
|
||||
const language = {
|
||||
|
||||
@ -211,7 +211,7 @@ describe('pin groupPosts', () => {
|
||||
|
||||
describe('MAX_GROUP_PINNED_POSTS is 1', () => {
|
||||
beforeEach(async () => {
|
||||
config = { ...defaultConfig, MAX_PINNED_POSTS: 1 }
|
||||
config = { ...defaultConfig, MAX_GROUP_PINNED_POSTS: 1 }
|
||||
authenticatedUser = await publicUser.toJson()
|
||||
})
|
||||
it('returns post-1-to-public-group as first, pinned post', async () => {
|
||||
@ -297,7 +297,7 @@ describe('pin groupPosts', () => {
|
||||
|
||||
describe('MAX_GROUP_PINNED_POSTS is 2', () => {
|
||||
beforeEach(async () => {
|
||||
config = { ...defaultConfig, MAX_PINNED_POSTS: 2 }
|
||||
config = { ...defaultConfig, MAX_GROUP_PINNED_POSTS: 2 }
|
||||
authenticatedUser = await publicUser.toJson()
|
||||
})
|
||||
it('returns post-1-to-public-group as first, post-2-to-public-group as second pinned post', async () => {
|
||||
|
||||
@ -474,12 +474,12 @@ export default {
|
||||
}
|
||||
const { config } = context
|
||||
|
||||
if (config.MAX_PINNED_POSTS === 0) {
|
||||
if (config.MAX_GROUP_PINNED_POSTS === 0) {
|
||||
throw new Error('Pinned posts are not allowed!')
|
||||
}
|
||||
|
||||
// If MAX_PINNED_POSTS === 1 -> Delete old pin
|
||||
if (config.MAX_PINNED_POSTS === 1) {
|
||||
// If MAX_GROUP_PINNED_POSTS === 1 -> Delete old pin
|
||||
if (config.MAX_GROUP_PINNED_POSTS === 1) {
|
||||
await context.database.write({
|
||||
query: `
|
||||
MATCH (post:Post {id: $params.id})-[:IN]->(group:Group)
|
||||
@ -488,7 +488,7 @@ export default {
|
||||
DELETE pinned`,
|
||||
variables: { user: context.user, params },
|
||||
})
|
||||
// If MAX_PINNED_POSTS !== 1 -> Check if max is reached
|
||||
// If MAX_GROUP_PINNED_POSTS !== 1 -> Check if max is reached
|
||||
} else {
|
||||
const result = await context.database.query({
|
||||
query: `
|
||||
@ -497,7 +497,7 @@ export default {
|
||||
RETURN toString(count(pinnedPosts)) as count`,
|
||||
variables: { user: context.user, params },
|
||||
})
|
||||
if (result.records[0].get('count') >= config.MAX_PINNED_POSTS) {
|
||||
if (result.records[0].get('count') >= config.MAX_GROUP_PINNED_POSTS) {
|
||||
throw new Error('Reached maxed pinned posts already. Unpin a post first.')
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,6 +57,7 @@ export const TEST_CONFIG = {
|
||||
INVITE_CODES_GROUP_PER_USER: 7,
|
||||
CATEGORIES_ACTIVE: false,
|
||||
MAX_PINNED_POSTS: 1,
|
||||
MAX_GROUP_PINNED_POSTS: 1,
|
||||
|
||||
LANGUAGE_DEFAULT: 'en',
|
||||
LOG_LEVEL: 'DEBUG',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user