mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-27 17:16:14 +01:00 
			
		
		
		
	
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							55d5cccf2e
						
					
				
				
					commit
					e60357d20d
				
			| @@ -29,6 +29,8 @@ | |||||||
| 	"reset.notify.text2": "If you did not authorise this, please notify an administrator immediately.", | 	"reset.notify.text2": "If you did not authorise this, please notify an administrator immediately.", | ||||||
|  |  | ||||||
| 	"digest.latest_topics": "Latest topics from %1", | 	"digest.latest_topics": "Latest topics from %1", | ||||||
|  | 	"digest.top-topics": "Top topics from %1", | ||||||
|  | 	"digest.popular-topics": "Popular topics from %1", | ||||||
| 	"digest.cta": "Click here to visit %1", | 	"digest.cta": "Click here to visit %1", | ||||||
| 	"digest.unsub.info": "This digest was sent to you due to your subscription settings.", | 	"digest.unsub.info": "This digest was sent to you due to your subscription settings.", | ||||||
| 	"digest.day": "day", | 	"digest.day": "day", | ||||||
|   | |||||||
| @@ -102,17 +102,19 @@ Digest.send = async function (data) { | |||||||
|  |  | ||||||
| 	await async.eachLimit(data.subscribers, 100, async function (uid) { | 	await async.eachLimit(data.subscribers, 100, async function (uid) { | ||||||
| 		const userObj = await user.getUserFields(uid, ['uid', 'username', 'userslug', 'lastonline']); | 		const userObj = await user.getUserFields(uid, ['uid', 'username', 'userslug', 'lastonline']); | ||||||
| 		let [notifications, topicsData] = await Promise.all([ | 		const [notifications, topTopics, popularTopics, recentTopics] = await Promise.all([ | ||||||
| 			user.notifications.getUnreadInterval(userObj.uid, data.interval), | 			user.notifications.getUnreadInterval(userObj.uid, data.interval), | ||||||
| 			getTermTopics(data.interval, userObj.uid, 0, 9), | 			getTermTopics(data.interval, userObj.uid, 0, 9, 'votes'), | ||||||
|  | 			getTermTopics(data.interval, userObj.uid, 0, 9, 'posts'), | ||||||
|  | 			getTermTopics(data.interval, userObj.uid, 0, 9, 'recent'), | ||||||
| 		]); | 		]); | ||||||
| 		notifications = notifications.filter(Boolean); | 		const unreadNotifs = notifications.filter(Boolean); | ||||||
| 		// If there are no notifications and no new topics, don't bother sending a digest | 		// If there are no notifications and no new topics, don't bother sending a digest | ||||||
| 		if (!notifications.length && !topicsData.length) { | 		if (!unreadNotifs.length && !topTopics.length && !popularTopics.length && !recentTopics.length) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		notifications.forEach(function (n) { | 		unreadNotifs.forEach(function (n) { | ||||||
| 			if (n.image && !n.image.startsWith('http')) { | 			if (n.image && !n.image.startsWith('http')) { | ||||||
| 				n.image = nconf.get('base_url') + n.image; | 				n.image = nconf.get('base_url') + n.image; | ||||||
| 			} | 			} | ||||||
| @@ -121,14 +123,6 @@ Digest.send = async function (data) { | |||||||
| 			} | 			} | ||||||
| 		}); | 		}); | ||||||
|  |  | ||||||
| 		// Fix relative paths in topic data |  | ||||||
| 		topicsData = topicsData.map(function (topicObj) { |  | ||||||
| 			const user = topicObj.hasOwnProperty('teaser') && topicObj.teaser && topicObj.teaser.user ? topicObj.teaser.user : topicObj.user; |  | ||||||
| 			if (user && user.picture && utils.isRelativeUrl(user.picture)) { |  | ||||||
| 				user.picture = nconf.get('base_url') + user.picture; |  | ||||||
| 			} |  | ||||||
| 			return topicObj; |  | ||||||
| 		}); |  | ||||||
| 		emailsSent += 1; | 		emailsSent += 1; | ||||||
| 		const now = new Date(); | 		const now = new Date(); | ||||||
| 		try { | 		try { | ||||||
| @@ -136,8 +130,10 @@ Digest.send = async function (data) { | |||||||
| 				subject: '[[email:digest.subject, ' + (now.getFullYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate()) + ']]', | 				subject: '[[email:digest.subject, ' + (now.getFullYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate()) + ']]', | ||||||
| 				username: userObj.username, | 				username: userObj.username, | ||||||
| 				userslug: userObj.userslug, | 				userslug: userObj.userslug, | ||||||
| 				notifications: notifications, | 				notifications: unreadNotifs, | ||||||
| 				recent: topicsData, | 				recent: recentTopics, | ||||||
|  | 				topTopics: topTopics, | ||||||
|  | 				popularTopics: popularTopics, | ||||||
| 				interval: data.interval, | 				interval: data.interval, | ||||||
| 				showUnsubscribe: true, | 				showUnsubscribe: true, | ||||||
| 			}); | 			}); | ||||||
| @@ -179,22 +175,30 @@ Digest.getDeliveryTimes = async (start, stop) => { | |||||||
| 	}; | 	}; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| async function getTermTopics(term, uid, start, stop) { | async function getTermTopics(term, uid, start, stop, sort) { | ||||||
| 	const options = { | 	const options = { | ||||||
| 		uid: uid, | 		uid: uid, | ||||||
| 		start: start, | 		start: start, | ||||||
| 		stop: stop, | 		stop: stop, | ||||||
| 		term: term, | 		term: term, | ||||||
| 		sort: 'posts', | 		sort: sort, | ||||||
| 		teaserPost: 'last-post', | 		teaserPost: 'last-post', | ||||||
| 	}; | 	}; | ||||||
| 	let data = await topics.getSortedTopics(options); | 	const data = sort === 'recent' ? | ||||||
| 	if (!data.topics.length) { | 		await topics.getLatestTopics(options) : | ||||||
| 		data = await topics.getLatestTopics(options); | 		await topics.getSortedTopics(options); | ||||||
| 	} |  | ||||||
| 	data.topics.forEach(function (topicObj) { | 	data.topics.forEach(function (topicObj) { | ||||||
| 		if (topicObj && topicObj.teaser && topicObj.teaser.content && topicObj.teaser.content.length > 255) { | 		if (topicObj) { | ||||||
| 			topicObj.teaser.content = topicObj.teaser.content.slice(0, 255) + '...'; | 			if (topicObj.teaser && topicObj.teaser.content && topicObj.teaser.content.length > 255) { | ||||||
|  | 				topicObj.teaser.content = topicObj.teaser.content.slice(0, 255) + '...'; | ||||||
|  | 			} | ||||||
|  | 			// Fix relative paths in topic data | ||||||
|  | 			const user = topicObj.hasOwnProperty('teaser') && topicObj.teaser && topicObj.teaser.user ? | ||||||
|  | 				topicObj.teaser.user : topicObj.user; | ||||||
|  | 			if (user && user.picture && utils.isRelativeUrl(user.picture)) { | ||||||
|  | 				user.picture = nconf.get('base_url') + user.picture; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 	}); | 	}); | ||||||
| 	return data.topics.filter(topic => topic && !topic.deleted); | 	return data.topics.filter(topic => topic && !topic.deleted); | ||||||
|   | |||||||
| @@ -43,6 +43,76 @@ | |||||||
| 					</td> | 					</td> | ||||||
| 				</tr> | 				</tr> | ||||||
| 				<!-- ENDIF notifications.length --> | 				<!-- ENDIF notifications.length --> | ||||||
|  | 				<!-- IF topTopics.length --> | ||||||
|  | 				<tr> | ||||||
|  | 					<td style="padding: 0px 40px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 15px; line-height: 20px; color: #555555;"> | ||||||
|  | 						<h1 style="margin: 16px 0 24px 0; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 18px; line-height: 21px; color: #aaaaaa; font-weight: normal;">[[email:digest.top-topics, {site_title}]]</h1> | ||||||
|  | 						<ul style="margin: 0; padding: 0;"> | ||||||
|  | 							<!-- BEGIN topTopics --> | ||||||
|  | 							<li style="text-decoration: none; list-style-type: none; padding-bottom: 0.5em;"> | ||||||
|  | 								<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"> | ||||||
|  | 									<tr> | ||||||
|  | 										<td style="padding: 6px 16px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; width: 32px; vertical-align: middle;">{function.renderDigestAvatar}</td> | ||||||
|  | 										<td style="padding: 6px 16px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; line-height: 16px; color: #333333;"> | ||||||
|  | 											<p style="margin: 0;"><a style="text-decoration:none !important; text-decoration:none; color: #333333;" href="{url}/topic/{topTopics.slug}"><strong>{topTopics.title}</strong></a></p> | ||||||
|  | 											<p style="margin: 0; font-size: 12px;"><a style="text-decoration:none !important; text-decoration:none; color: #aaaaaa; line-height: 16px;" href="{url}/uid/{topTopics.teaser.user.uid}"><strong>{topTopics.teaser.user.username}</strong></a></p> | ||||||
|  | 										</td> | ||||||
|  | 									</tr> | ||||||
|  | 									<tr> | ||||||
|  | 										<td colspan="2" style="padding: 8px 16px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; line-height: 16px; color: #333333;"> | ||||||
|  | 											<p style="margin: 0; padding: 6px 0px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 13px; line-height: 26px; color: #666666;">{topTopics.teaser.content}</p> | ||||||
|  | 											<p style="margin: 0; padding: 6px 0px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; line-height: 16px;"> | ||||||
|  | 												<a style="text-decoration:none !important; text-decoration:none; text-transform: capitalize; color: #666666; line-height: 16px;" href="{url}/topic/{recent.slug}"> | ||||||
|  | 													<small><strong><span style="color: #aaaaaa;">›</span> [[global:read_more]]</strong></small> | ||||||
|  | 												</a> | ||||||
|  | 											</p> | ||||||
|  | 										</td> | ||||||
|  | 									</tr> | ||||||
|  | 								</table> | ||||||
|  | 							</li> | ||||||
|  | 							<!-- IF !@last --> | ||||||
|  | 							<li style="text-decoration: none; list-style-type: none; margin: 0px 64px 16px 64px; border-bottom: 1px solid #dddddd"></li> | ||||||
|  | 							<!-- END --> | ||||||
|  | 							<!-- END --> | ||||||
|  | 						</ul> | ||||||
|  | 					</td> | ||||||
|  | 				</tr> | ||||||
|  | 				<!-- END --> | ||||||
|  | 				<!-- IF popularTopics.length --> | ||||||
|  | 				<tr> | ||||||
|  | 					<td style="padding: 0px 40px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 15px; line-height: 20px; color: #555555;"> | ||||||
|  | 						<h1 style="margin: 16px 0 24px 0; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 18px; line-height: 21px; color: #aaaaaa; font-weight: normal;">[[email:digest.popular-topics, {site_title}]]</h1> | ||||||
|  | 						<ul style="margin: 0; padding: 0;"> | ||||||
|  | 							<!-- BEGIN popularTopics --> | ||||||
|  | 							<li style="text-decoration: none; list-style-type: none; padding-bottom: 0.5em;"> | ||||||
|  | 								<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"> | ||||||
|  | 									<tr> | ||||||
|  | 										<td style="padding: 6px 16px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; width: 32px; vertical-align: middle;">{function.renderDigestAvatar}</td> | ||||||
|  | 										<td style="padding: 6px 16px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; line-height: 16px; color: #333333;"> | ||||||
|  | 											<p style="margin: 0;"><a style="text-decoration:none !important; text-decoration:none; color: #333333;" href="{url}/topic/{popularTopics.slug}"><strong>{popularTopics.title}</strong></a></p> | ||||||
|  | 											<p style="margin: 0; font-size: 12px;"><a style="text-decoration:none !important; text-decoration:none; color: #aaaaaa; line-height: 16px;" href="{url}/uid/{popularTopics.teaser.user.uid}"><strong>{popularTopics.teaser.user.username}</strong></a></p> | ||||||
|  | 										</td> | ||||||
|  | 									</tr> | ||||||
|  | 									<tr> | ||||||
|  | 										<td colspan="2" style="padding: 8px 16px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; line-height: 16px; color: #333333;"> | ||||||
|  | 											<p style="margin: 0; padding: 6px 0px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 13px; line-height: 26px; color: #666666;">{popularTopics.teaser.content}</p> | ||||||
|  | 											<p style="margin: 0; padding: 6px 0px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; line-height: 16px;"> | ||||||
|  | 												<a style="text-decoration:none !important; text-decoration:none; text-transform: capitalize; color: #666666; line-height: 16px;" href="{url}/topic/{recent.slug}"> | ||||||
|  | 													<small><strong><span style="color: #aaaaaa;">›</span> [[global:read_more]]</strong></small> | ||||||
|  | 												</a> | ||||||
|  | 											</p> | ||||||
|  | 										</td> | ||||||
|  | 									</tr> | ||||||
|  | 								</table> | ||||||
|  | 							</li> | ||||||
|  | 							<!-- IF !@last --> | ||||||
|  | 							<li style="text-decoration: none; list-style-type: none; margin: 0px 64px 16px 64px; border-bottom: 1px solid #dddddd"></li> | ||||||
|  | 							<!-- END --> | ||||||
|  | 							<!-- END --> | ||||||
|  | 						</ul> | ||||||
|  | 					</td> | ||||||
|  | 				</tr> | ||||||
|  | 				<!-- END --> | ||||||
| 				<!-- IF recent.length --> | 				<!-- IF recent.length --> | ||||||
| 				<tr> | 				<tr> | ||||||
| 					<td style="padding: 0px 40px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 15px; line-height: 20px; color: #555555;"> | 					<td style="padding: 0px 40px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 15px; line-height: 20px; color: #555555;"> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user