A modified version of Wafrn used on https://wf.jbc.lol (mirror of https://git.jbc.lol/jbcrn/wf.jbc.lol which is a mirror of https://codeberg.org/jbcarreon123/wf.jbc.lol)

Merge pull request 'Add options to disable replies in all feeds and disable rewoots in dashboard' (#381) from campos02/wafrn:development into development

Reviewed-on: https://codeberg.org/wafrn/wafrn/pulls/381

gabboman d7c78ea6 5fbb0e2c

+115 -25
+86 -23
packages/backend/routes/dashboard.ts
··· 46 46 let whereObject: any = { 47 47 privacy: Privacy.Public 48 48 } 49 + 50 + const dbOptiondisableReplies = await UserOptions.findOne({ 51 + where: { 52 + userId: posterId, 53 + optionName: 'wafrn.disableReplies' 54 + } 55 + }) 56 + 57 + const disableReplies = dbOptiondisableReplies?.optionValue === 'true' 58 + const disableRepliesOr = [ 59 + { 60 + isReblog: true 61 + }, 62 + { 63 + parentId: null 64 + } 65 + ] 66 + 49 67 switch (level) { 50 68 case 2: { 51 69 let hideReblogs = false ··· 61 79 } 62 80 const followedUsers = getFollowedsIds(posterId, true) 63 81 const nonFollowedUsers = getNonFollowedLocalUsersIds(posterId) 64 - whereObject = { 65 - [Op.or]: [ 66 - { 67 - privacy: { 68 - [Op.in]: [Privacy.Public, Privacy.FollowersOnly, Privacy.LocalOnly] 82 + 83 + const and: any = [ 84 + { 85 + [Op.or]: [ 86 + { 87 + privacy: { 88 + [Op.in]: [Privacy.Public, Privacy.FollowersOnly, Privacy.LocalOnly] 89 + }, 90 + userId: { 91 + [Op.in]: await followedUsers 92 + } 69 93 }, 70 - userId: { 71 - [Op.in]: await followedUsers 72 - } 73 - }, 74 - { 75 - privacy: { 76 - [Op.in]: req.jwtData?.userId ? [Privacy.Public, Privacy.LocalOnly] : [Privacy.Public] // only display public if not logged in 94 + { 95 + privacy: { 96 + [Op.in]: req.jwtData?.userId ? [Privacy.Public, Privacy.LocalOnly] : [Privacy.Public] // only display public if not logged in 97 + }, 98 + userId: { 99 + [Op.in]: await nonFollowedUsers 100 + } 77 101 }, 78 - userId: { 79 - [Op.in]: await nonFollowedUsers 102 + { 103 + userId: posterId, 104 + privacy: { 105 + [Op.ne]: Privacy.DirectMessage 106 + } 80 107 } 81 - }, 82 - { 83 - userId: posterId, 84 - privacy: { 85 - [Op.ne]: Privacy.DirectMessage 86 - } 87 - } 88 - ], 108 + ] 109 + } 110 + ] 111 + 112 + if (disableReplies) { 113 + and.push({ 114 + [Op.or]: disableRepliesOr 115 + }) 116 + } 117 + 118 + whereObject = { 119 + [Op.and]: and, 89 120 isReblog: { 90 121 [Op.in]: hideReblogs ? [false, null] : [true, false, null] 91 122 } 92 123 } 124 + 93 125 break 94 126 } 95 127 case 1: { ··· 98 130 userId: { [Op.in]: await getFollowedsIds(posterId) } 99 131 } 100 132 ] 133 + 134 + const dbOptionDisableRewootsDashboard = await UserOptions.findOne({ 135 + where: { 136 + userId: posterId, 137 + optionName: 'wafrn.disableRewootsDashboard' 138 + } 139 + }) 140 + 141 + const hideReblogs = dbOptionDisableRewootsDashboard?.optionValue === 'true' 101 142 const subscribedTags = await getFollowedHashtags(posterId) 143 + 102 144 if (subscribedTags && subscribedTags.length > 0) { 103 145 // query: get posts with hashtag thing 104 146 postsWithTags = PostTag.findAll({ ··· 131 173 order: [['createdAt', 'DESC']] 132 174 }) 133 175 } 176 + 177 + const and: any = [ 178 + { 179 + [Op.or]: orConditions 180 + } 181 + ] 182 + 183 + if (disableReplies) { 184 + and.push({ 185 + [Op.or]: disableRepliesOr 186 + }) 187 + } 188 + 134 189 whereObject = { 135 190 privacy: { [Op.in]: [Privacy.Public, Privacy.FollowersOnly, Privacy.LocalOnly, Privacy.Unlisted] }, 136 - [Op.or]: orConditions 191 + isReblog: { 192 + [Op.in]: hideReblogs ? [false, null] : [true, false, null] 193 + }, 194 + [Op.and]: and 137 195 } 196 + 138 197 break 139 198 } 140 199 case 0: { ··· 153 212 } 154 213 ] 155 214 } 215 + 216 + if (disableReplies) 217 + whereObject.parentId = null 218 + 156 219 break 157 220 } 158 221 case 10: {
+3 -1
packages/frontend/src/app/services/login.service.ts
··· 350 350 hideQuotes: 'wafrn.hideQuotes', 351 351 displayMentionsOfBlockedUsersFromOtherUsers: 'wafrn.displayMentionsOfBlockedUsersFromOtherUsers', 352 352 hideNoDescriptionMedia: 'wafrn.hideNoDescriptionMedia', 353 - disableRewootsExploreLocal: 'wafrn.disableRewootsExploreLocal' 353 + disableRewootsExploreLocal: 'wafrn.disableRewootsExploreLocal', 354 + disableRewootsDashboard: 'wafrn.disableRewootsDashboard', 355 + disableReplies: 'wafrn.disableReplies' 354 356 } 355 357 356 358 try {
+21 -1
packages/frontend/src/app/services/settings.service.ts
··· 84 84 'confettiMultiplier', 85 85 'flatConfetti', 86 86 'disableRewootsExploreLocal', 87 + 'disableRewootsDashboard', 88 + 'disableReplies', 87 89 'confirmOpenCw', 88 90 'confirmOpenCwAnnoyance', 89 91 'disableLinkPreviews' ··· 403 405 type: 'checkbox', 404 406 default: false 405 407 }, 408 + disableRewootsDashboard: { 409 + key: 'disableRewootsDashboard', 410 + translationKey: 'settings.disableRewootsDashboard', 411 + serverKey: 'wafrn.disableRewootsDashboard', 412 + localStorageKey: 'disableRewootsDashboard', 413 + type: 'checkbox', 414 + default: false 415 + }, 416 + disableReplies: { 417 + key: 'disableReplies', 418 + translationKey: 'settings.disableReplies', 419 + serverKey: 'wafrn.disableReplies', 420 + localStorageKey: 'disableReplies', 421 + type: 'checkbox', 422 + default: false 423 + }, 406 424 automaticallyExpandPosts: { 407 425 key: 'automaticallyExpandPosts', 408 426 translationKey: 'settings.automaticallyExpandPosts', ··· 698 716 { type: 'header', value: 'settings.header.dashboardBehavior' }, 699 717 { type: 'key', value: 'defaultDashboard' }, 700 718 { type: 'key', value: 'disableRewootsExploreLocal' }, 719 + { type: 'key', value: 'disableRewootsDashboard' }, 720 + { type: 'key', value: 'disableReplies' }, 701 721 { type: 'key', value: 'automaticallyExpandPosts' }, 702 722 { type: 'key', value: 'expandQuotes' }, 703 723 { type: 'key', value: 'disableLinkPreviews' }, ··· 826 846 try { 827 847 this.fediAttachments.length = 0 828 848 this.fediAttachments.push(...JSON.parse(rawAttachments.optionValue)) 829 - } catch (error) {} 849 + } catch (error) { } 830 850 831 851 if (this.fediAttachments.length === 0) { 832 852 this.fediAttachments.push({ name: '', value: '' })
+3
packages/frontend/src/assets/i18n/br.json
··· 370 370 "instanceOnly": "Somente Local", 371 371 "unlisted": "Não Listado" 372 372 }, 373 + "disableRewootsExploreLocal": "Desabilitar rewoots no feed Explorar Local", 374 + "disableRewootsDashboard": "Desabilitar rewoots na Linha do Tempo", 375 + "disableReplies": "Desabilitar respostas nos feeds", 373 376 "mutedWords": "Palavras silenciadas", 374 377 "mutedWordsDescription": "Uma por linha. Woots com estas frases serão escondidos por trás de um aviso de conteúdo.", 375 378 "superMutedWords": "Palavras bloqueadas",
+2
packages/frontend/src/assets/i18n/en.json
··· 376 376 "unlisted": "Unlisted" 377 377 }, 378 378 "disableRewootsExploreLocal": "Disable rewoots in Explore local feed", 379 + "disableRewootsDashboard": "Disable rewoots in Dashboard", 380 + "disableReplies": "Disable replies in feeds", 379 381 "mutedWords": "Muted words", 380 382 "mutedWordsDescription": "One word per line. Woots with these phrases will be placed behind a CW.", 381 383 "superMutedWords": "Blocked words",