Merge commit '28966fa0a6d7b98ee94696acdc79e45449ce8349' into glitch-soc/merge-upstream

This commit is contained in:
Claire committed 2024-09-25 17:41:37 +02:00
commit 633165ba9c
39 files changed
+350 -625

No files matched your search

@@ -31,7 +31,7 @@ module WebAppControllerConcern
def redirect_unauthenticated_to_permalinks!
return if user_signed_in? # NOTE: Different from upstream because we allow moved users to log in
permalink_redirector = PermalinkRedirector.new(request.path)
permalink_redirector = PermalinkRedirector.new(request.original_fullpath)
return if permalink_redirector.redirect_path.blank?
expires_in(15.seconds, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.day) unless user_signed_in?
@@ -68,10 +68,15 @@ function dispatchAssociatedRecords(
dispatch(importFetchedStatuses(fetchedStatuses));
}
const supportedGroupedNotificationTypes = ['favourite', 'reblog'];
export const fetchNotifications = createDataLoadingThunk(
'notificationGroups/fetch',
async (_params, { getState }) =>
apiFetchNotificationGroups({ exclude_types: getExcludedTypes(getState()) }),
apiFetchNotificationGroups({
grouped_types: supportedGroupedNotificationTypes,
exclude_types: getExcludedTypes(getState()),
}),
({ notifications, accounts, statuses }, { dispatch }) => {
dispatch(importFetchedAccounts(accounts));
dispatch(importFetchedStatuses(statuses));
@@ -93,6 +98,7 @@ export const fetchNotificationsGap = createDataLoadingThunk(
'notificationGroups/fetchGap',
async (params: { gap: NotificationGap }, { getState }) =>
apiFetchNotificationGroups({
grouped_types: supportedGroupedNotificationTypes,
max_id: params.gap.maxId,
exclude_types: getExcludedTypes(getState()),
}),
@@ -109,6 +115,7 @@ export const pollRecentNotifications = createDataLoadingThunk(
'notificationGroups/pollRecentNotifications',
async (_params, { getState }) => {
return apiFetchNotificationGroups({
grouped_types: supportedGroupedNotificationTypes,
max_id: undefined,
exclude_types: getExcludedTypes(getState()),
// In slow mode, we don't want to include notifications that duplicate the already-displayed ones
@@ -31,6 +31,7 @@ export const apiFetchNotifications = async (
export const apiFetchNotificationGroups = async (params?: {
url?: string;
grouped_types?: string[];
exclude_types?: string[];
max_id?: string;
since_id?: string;
@@ -375,20 +375,29 @@ class StatusActionBar extends ImmutablePureComponent {
return (
<div className='status__action-bar'>
<IconButton className='status__action-bar__button' title={replyTitle} icon={isReply ? 'reply' : replyIcon} iconComponent={isReply ? ReplyIcon : replyIconComponent} onClick={this.handleReplyClick} counter={status.get('replies_count')} />
<IconButton className={classNames('status__action-bar__button', { reblogPrivate })} disabled={!publicStatus && !reblogPrivate} active={status.get('reblogged')} title={reblogTitle} icon='retweet' iconComponent={reblogIconComponent} onClick={this.handleReblogClick} counter={withCounters ? status.get('reblogs_count') : undefined} />
<IconButton className='status__action-bar__button star-icon' animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' iconComponent={status.get('favourited') ? StarIcon : StarBorderIcon} onClick={this.handleFavouriteClick} counter={withCounters ? status.get('favourites_count') : undefined} />
<IconButton className='status__action-bar__button bookmark-icon' disabled={!signedIn} active={status.get('bookmarked')} title={intl.formatMessage(messages.bookmark)} icon='bookmark' iconComponent={status.get('bookmarked') ? BookmarkIcon : BookmarkBorderIcon} onClick={this.handleBookmarkClick} />
<DropdownMenuContainer
scrollKey={scrollKey}
status={status}
items={menu}
icon='ellipsis-h'
iconComponent={MoreHorizIcon}
direction='right'
title={intl.formatMessage(messages.more)}
/>
<div className='status__action-bar__button-wrapper'>
<IconButton className='status__action-bar__button' title={replyTitle} icon={isReply ? 'reply' : replyIcon} iconComponent={isReply ? ReplyIcon : replyIconComponent} onClick={this.handleReplyClick} counter={status.get('replies_count')} />
</div>
<div className='status__action-bar__button-wrapper'>
<IconButton className={classNames('status__action-bar__button', { reblogPrivate })} disabled={!publicStatus && !reblogPrivate} active={status.get('reblogged')} title={reblogTitle} icon='retweet' iconComponent={reblogIconComponent} onClick={this.handleReblogClick} counter={withCounters ? status.get('reblogs_count') : undefined} />
</div>
<div className='status__action-bar__button-wrapper'>
<IconButton className='status__action-bar__button star-icon' animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' iconComponent={status.get('favourited') ? StarIcon : StarBorderIcon} onClick={this.handleFavouriteClick} counter={withCounters ? status.get('favourites_count') : undefined} />
</div>
<div className='status__action-bar__button-wrapper'>
<IconButton className='status__action-bar__button bookmark-icon' disabled={!signedIn} active={status.get('bookmarked')} title={intl.formatMessage(messages.bookmark)} icon='bookmark' iconComponent={status.get('bookmarked') ? BookmarkIcon : BookmarkBorderIcon} onClick={this.handleBookmarkClick} />
</div>
<div className='status__action-bar__button-wrapper'>
<DropdownMenuContainer
scrollKey={scrollKey}
status={status}
items={menu}
icon='ellipsis-h'
iconComponent={MoreHorizIcon}
direction='right'
title={intl.formatMessage(messages.more)}
/>
</div>
</div>
);
}
@@ -186,7 +186,7 @@ class SwitchingColumnsArea extends PureComponent {
{redirect}
{singleColumn ? <Redirect from='/deck' to='/home' exact /> : null}
{singleColumn && pathName.startsWith('/deck/') ? <Redirect from={pathName} to={pathName.slice(5)} /> : null}
{singleColumn && pathName.startsWith('/deck/') ? <Redirect from={pathName} to={{...this.props.location, pathname: pathName.slice(5)}} /> : null}
{/* Redirect old bookmarks (without /deck) with home-like routes to the advanced interface */}
{!singleColumn && pathName === '/getting-started' ? <Redirect from='/getting-started' to='/deck/getting-started' exact /> : null}
{!singleColumn && pathName === '/home' ? <Redirect from='/home' to='/deck/getting-started' exact /> : null}
+1 -1
View File
@@ -164,7 +164,7 @@
"compose_form.publish": "Publier",
"compose_form.publish_form": "Publier",
"compose_form.reply": "Répondre",
"compose_form.save_changes": "Mis à jour",
"compose_form.save_changes": "Mettre à jour",
"compose_form.spoiler.marked": "Enlever l'avertissement de contenu",
"compose_form.spoiler.unmarked": "Ajouter un avertissement de contenu",
"compose_form.spoiler_placeholder": "Avertissement de contenu (optionnel)",
+1 -1
View File
@@ -164,7 +164,7 @@
"compose_form.publish": "Publier",
"compose_form.publish_form": "Nouvelle publication",
"compose_form.reply": "Répondre",
"compose_form.save_changes": "Mis à jour",
"compose_form.save_changes": "Mettre à jour",
"compose_form.spoiler.marked": "Enlever l’avertissement de contenu",
"compose_form.spoiler.unmarked": "Ajouter un avertissement de contenu",
"compose_form.spoiler_placeholder": "Avertissement de contenu (optionnel)",
+14 -14
View File
@@ -76,7 +76,7 @@
"admin.dashboard.monthly_retention": "Tỉ lệ người dùng ở lại sau khi đăng ký",
"admin.dashboard.retention.average": "Trung bình",
"admin.dashboard.retention.cohort": "Tháng đăng ký",
"admin.dashboard.retention.cohort_size": "Người mới",
"admin.dashboard.retention.cohort_size": "Số người",
"admin.impact_report.instance_accounts": "Hồ sơ tài khoản này sẽ xóa",
"admin.impact_report.instance_followers": "Người theo dõi của thành viên máy chủ sẽ mất",
"admin.impact_report.instance_follows": "Người theo dõi người dùng của họ sẽ mất",
@@ -154,7 +154,7 @@
"compose_form.lock_disclaimer": "Tài khoản của bạn không {locked}. Bất cứ ai cũng có thể theo dõi và xem tút riêng tư của bạn.",
"compose_form.lock_disclaimer.lock": "khóa",
"compose_form.placeholder": "Bạn đang nghĩ gì?",
"compose_form.poll.duration": "Hết hạn",
"compose_form.poll.duration": "Hết hạn sau",
"compose_form.poll.multiple": "Chọn nhiều",
"compose_form.poll.option_placeholder": "Lựa chọn {number}",
"compose_form.poll.single": "Chọn một",
@@ -180,7 +180,7 @@
"confirmations.discard_edit_media.message": "Bạn chưa lưu thay đổi đối với phần mô tả hoặc bản xem trước của media, vẫn bỏ luôn?",
"confirmations.edit.confirm": "Sửa",
"confirmations.edit.message": "Nội dung tút cũ sẽ bị ghi đè, bạn có tiếp tục?",
"confirmations.edit.title": "Viết đè lên tút cũ",
"confirmations.edit.title": "Ghi đè lên tút cũ",
"confirmations.logout.confirm": "Đăng xuất",
"confirmations.logout.message": "Bạn có chắc muốn thoát?",
"confirmations.logout.title": "Đăng xuất",
@@ -190,11 +190,11 @@
"confirmations.redraft.title": "Xóa & viết lại",
"confirmations.reply.confirm": "Trả lời",
"confirmations.reply.message": "Nội dung bạn đang soạn thảo sẽ bị ghi đè, bạn có tiếp tục?",
"confirmations.reply.title": "Viết đè lên tút cũ",
"confirmations.reply.title": "Ghi đè lên tút cũ",
"confirmations.unfollow.confirm": "Bỏ theo dõi",
"confirmations.unfollow.message": "Bạn có chắc muốn bỏ theo dõi {name}?",
"confirmations.unfollow.title": "Bỏ theo dõi",
"content_warning.hide": "Ẩn tút",
"content_warning.hide": "Ẩn lại",
"content_warning.show": "Nhấn để xem",
"conversation.delete": "Xóa tin nhắn này",
"conversation.mark_as_read": "Đánh dấu là đã đọc",
@@ -322,7 +322,7 @@
"follow_suggestions.hints.most_interactions": "Người này đang thu hút sự chú ý trên {domain}.",
"follow_suggestions.hints.similar_to_recently_followed": "Người này có nét giống những người mà bạn theo dõi gần đây.",
"follow_suggestions.personalized_suggestion": "Gợi ý cá nhân hóa",
"follow_suggestions.popular_suggestion": "Những người nổi tiếng",
"follow_suggestions.popular_suggestion": "Người nổi tiếng",
"follow_suggestions.popular_suggestion_longer": "Nổi tiếng trên {domain}",
"follow_suggestions.similar_to_recently_followed_longer": "Tương tự những người mà bạn theo dõi gần đây",
"follow_suggestions.view_all": "Xem tất cả",
@@ -480,7 +480,7 @@
"navigation_bar.domain_blocks": "Máy chủ đã ẩn",
"navigation_bar.explore": "Xu hướng",
"navigation_bar.favourites": "Tút thích",
"navigation_bar.filters": "Bộ lọc từ ngữ",
"navigation_bar.filters": "Từ khóa đã lọc",
"navigation_bar.follow_requests": "Yêu cầu theo dõi",
"navigation_bar.followed_tags": "Hashtag theo dõi",
"navigation_bar.follows_and_followers": "Quan hệ",
@@ -555,7 +555,7 @@
"notification_requests.view": "Hiện thông báo",
"notifications.clear": "Xóa hết thông báo",
"notifications.clear_confirmation": "Bạn có chắc muốn xóa vĩnh viễn tất cả thông báo của mình?",
"notifications.clear_title": "Xóa hết thông báo?",
"notifications.clear_title": "Xóa toàn bộ thông báo",
"notifications.column_settings.admin.report": "Báo cáo mới:",
"notifications.column_settings.admin.sign_up": "Người mới tham gia:",
"notifications.column_settings.alert": "Báo trên máy tính",
@@ -601,8 +601,8 @@
"notifications.policy.filter_not_followers_title": "Những người không theo dõi bạn",
"notifications.policy.filter_not_following_hint": "Cho tới khi bạn duyệt họ",
"notifications.policy.filter_not_following_title": "Những người bạn không theo dõi",
"notifications.policy.filter_private_mentions_hint": "Được lọc trừ khi nó trả lời lượt nhắc từ bạn hoặc nếu bạn theo dõi người gửi",
"notifications.policy.filter_private_mentions_title": "Lượt nhắc riêng tư không được yêu cầu",
"notifications.policy.filter_private_mentions_hint": "Trừ khi nó trả lời lượt nhắc từ bạn hoặc nếu bạn có theo dõi người gửi",
"notifications.policy.filter_private_mentions_title": "Lượt nhắn riêng không mong muốn",
"notifications.policy.title": "Quản lý thông báo từ…",
"notifications_permission_banner.enable": "Cho phép thông báo trên màn hình",
"notifications_permission_banner.how_to_control": "Hãy bật thông báo trên màn hình để không bỏ lỡ những thông báo từ Mastodon. Một khi đã bật, bạn có thể lựa chọn từng loại thông báo khác nhau thông qua {icon} nút bên dưới.",
@@ -713,7 +713,7 @@
"report.reasons.other": "Một lý do khác",
"report.reasons.other_description": "Vấn đề không nằm trong những mục trên",
"report.reasons.spam": "Đây là spam",
"report.reasons.spam_description": "Liên kết độc hại, tạo tương tác giả hoặc trả lời lặp đi lặp lại",
"report.reasons.spam_description": "Liên kết độc hại, giả tương tác hoặc trả lời lặp đi lặp lại",
"report.reasons.violation": "Vi phạm nội quy máy chủ",
"report.reasons.violation_description": "Bạn nhận thấy nó vi phạm nội quy máy chủ",
"report.rules.subtitle": "Chọn tất cả những gì phù hợp",
@@ -787,9 +787,9 @@
"status.edit": "Sửa",
"status.edited": "Sửa lần cuối {date}",
"status.edited_x_times": "Đã sửa {count, plural, other {{count} lần}}",
"status.embed": "Lấy mã nhúng",
"status.embed": "Nhúng",
"status.favourite": "Thích",
"status.favourites": "{count, plural, other {Thích}}",
"status.favourites": "{count, plural, other {thích}}",
"status.filter": "Lọc tút này",
"status.history.created": "{name} đăng {date}",
"status.history.edited": "{name} đã sửa {date}",
@@ -808,7 +808,7 @@
"status.reblog": "Đăng lại",
"status.reblog_private": "Đăng lại (Riêng tư)",
"status.reblogged_by": "{name} đăng lại",
"status.reblogs": "{count, plural, other {Đăng lại}}",
"status.reblogs": "{count, plural, other {đăng lại}}",
"status.reblogs.empty": "Tút này chưa có ai đăng lại. Nếu có, nó sẽ hiển thị ở đây.",
"status.redraft": "Xóa và viết lại",
"status.remove_bookmark": "Bỏ lưu",
+14 -1
View File
@@ -93,7 +93,7 @@
&:disabled,
&.disabled {
background-color: $ui-primary-color;
cursor: default;
cursor: not-allowed;
}
&.copyable {
@@ -299,6 +299,10 @@
}
}
&--with-counter {
padding-inline-end: 4px;
}
&__counter {
display: block;
width: auto;
@@ -1465,6 +1469,15 @@ body > [data-popper-placement] {
}
}
&__action-bar__button-wrapper {
flex-basis: 0;
flex-grow: 1;
&:last-child {
flex-grow: 0;
}
}
&--first-in-thread {
border-top: 1px solid var(--background-border-color);
}
+1 -1
View File
@@ -83,6 +83,6 @@ class PermalinkRedirector
end
def path_segments
@path_segments ||= @path.delete_prefix('/deck').delete_prefix('/').split('/')
@path_segments ||= @path.split('?')[0].delete_prefix('/deck').delete_prefix('/').split('/')
end
end
+9 -7
View File
@@ -13,12 +13,14 @@ class NotificationMailer < ApplicationMailer
before_action :set_account, only: [:follow, :favourite, :reblog, :follow_request]
after_action :set_list_headers!
before_deliver :verify_functional_user
default to: -> { email_address_with_name(@user.email, @me.username) }
layout 'mailer'
def mention
return unless @user.functional? && @status.present?
return if @status.blank?
locale_for_account(@me) do
mail subject: default_i18n_subject(name: @status.account.acct)
@@ -26,15 +28,13 @@ class NotificationMailer < ApplicationMailer
end
def follow
return unless @user.functional?
locale_for_account(@me) do
mail subject: default_i18n_subject(name: @account.acct)
end
end
def favourite
return unless @user.functional? && @status.present?
return if @status.blank?
locale_for_account(@me) do
mail subject: default_i18n_subject(name: @account.acct)
@@ -42,7 +42,7 @@ class NotificationMailer < ApplicationMailer
end
def reblog
return unless @user.functional? && @status.present?
return if @status.blank?
locale_for_account(@me) do
mail subject: default_i18n_subject(name: @account.acct)
@@ -50,8 +50,6 @@ class NotificationMailer < ApplicationMailer
end
def follow_request
return unless @user.functional?
locale_for_account(@me) do
mail subject: default_i18n_subject(name: @account.acct)
end
@@ -75,6 +73,10 @@ class NotificationMailer < ApplicationMailer
@account = @notification.from_account
end
def verify_functional_user
throw(:abort) unless @user.functional?
end
def set_list_headers!
headers(
'List-ID' => "<#{@type}.#{@me.username}.#{Rails.configuration.x.local_domain}>",
+28 -1
View File
@@ -20,6 +20,7 @@ class Notification < ApplicationRecord
self.inheritance_column = nil
include Paginable
include Redisable
LEGACY_TYPE_CLASS_MAP = {
'Mention' => :mention,
@@ -30,7 +31,9 @@ class Notification < ApplicationRecord
'Poll' => :poll,
}.freeze
GROUPABLE_NOTIFICATION_TYPES = %i(favourite reblog).freeze
# `set_group_key!` needs to be updated if this list changes
GROUPABLE_NOTIFICATION_TYPES = %i(favourite reblog follow).freeze
MAXIMUM_GROUP_SPAN_HOURS = 12
# Please update app/javascript/api_types/notification.ts if you change this
PROPERTIES = {
@@ -123,6 +126,30 @@ class Notification < ApplicationRecord
end
end
def set_group_key!
return if filtered? || Notification::GROUPABLE_NOTIFICATION_TYPES.exclude?(type)
type_prefix = case type
when :favourite, :reblog
[type, target_status&.id].join('-')
when :follow
type
else
raise NotImplementedError
end
redis_key = "notif-group/#{account.id}/#{type_prefix}"
hour_bucket = activity.created_at.utc.to_i / 1.hour.to_i
# Reuse previous group if it does not span too large an amount of time
previous_bucket = redis.get(redis_key).to_i
hour_bucket = previous_bucket if hour_bucket < previous_bucket + MAXIMUM_GROUP_SPAN_HOURS
# We do not concern ourselves with race conditions since we use hour buckets
redis.set(redis_key, hour_bucket, ex: MAXIMUM_GROUP_SPAN_HOURS.hours.to_i)
self.group_key = "#{type_prefix}-#{hour_bucket}"
end
class << self
def browserable(types: [], exclude_types: [], from_account_id: nil, include_filtered: false)
requested_types = if types.empty?
+1 -20
View File
@@ -3,8 +3,6 @@
class NotifyService < BaseService
include Redisable
MAXIMUM_GROUP_SPAN_HOURS = 12
# TODO: the severed_relationships type probably warrants email notifications
NON_EMAIL_TYPES = %i(
admin.report
@@ -216,7 +214,7 @@ class NotifyService < BaseService
return if drop?
@notification.filtered = filter?
@notification.group_key = notification_group_key
@notification.set_group_key!
@notification.save!
# It's possible the underlying activity has been deleted
@@ -236,23 +234,6 @@ class NotifyService < BaseService
private
def notification_group_key
return nil if @notification.filtered || Notification::GROUPABLE_NOTIFICATION_TYPES.exclude?(@notification.type)
type_prefix = "#{@notification.type}-#{@notification.target_status.id}"
redis_key = "notif-group/#{@recipient.id}/#{type_prefix}"
hour_bucket = @notification.activity.created_at.utc.to_i / 1.hour.to_i
# Reuse previous group if it does not span too large an amount of time
previous_bucket = redis.get(redis_key).to_i
hour_bucket = previous_bucket if hour_bucket < previous_bucket + MAXIMUM_GROUP_SPAN_HOURS
# We do not concern ourselves with race conditions since we use hour buckets
redis.set(redis_key, hour_bucket, ex: MAXIMUM_GROUP_SPAN_HOURS.hours.to_i)
"#{type_prefix}-#{hour_bucket}"
end
def drop?
DropCondition.new(@notification).drop?
end