@ -47,16 +47,16 @@ module.exports = function (User) {
settings . openOutgoingLinksInNewTab = parseInt ( getSetting ( settings , 'openOutgoingLinksInNewTab' , 0 ) , 10 ) === 1 ;
settings . openOutgoingLinksInNewTab = parseInt ( getSetting ( settings , 'openOutgoingLinksInNewTab' , 0 ) , 10 ) === 1 ;
settings . dailyDigestFreq = getSetting ( settings , 'dailyDigestFreq' , 'off' ) ;
settings . dailyDigestFreq = getSetting ( settings , 'dailyDigestFreq' , 'off' ) ;
settings . usePagination = parseInt ( getSetting ( settings , 'usePagination' , 0 ) , 10 ) === 1 ;
settings . usePagination = parseInt ( getSetting ( settings , 'usePagination' , 0 ) , 10 ) === 1 ;
settings . topicsPerPage =
settings . topicsPerPage = Math . min (
Math . min (
meta . config . maxTopicsPerPage ,
meta . config . max TopicsPerPage,
settings . topicsPerPage ? parseInt ( settings . topicsPerPage , 10 ) : default TopicsPerPage,
Math . min ( settings . topicsPerPage ? parseInt ( settings . topicsPerPage , 10 ) : defaultTopicsPerPage , defaultTopicsPerPage )
defaultTopicsPerPage
) ;
) ;
settings . postsPerPage =
settings . postsPerPage = Math . min (
Math . min (
meta . config . maxPostsPerPage ,
meta . config . max PostsPerPage,
settings . postsPerPage ? parseInt ( settings . postsPerPage , 10 ) : default PostsPerPage,
Math . min ( settings . postsPerPage ? parseInt ( settings . postsPerPage , 10 ) : defaultPostsPerPage , defaultPostsPerPage )
defaultPostsPerPage
) ;
) ;
settings . userLang = settings . userLang || meta . config . defaultLang || 'en-GB' ;
settings . userLang = settings . userLang || meta . config . defaultLang || 'en-GB' ;
settings . acpLang = settings . acpLang || settings . userLang ;
settings . acpLang = settings . acpLang || settings . userLang ;
settings . topicPostSort = getSetting ( settings , 'topicPostSort' , 'oldest_to_newest' ) ;
settings . topicPostSort = getSetting ( settings , 'topicPostSort' , 'oldest_to_newest' ) ;
@ -91,12 +91,20 @@ module.exports = function (User) {
User . saveSettings = async function ( uid , data ) {
User . saveSettings = async function ( uid , data ) {
const maxPostsPerPage = meta . config . maxPostsPerPage || 20 ;
const maxPostsPerPage = meta . config . maxPostsPerPage || 20 ;
if ( ! data . postsPerPage || parseInt ( data . postsPerPage , 10 ) <= 1 || parseInt ( data . postsPerPage , 10 ) > maxPostsPerPage ) {
if (
! data . postsPerPage ||
parseInt ( data . postsPerPage , 10 ) <= 1 ||
parseInt ( data . postsPerPage , 10 ) > maxPostsPerPage
) {
throw new Error ( ` [[error:invalid-pagination-value, 2, ${ maxPostsPerPage } ]] ` ) ;
throw new Error ( ` [[error:invalid-pagination-value, 2, ${ maxPostsPerPage } ]] ` ) ;
}
}
const maxTopicsPerPage = meta . config . maxTopicsPerPage || 20 ;
const maxTopicsPerPage = meta . config . maxTopicsPerPage || 20 ;
if ( ! data . topicsPerPage || parseInt ( data . topicsPerPage , 10 ) <= 1 || parseInt ( data . topicsPerPage , 10 ) > maxTopicsPerPage ) {
if (
! data . topicsPerPage ||
parseInt ( data . topicsPerPage , 10 ) <= 1 ||
parseInt ( data . topicsPerPage , 10 ) > maxTopicsPerPage
) {
throw new Error ( ` [[error:invalid-pagination-value, 2, ${ maxTopicsPerPage } ]] ` ) ;
throw new Error ( ` [[error:invalid-pagination-value, 2, ${ maxTopicsPerPage } ]] ` ) ;
}
}