From bf1bde5d6a8306284a0cce89eb8f492b8c9b7a67 Mon Sep 17 00:00:00 2001 From: Dachi Natsvlishvili Date: Fri, 17 Aug 2018 20:00:01 +0400 Subject: Add Georgian language translation (#8250) * Add Georgian language translation * i18n-tasks normalize --- app/helpers/settings_helper.rb | 1 + app/javascript/mastodon/locales/ka.json | 311 ++++++++++++++++++++++ app/javascript/mastodon/locales/whitelist_ka.json | 2 + 3 files changed, 314 insertions(+) create mode 100644 app/javascript/mastodon/locales/ka.json create mode 100644 app/javascript/mastodon/locales/whitelist_ka.json (limited to 'app') diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index 8528be267..14ca2333e 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -26,6 +26,7 @@ module SettingsHelper io: 'Ido', it: 'Italiano', ja: '日本語', + ka: 'ქართული', ko: '한국어', nl: 'Nederlands', no: 'Norsk', diff --git a/app/javascript/mastodon/locales/ka.json b/app/javascript/mastodon/locales/ka.json new file mode 100644 index 000000000..494270b9d --- /dev/null +++ b/app/javascript/mastodon/locales/ka.json @@ -0,0 +1,311 @@ +{ + "account.badges.bot": "ბოტი", + "account.block": "დაბლოკე @{name}", + "account.block_domain": "დაიმალოს ყველაფერი დომენიდან {domain}", + "account.blocked": "დაიბლოკა", + "account.direct": "პირდაპირი წერილი @{name}-ს", + "account.disclaimer_full": "ქვემოთ მოცემულმა ინფორმაციამ შეიძლება სრულად არ ასახოს მომხმარებლის პროფილი.", + "account.domain_blocked": "დომენი დამალულია", + "account.edit_profile": "პროფილის ცვლილება", + "account.endorse": "გამორჩევა პროფილზე", + "account.follow": "გაყოლა", + "account.followers": "მიმდევრები", + "account.follows": "მიდევნებები", + "account.follows_you": "მოგყვებათ", + "account.hide_reblogs": "დაიმალოს ბუსტები @{name}-სგან", + "account.media": "მედია", + "account.mention": "ასახელეთ @{name}", + "account.moved_to": "{name} გადავიდა:", + "account.mute": "გააჩუმე @{name}", + "account.mute_notifications": "გააჩუმე შეტყობინებები @{name}-სგან", + "account.muted": "გაჩუმებული", + "account.posts": "ტუტები", + "account.posts_with_replies": "ტუტები და პასუხები", + "account.report": "დაარეპორტე @{name}", + "account.requested": "დამტკიცების მოლოდინში. დააწკაპუნეთ რომ უარყოთ დადევნების მოთხონვა", + "account.share": "გააზიარე @{name}-ის პროფილი", + "account.show_reblogs": "აჩვენე ბუსტები @{name}-სგან", + "account.unblock": "განბლოკე @{name}", + "account.unblock_domain": "გამოაჩინე {domain}", + "account.unendorse": "არ გამოირჩეს პროფილზე", + "account.unfollow": "ნუღარ მიჰყვები", + "account.unmute": "ნუღარ აჩუმებ @{name}-ს", + "account.unmute_notifications": "ნუღარ აჩუმებ შეტყობინებებს @{name}-სგან", + "account.view_full_profile": "სრული პროფილის ჩვენება", + "alert.unexpected.message": "წარმოიშვა მოულოდნელი შეცდომა.", + "alert.unexpected.title": "უპს!", + "boost_modal.combo": "შეგიძლიათ დააჭიროთ {combo}-ს რათა შემდეგ ჯერზე გამოტოვოთ ეს", + "bundle_column_error.body": "ამ კომპონენტის ჩატვირთვისას რაღაც აირია.", + "bundle_column_error.retry": "სცადეთ კიდევ ერთხელ", + "bundle_column_error.title": "ქსელის შეცდომა", + "bundle_modal_error.close": "დახურვა", + "bundle_modal_error.message": "ამ კომპონენტის ჩატვირთვისას რაღაც აირია.", + "bundle_modal_error.retry": "სცადეთ კიდევ ერთხელ", + "column.blocks": "დაბლოკილი მომხმარებლები", + "column.community": "ლოკალური თაიმლაინი", + "column.direct": "პირდაპირი წერილები", + "column.domain_blocks": "დამალული დომენები", + "column.favourites": "ფავორიტები", + "column.follow_requests": "დადევნების მოთხოვნები", + "column.home": "სახლი", + "column.lists": "სიები", + "column.mutes": "გაჩუმებული მომხმარებლები", + "column.notifications": "შეტყობინებები", + "column.pins": "აპინული ტუტები", + "column.public": "ფედერალური თაიმლაინი", + "column_back_button.label": "უკან", + "column_header.hide_settings": "პარამეტრების დამალვა", + "column_header.moveLeft_settings": "სვეტის მარცხნივ გადატანა", + "column_header.moveRight_settings": "სვეტის მარჯვნივ გადატანა", + "column_header.pin": "აპინვა", + "column_header.show_settings": "პარამეტრების ჩვენება", + "column_header.unpin": "პინის მოხსნა", + "column_subheading.settings": "პარამეტრები", + "community.column_settings.media_only": "მხოლოდ მედია", + "compose_form.direct_message_warning": "ეს ტუტი გაეგზავნება მხოლოდ ნახსენებ მომხმარებლებს.", + "compose_form.direct_message_warning_learn_more": "გაიგე მეტი", + "compose_form.hashtag_warning": "ეს ტუტი არ მოექცევა ჰეშტეგების ქვეს, რამეთუ ის არაა მითითებული. მხოლოდ ღია ტუტები მოიძებნება ჰეშტეგით.", + "compose_form.lock_disclaimer": "თქვენი ანგარიში არაა {locked}. ნებისმიერს შეიძლია გამოგყვეთ, რომ იხილოს თქვენი მიმდევრებზე გათვლილი პოსტები.", + "compose_form.lock_disclaimer.lock": "ჩაკეტილი", + "compose_form.placeholder": "რაზე ფიქრობ?", + "compose_form.publish": "ტუტი", + "compose_form.publish_loud": "{publish}!", + "compose_form.sensitive.marked": "მედია მონიშნულია მგრძნობიარედ", + "compose_form.sensitive.unmarked": "მედია არაა მონიშნული მგრძნობიარედ", + "compose_form.spoiler.marked": "გაფრთხილების უკან ტექსტი დამალულია", + "compose_form.spoiler.unmarked": "ტექსტი არაა დამალული", + "compose_form.spoiler_placeholder": "თქვენი გაფრთხილება დაწერეთ აქ", + "confirmation_modal.cancel": "უარყოფა", + "confirmations.block.confirm": "ბლოკი", + "confirmations.block.message": "დარწმუნებული ხართ, გსურთ დაბლოკოთ {name}?", + "confirmations.delete.confirm": "გაუქმება", + "confirmations.delete.message": "დარწმუნებული ხართ, გსურთ გააუქმოთ ეს სტატუსი?", + "confirmations.delete_list.confirm": "გაუქმება", + "confirmations.delete_list.message": "დარწმუნებული ხართ, გსურთ სამუდამოდ გააუქმოთ ეს სია?", + "confirmations.domain_block.confirm": "მთელი დომენის დამალვა", + "confirmations.domain_block.message": "ნაღდად, ნაღდად, დარწმუნებული ხართ, გსურთ დაბლოკოთ მთელი {domain}? უმეტეს შემთხვევაში რამდენიმე გამიზნული ბლოკი ან გაჩუმება საკმარისი და უკეთესია. კონტენტს ამ დომენიდან ვერ იხილავთ ვერც ერთ ღია თაიმლაინზე ან თქვენს შეტყობინებებში. ამ დომენიდან არსებული მიმდევრები ამოიშლება.", + "confirmations.mute.confirm": "გაჩუმება", + "confirmations.mute.message": "დარწმუნებული ხართ, გსურთ გააჩუმოთ {name}?", + "confirmations.redraft.confirm": "გაუქმება და გადანაწილება", + "confirmations.redraft.message": "დარწმუნებული ხართ, გსურთ გააუქმოთ ეს სტატუსი და გადაანაწილოთ? დაკარგავთ ყველა პასუხს, ბუსტს და მასზედ არსებულ ფავორიტს.", + "confirmations.unfollow.confirm": "ნუღარ მიჰყვები", + "confirmations.unfollow.message": "დარწმუნებული ხართ, აღარ გსურთ მიჰყვებოდეთ {name}-ს?", + "embed.instructions": "ეს სტატუსი ჩასვით თქვენს ვებ-საიტზე შემდეგი კოდის კოპირებით.", + "embed.preview": "ესაა თუ როგორც გამოჩნდება:", + "emoji_button.activity": "აქტივობა", + "emoji_button.custom": "პერსონალიზირებული", + "emoji_button.flags": "დროშები", + "emoji_button.food": "საჭმელი და სასლმელი", + "emoji_button.label": "ემოჯის ჩასმა", + "emoji_button.nature": "ბუმება", + "emoji_button.not_found": "არაა ემოჯი!! (╯°□°)╯︵ ┻━┻", + "emoji_button.objects": "ობიექტები", + "emoji_button.people": "ხალხი", + "emoji_button.recent": "ხშირად გამოყენებული", + "emoji_button.search": "ძებნა...", + "emoji_button.search_results": "ძებნის შედეგები", + "emoji_button.symbols": "სიმბოლოები", + "emoji_button.travel": "მოგზაურობა და ადგილები", + "empty_column.community": "ლოკალური თაიმლაინი ცარიელია. დაწერეთ რაიმე ღიად ან ქენით რაიმე სხვა!", + "empty_column.direct": "ჯერ პირდაპირი წერილები არ გაქვთ. როდესაც მიიღებთ ან გააგზავნით, გამოჩნდება აქ.", + "empty_column.hashtag": "ამ ჰეშტეგში ჯერ არაფერია.", + "empty_column.home": "თქვენი სახლის თაიმლაინი ცარიელია! ესტუმრეთ {public}-ს ან დასაწყისისთვის გამოიყენეთ ძებნა, რომ შეხვდეთ სხვა მომხმარებლებს.", + "empty_column.home.public_timeline": "ღია თაიმლაინი", + "empty_column.list": "ამ სიაში ჯერ არაფერია. როდესაც სიის წევრები დაპოსტავენ ახალ სტატუსებს, ისინი გამოჩნდებიან აქ.", + "empty_column.notifications": "ჯერ შეტყობინებები არ გაქვთ. საუბრის დასაწყებად იურთიერთქმედეთ სხვებთან.", + "empty_column.public": "აქ არაფერია! შესავსებად, დაწერეთ რაიმე ღიად ან ხელით გაჰყევით მომხმარებლებს სხვა ინსტანციებისგან", + "follow_request.authorize": "ავტორიზაცია", + "follow_request.reject": "უარყოფა", + "getting_started.developers": "დეველოპერები", + "getting_started.documentation": "დოკუმენტაცია", + "getting_started.find_friends": "იპოვეთ მეგობრები ტვიტერიდან", + "getting_started.heading": "დაწყება", + "getting_started.invite": "ხალხის მოწვევა", + "getting_started.open_source_notice": "მასტოდონი ღია პროგრამაა. შეგიძლიათ შეუწყოთ ხელი ან შექმნათ პრობემის რეპორტი {github}-ზე.", + "getting_started.security": "უსაფრთხოება", + "getting_started.terms": "მომსახურების პირობები", + "home.column_settings.basic": "ძირითადი", + "home.column_settings.show_reblogs": "ბუსტების ჩვენება", + "home.column_settings.show_replies": "პასუხების ჩვენება", + "keyboard_shortcuts.back": "უკან გადასასვლელად", + "keyboard_shortcuts.boost": "დასაბუსტად", + "keyboard_shortcuts.column": "ერთ-ერთი სვეტში სტატუსზე ფოკუსირებისთვის", + "keyboard_shortcuts.compose": "შედგენის ტექსტ-არეაზე ფოკუსირებისთვის", + "keyboard_shortcuts.description": "აღწერილობა", + "keyboard_shortcuts.down": "სიაში ქვემოთ გადასაადგილებლად", + "keyboard_shortcuts.enter": "სტატუსის გასახსნელად", + "keyboard_shortcuts.favourite": "ფავორიტად ქცევისთვის", + "keyboard_shortcuts.heading": "კლავიატურის სწრაფი ბმულები", + "keyboard_shortcuts.hotkey": "ცხელი კლავიში", + "keyboard_shortcuts.legend": "ამ ლეგენდის გამოსაჩენად", + "keyboard_shortcuts.mention": "ავტორის დასახელებლად", + "keyboard_shortcuts.profile": "ავტორის პროფილის გასახსნელად", + "keyboard_shortcuts.reply": "პასუხისთვის", + "keyboard_shortcuts.search": "ძიებაზე ფოკუსირებისთვის", + "keyboard_shortcuts.toggle_hidden": "გაფრთხილების უკან ტექსტის გამოსაჩენად/დასამალვად", + "keyboard_shortcuts.toot": "ახალი ტუტის დასაწყებად", + "keyboard_shortcuts.unfocus": "შედგენის ტექსტ-არეაზე ფოკუსის მოსაშორებლად", + "keyboard_shortcuts.up": "სიაში ზემოთ გადასაადგილებლად", + "lightbox.close": "დახურვა", + "lightbox.next": "შემდეგი", + "lightbox.previous": "წინა", + "lists.account.add": "სიაში დამატება", + "lists.account.remove": "სიიდან ამოშლა", + "lists.delete": "სიის წაშლა", + "lists.edit": "სიის შეცვლა", + "lists.new.create": "სიის დამატება", + "lists.new.title_placeholder": "ახალი სიის სათაური", + "lists.search": "ძებნა ადამიანებს შორის რომელთაც მიჰყვებით", + "lists.subheading": "თქვენი სიები", + "loading_indicator.label": "იტვირთება...", + "media_gallery.toggle_visible": "ხილვადობის ჩართვა", + "missing_indicator.label": "არაა ნაპოვნი", + "missing_indicator.sublabel": "ამ რესურსის პოვნა ვერ მოხერხდა", + "mute_modal.hide_notifications": "დავმალოთ შეტყობინებები ამ მომხმარებლისგან?", + "navigation_bar.blocks": "დაბლოკილი მომხმარებლები", + "navigation_bar.community_timeline": "ლოკალური თაიმლაინი", + "navigation_bar.direct": "პირდაპირი წერილები", + "navigation_bar.discover": "აღმოაჩინე", + "navigation_bar.domain_blocks": "დამალული დომენები", + "navigation_bar.edit_profile": "შეცვალე პროფილი", + "navigation_bar.favourites": "ფავორიტები", + "navigation_bar.filters": "გაჩუმებული სიტყვები", + "navigation_bar.follow_requests": "დადევნების მოთხოვნები", + "navigation_bar.info": "ამ ინსტანციის შესახებ", + "navigation_bar.keyboard_shortcuts": "ცხელი კლავიშები", + "navigation_bar.lists": "სიები", + "navigation_bar.logout": "გასვლა", + "navigation_bar.mutes": "გაჩუმებული მომხმარებლები", + "navigation_bar.personal": "პირადი", + "navigation_bar.pins": "აპინული ტუტები", + "navigation_bar.preferences": "პრეფერენსიები", + "navigation_bar.public_timeline": "ფედერალური თაიმლაინი", + "navigation_bar.security": "უსაფრთხოება", + "notification.favourite": "{name}-მა თქვენი სტატუსი აქცია ფავორიტად", + "notification.follow": "{name} გამოგყვათ", + "notification.mention": "{name}-მა გასახელათ", + "notification.reblog": "{name}-მა დაბუსტა თქვენი სტატუსი", + "notifications.clear": "შეტყობინებების გასუფთავება", + "notifications.clear_confirmation": "დარწმუნებული ხართ, გსურთ სამუდამოდ წაშალოთ ყველა თქვენი შეტყობინება?", + "notifications.column_settings.alert": "დესკტოპ შეტყობინებები", + "notifications.column_settings.favourite": "ფავორიტები:", + "notifications.column_settings.follow": "ახალი მიმდევრები:", + "notifications.column_settings.mention": "ხსენებები:", + "notifications.column_settings.push": "ფუშ შეტყობინებები", + "notifications.column_settings.push_meta": "ეს მოწყობილობა", + "notifications.column_settings.reblog": "ბუსტები:", + "notifications.column_settings.show": "გამოჩნდეს სვეტში", + "notifications.column_settings.sound": "ხმის დაკვრა", + "notifications.group": "{count} შეტყობინება", + "onboarding.done": "დასასრული", + "onboarding.next": "შემდეგი", + "onboarding.page_five.public_timelines": "ლოკალური თაიმლაინი {domain}-ზე საჯარო პოსტებს აჩვენებს ყველასგან. ფედერალური თაიმლაინი {domain}-ზე აჩვენებს საჯარო პოსტებს ყველასგან ვინც მიჰყვება. ეს საჯარო თაიმლაინებია, ახალი ადამიანების აღმოჩენის კარგი გზაა.", + "onboarding.page_four.home": "სახლის თაიმლაინი აჩვენებს პოსტებს ადამიანებისგან, რომლებსაც მიჰყვებით.", + "onboarding.page_four.notifications": "შეტყობინებების სვეტი აჩვენებს სხვის ურთიერთქმედებებს თქვენთან.", + "onboarding.page_one.federation": "მასტოდონი დამოუკიდებელი სერვერების ქსელია, რომლებიც ერთიანდებიან ერთი დიდი სოციალური ქსელის შექმნისთვის. ამ სერვერებს ჩვენ ვეძახით ინსტანციებს.", + "onboarding.page_one.full_handle": "თქვენი სრული სახელური", + "onboarding.page_one.handle_hint": "ეს არის ის რასაც ეტყოდით თქვენს მეგობრებს რომ მოძიონ.", + "onboarding.page_one.welcome": "კეთილი იყოს თქვენი მასტოდონში მობრძანება!", + "onboarding.page_six.admin": "თქვენი ინსტანციის ადმინისტრატორია {admin}.", + "onboarding.page_six.almost_done": "თითქმის დასრულდა...", + "onboarding.page_six.appetoot": "ბონ აპეტუტ!", + "onboarding.page_six.apps_available": "ხელმისაწვდომია {apps} აი-ოსისთვის, ანდროიდისთვის და სხვა პლატფორმებისთვის.", + "onboarding.page_six.github": "მასტოდონი უფასო ღია პროგრამაა. შეგიძლიათ დაარეპორტოთ შეცდომები, მოითხოვოთ ფუნქციები, შეუწყოთ ხელი კოდს {github}-ზე.", + "onboarding.page_six.guidelines": "საზოგადოების სახელმძღვანელო", + "onboarding.page_six.read_guidelines": "გთხოვთ გაეცნოთ {domain}-ს {guidelines}!", + "onboarding.page_six.various_app": "მობაილ აპები", + "onboarding.page_three.profile": "შეცვალეთ თქვენი პროფილი რომ შეცვალოთ ავატარი, ბიოგრაფია და დისპლეის სახელი. იქ, ასევე იხილავთ სხვა პრეფერენსიების.", + "onboarding.page_three.search": "გამოიყენეთ ძიება რომ იპოვნოთ ადამიანები და იხილოთ ჰეშტეგები, ისეთები როგორებიცაა {illustration} და {introductions}. რომ მოძებნოთ ადამიანი ვინც არაა ამ ინსტანციაზე, გამოიყენეთ სრული სახელური.", + "onboarding.page_two.compose": "პოსტები შექმენით კომპოზიციის სვეტიდან. შეგიძლიათ ატვირთოთ სურათები, შეცვალოთ კონფიდენციალურობა და ქვემოთ მოცემული პიქტოგრამით დაამატოთ კონტენტის გაფრთხილება.", + "onboarding.skip": "გამოტოვება", + "privacy.change": "სტატუსის კონფიდენციალურობის მითითება", + "privacy.direct.long": "დაიპოსტოს მხოლოდ დასახელებულ მომხმარებლებთან", + "privacy.direct.short": "პირდაპირი", + "privacy.private.long": "დაიპოსტოს მხოლოდ მიმდევრებთან", + "privacy.private.short": "მხოლოდ-მიმდევრებისთვის", + "privacy.public.long": "დაიპოსტოს საჯარო თაიმლაინებზე", + "privacy.public.short": "საჯარო", + "privacy.unlisted.long": "არ დაიპოსტოს საჯარო თაიმლაინებზე", + "privacy.unlisted.short": "ჩამოუთვლელი", + "regeneration_indicator.label": "იტვირთება…", + "regeneration_indicator.sublabel": "თქვენი სახლის ლენტა მზადდება!", + "relative_time.days": "{number}დღ", + "relative_time.hours": "{number}სთ", + "relative_time.just_now": "ახლა", + "relative_time.minutes": "{number}წთ", + "relative_time.seconds": "{number}წმ", + "reply_indicator.cancel": "უარყოფა", + "report.forward": "ფორვარდი {target}-ს", + "report.forward_hint": "ანგარიში სხვა სერვერიდანაა. გავაგზავნოთ რეპორტის ანონიმური ასლიც?", + "report.hint": "რეპორტი გაეგზავნება თქვენი ინსტანციის მოდერატორებს. ქვემოთ შეგიძლიათ დაამატოთ მიზეზი თუ რატომ არეპორტებთ ამ ანგარიშს:", + "report.placeholder": "დამატებითი კომენტარები", + "report.submit": "დასრულება", + "report.target": "არეპორტებთ {target}", + "search.placeholder": "ძებნა", + "search_popout.search_format": "დეტალური ძებნის ფორმა", + "search_popout.tips.full_text": "მარტივი ტექსტი აბრუნებს სტატუსებს რომლებიც შექმენით, აქციეთ ფავორიტად, დაბუსტეთ, ან რაშიც ასახელეთ, ასევე ემთხვევა მომხმარებლის სახელებს, დისპლეი სახელებს, და ჰეშტეგებს.", + "search_popout.tips.hashtag": "ჰეშტეგი", + "search_popout.tips.status": "სტატუსი", + "search_popout.tips.text": "მარტივი ტექსტი აბრუნებს დამთხვეულ დისპლეი სახელებს, მომხმარებლის სახელებს და ჰეშტეგებს", + "search_popout.tips.user": "მომხმარებელი", + "search_results.accounts": "ხალხი", + "search_results.hashtags": "ჰეშტეგები", + "search_results.statuses": "ტუტები", + "search_results.total": "{count, number} {count, plural, one {result} other {results}}", + "standalone.public_title": "შიდა ხედი...", + "status.block": "დაბლოკე @{name}", + "status.cancel_reblog_private": "ბუსტის მოშორება", + "status.cannot_reblog": "ეს პოსტი ვერ დაიბუსტება", + "status.delete": "წაშლა", + "status.direct": "პირდაპირი წერილი @{name}-ს", + "status.embed": "ჩართვა", + "status.favourite": "ფავორიტი", + "status.filtered": "ფილტრირებული", + "status.load_more": "მეტის ჩატვირთვა", + "status.media_hidden": "მედია დამალულია", + "status.mention": "ასახელე @{name}", + "status.more": "მეტი", + "status.mute": "გააჩუმე @{name}", + "status.mute_conversation": "გააჩუმე საუბარი", + "status.open": "ამ სტატუსის გაფართოება", + "status.pin": "აპინე პროფილზე", + "status.pinned": "აპინული ტუტი", + "status.reblog": "ბუსტი", + "status.reblog_private": "დაიბუსტოს საწყის აუდიტორიაზე", + "status.reblogged_by": "{name} დაიბუსტა", + "status.redraft": "გაუქმდეს და გადანაწილდეს", + "status.reply": "პასუხი", + "status.replyAll": "უპასუხე თემას", + "status.report": "დაარეპორტე @{name}", + "status.sensitive_toggle": "დააწკაპუნეთ სანახავად", + "status.sensitive_warning": "მგრძნობიარე კონტენტი", + "status.share": "გაზიარება", + "status.show_less": "აჩვენე ნაკლები", + "status.show_less_all": "აჩვენე ნაკლები ყველაზე", + "status.show_more": "აჩვენე მეტი", + "status.show_more_all": "აჩვენე მეტი ყველაზე", + "status.unmute_conversation": "საუბარზე გაჩუმების მოშორება", + "status.unpin": "პროფილიდან პინის მოშორება", + "tabs_bar.federated_timeline": "ფედერალური", + "tabs_bar.home": "სახლი", + "tabs_bar.local_timeline": "ლოკალური", + "tabs_bar.notifications": "შეტყობინებები", + "tabs_bar.search": "ძებნა", + "trends.count_by_accounts": "{count} {rawCount, plural, one {person} other {people}} საუბრობს", + "ui.beforeunload": "თქვენი დრაფტი გაუქმდება თუ დატოვებთ მასტოდონს.", + "upload_area.title": "გადმოწიეთ და ჩააგდეთ ასატვირთათ", + "upload_button.label": "მედიის დამატება", + "upload_form.description": "აღწერილობა ვიზუალურად უფასურისთვის", + "upload_form.focus": "კროპი", + "upload_form.undo": "გაუქმება", + "upload_progress.label": "იტვირთება...", + "video.close": "ვიდეოს დახურვა", + "video.exit_fullscreen": "სრულ ეკრანზე ჩვენების გათიშვა", + "video.expand": "ვიდეოს გაფართოება", + "video.fullscreen": "ჩვენება სრულ ეკრანზე", + "video.hide": "ვიდეოს დამალვა", + "video.mute": "ხმის გაჩუმება", + "video.pause": "პაუზა", + "video.play": "დაკვრა", + "video.unmute": "ხმის გაჩუმების მოშორება" +} diff --git a/app/javascript/mastodon/locales/whitelist_ka.json b/app/javascript/mastodon/locales/whitelist_ka.json new file mode 100644 index 000000000..0d4f101c7 --- /dev/null +++ b/app/javascript/mastodon/locales/whitelist_ka.json @@ -0,0 +1,2 @@ +[ +] -- cgit From 78fa926ed560e6a9738144bec7e152fa42104139 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 18 Aug 2018 03:03:12 +0200 Subject: Add remote interaction dialog for toots (#8202) * Add remote interaction dialog for toots * Change AuthorizeFollow into AuthorizeInteraction, support statuses * Update brakeman.ignore * Adjust how interaction buttons are display on public pages * Fix tests --- app/controllers/authorize_follows_controller.rb | 66 -------- .../authorize_interactions_controller.rb | 66 ++++++++ app/controllers/intents_controller.rb | 2 +- app/controllers/remote_follow_controller.rb | 1 + app/controllers/remote_interaction_controller.rb | 48 ++++++ app/helpers/home_helper.rb | 10 ++ app/javascript/packs/public.js | 21 ++- app/javascript/styles/mastodon/components.scss | 1 + app/javascript/styles/mastodon/stream_entries.scss | 5 + app/models/remote_follow.rb | 4 + app/serializers/webfinger_serializer.rb | 2 +- .../_post_follow_actions.html.haml | 4 - app/views/authorize_follows/error.html.haml | 3 - app/views/authorize_follows/show.html.haml | 17 -- app/views/authorize_follows/success.html.haml | 13 -- .../_post_follow_actions.html.haml | 4 + app/views/authorize_interactions/error.html.haml | 3 + app/views/authorize_interactions/show.html.haml | 18 +++ app/views/authorize_interactions/success.html.haml | 13 ++ app/views/layouts/modal.html.haml | 2 +- app/views/remote_interaction/new.html.haml | 17 ++ .../stream_entries/_detailed_status.html.haml | 15 +- app/views/stream_entries/_simple_status.html.haml | 10 +- app/views/stream_entries/show.html.haml | 2 +- app/views/well_known/webfinger/show.xml.ruby | 2 +- config/brakeman.ignore | 180 +++++++++++++-------- config/locales/en.yml | 5 +- config/routes.rb | 5 +- .../authorize_follows_controller_spec.rb | 110 ------------- .../authorize_interactions_controller_spec.rb | 111 +++++++++++++ spec/controllers/intents_controller_spec.rb | 2 +- 31 files changed, 457 insertions(+), 305 deletions(-) delete mode 100644 app/controllers/authorize_follows_controller.rb create mode 100644 app/controllers/authorize_interactions_controller.rb create mode 100644 app/controllers/remote_interaction_controller.rb delete mode 100644 app/views/authorize_follows/_post_follow_actions.html.haml delete mode 100644 app/views/authorize_follows/error.html.haml delete mode 100644 app/views/authorize_follows/show.html.haml delete mode 100644 app/views/authorize_follows/success.html.haml create mode 100644 app/views/authorize_interactions/_post_follow_actions.html.haml create mode 100644 app/views/authorize_interactions/error.html.haml create mode 100644 app/views/authorize_interactions/show.html.haml create mode 100644 app/views/authorize_interactions/success.html.haml create mode 100644 app/views/remote_interaction/new.html.haml delete mode 100644 spec/controllers/authorize_follows_controller_spec.rb create mode 100644 spec/controllers/authorize_interactions_controller_spec.rb (limited to 'app') diff --git a/app/controllers/authorize_follows_controller.rb b/app/controllers/authorize_follows_controller.rb deleted file mode 100644 index 775d5f23f..000000000 --- a/app/controllers/authorize_follows_controller.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -class AuthorizeFollowsController < ApplicationController - layout 'modal' - - before_action :authenticate_user! - before_action :set_body_classes - - def show - @account = located_account || render(:error) - end - - def create - @account = follow_attempt.try(:target_account) - - if @account.nil? - render :error - else - render :success - end - rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError - render :error - end - - private - - def follow_attempt - FollowService.new.call(current_account, acct_without_prefix) - end - - def located_account - if acct_param_is_url? - account_from_remote_fetch - else - account_from_remote_follow - end - end - - def account_from_remote_fetch - FetchRemoteAccountService.new.call(acct_without_prefix) - end - - def account_from_remote_follow - ResolveAccountService.new.call(acct_without_prefix) - end - - def acct_param_is_url? - parsed_uri.path && %w(http https).include?(parsed_uri.scheme) - end - - def parsed_uri - Addressable::URI.parse(acct_without_prefix).normalize - end - - def acct_without_prefix - acct_params.gsub(/\Aacct:/, '') - end - - def acct_params - params.fetch(:acct, '') - end - - def set_body_classes - @body_classes = 'modal-layout' - end -end diff --git a/app/controllers/authorize_interactions_controller.rb b/app/controllers/authorize_interactions_controller.rb new file mode 100644 index 000000000..e27366ea3 --- /dev/null +++ b/app/controllers/authorize_interactions_controller.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +class AuthorizeInteractionsController < ApplicationController + include Authorization + + layout 'modal' + + before_action :authenticate_user! + before_action :set_body_classes + before_action :set_resource + + def show + if @resource.is_a?(Account) + render :show + elsif @resource.is_a?(Status) + redirect_to web_url("statuses/#{@resource.id}") + else + render :error + end + end + + def create + if @resource.is_a?(Account) && FollowService.new.call(current_account, @resource) + render :success + else + render :error + end + rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError + render :error + end + + private + + def set_resource + @resource = located_resource || render(:error) + authorize(@resource, :show?) if @resource.is_a?(Status) + end + + def located_resource + if uri_param_is_url? + ResolveURLService.new.call(uri_param) + else + account_from_remote_follow + end + end + + def account_from_remote_follow + ResolveAccountService.new.call(uri_param) + end + + def uri_param_is_url? + parsed_uri.path && %w(http https).include?(parsed_uri.scheme) + end + + def parsed_uri + Addressable::URI.parse(uri_param).normalize + end + + def uri_param + params[:uri] || params.fetch(:acct, '').gsub(/\Aacct:/, '') + end + + def set_body_classes + @body_classes = 'modal-layout' + end +end diff --git a/app/controllers/intents_controller.rb b/app/controllers/intents_controller.rb index 56129d69a..9f41cf48a 100644 --- a/app/controllers/intents_controller.rb +++ b/app/controllers/intents_controller.rb @@ -8,7 +8,7 @@ class IntentsController < ApplicationController if uri.scheme == 'web+mastodon' case uri.host when 'follow' - return redirect_to authorize_follow_path(acct: uri.query_values['uri'].gsub(/\Aacct:/, '')) + return redirect_to authorize_interaction_path(uri: uri.query_values['uri'].gsub(/\Aacct:/, '')) when 'share' return redirect_to share_path(text: uri.query_values['text']) end diff --git a/app/controllers/remote_follow_controller.rb b/app/controllers/remote_follow_controller.rb index cd61fd763..8ba331cd1 100644 --- a/app/controllers/remote_follow_controller.rb +++ b/app/controllers/remote_follow_controller.rb @@ -42,5 +42,6 @@ class RemoteFollowController < ApplicationController def set_body_classes @body_classes = 'modal-layout' + @hide_header = true end end diff --git a/app/controllers/remote_interaction_controller.rb b/app/controllers/remote_interaction_controller.rb new file mode 100644 index 000000000..6299a1e13 --- /dev/null +++ b/app/controllers/remote_interaction_controller.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +class RemoteInteractionController < ApplicationController + include Authorization + + layout 'modal' + + before_action :set_status + before_action :set_body_classes + + def new + @remote_follow = RemoteFollow.new(session_params) + end + + def create + @remote_follow = RemoteFollow.new(resource_params) + + if @remote_follow.valid? + session[:remote_follow] = @remote_follow.acct + redirect_to @remote_follow.interact_address_for(@status) + else + render :new + end + end + + private + + def resource_params + params.require(:remote_follow).permit(:acct) + end + + def session_params + { acct: session[:remote_follow] } + end + + def set_status + @status = Status.find(params[:id]) + authorize @status, :show? + rescue Mastodon::NotPermittedError + # Reraise in order to get a 404 + raise ActiveRecord::RecordNotFound + end + + def set_body_classes + @body_classes = 'modal-layout' + @hide_header = true + end +end diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb index 8449f6c8a..f5b501235 100644 --- a/app/helpers/home_helper.rb +++ b/app/helpers/home_helper.rb @@ -38,4 +38,14 @@ module HomeHelper end end end + + def obscured_counter(count) + if count <= 0 + 0 + elsif count == 1 + 1 + else + '1+' + end + end end diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index 6b47eecf9..dc18da853 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -67,13 +67,6 @@ function main() { }, datetime, now, datetime.getFullYear()); }); - [].forEach.call(document.querySelectorAll('.modal-button'), (content) => { - content.addEventListener('click', (e) => { - e.preventDefault(); - window.open(e.target.href, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes'); - }); - }); - const reactComponents = document.querySelectorAll('[data-component]'); if (reactComponents.length > 0) { import(/* webpackChunkName: "containers/media_container" */ '../mastodon/containers/media_container') @@ -119,6 +112,20 @@ function main() { return false; }); + delegate(document, '.modal-button', 'click', e => { + e.preventDefault(); + + let href; + + if (e.target.nodeName !== 'A') { + href = e.target.parentNode.href; + } else { + href = e.target.href; + } + + window.open(href, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes'); + }); + delegate(document, '#account_display_name', 'input', ({ target }) => { const nameCounter = document.querySelector('.name-counter'); const name = document.querySelector('.card .display-name strong'); diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 931f1aa0d..cfd8e5ad4 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -628,6 +628,7 @@ overflow: hidden; white-space: pre-wrap; padding-top: 2px; + color: $primary-text-color; &:focus { outline: 0; diff --git a/app/javascript/styles/mastodon/stream_entries.scss b/app/javascript/styles/mastodon/stream_entries.scss index 9e2aa720c..03bbd84db 100644 --- a/app/javascript/styles/mastodon/stream_entries.scss +++ b/app/javascript/styles/mastodon/stream_entries.scss @@ -3,6 +3,7 @@ border-radius: 4px; overflow: hidden; margin-bottom: 10px; + text-align: left; @media screen and (max-width: $no-gap-breakpoint) { margin-bottom: 0; @@ -63,6 +64,10 @@ } } } + + &--highlighted .entry { + background: lighten($ui-base-color, 8%); + } } .button.logo-button { diff --git a/app/models/remote_follow.rb b/app/models/remote_follow.rb index 070144e2d..2537de36c 100644 --- a/app/models/remote_follow.rb +++ b/app/models/remote_follow.rb @@ -22,6 +22,10 @@ class RemoteFollow addressable_template.expand(uri: account.local_username_and_domain).to_s end + def interact_address_for(status) + addressable_template.expand(uri: ActivityPub::TagManager.instance.uri_for(status)).to_s + end + private def populate_template diff --git a/app/serializers/webfinger_serializer.rb b/app/serializers/webfinger_serializer.rb index f80d12c02..8c0b07702 100644 --- a/app/serializers/webfinger_serializer.rb +++ b/app/serializers/webfinger_serializer.rb @@ -20,7 +20,7 @@ class WebfingerSerializer < ActiveModel::Serializer { rel: 'self', type: 'application/activity+json', href: account_url(object) }, { rel: 'salmon', href: api_salmon_url(object.id) }, { rel: 'magic-public-key', href: "data:application/magic-public-key,#{object.magic_key}" }, - { rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}" }, + { rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_interaction_url}?uri={uri}" }, ] end end diff --git a/app/views/authorize_follows/_post_follow_actions.html.haml b/app/views/authorize_follows/_post_follow_actions.html.haml deleted file mode 100644 index 2a9c062e9..000000000 --- a/app/views/authorize_follows/_post_follow_actions.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -.post-follow-actions - %div= link_to t('authorize_follow.post_follow.web'), web_url("accounts/#{@account.id}"), class: 'button button--block' - %div= link_to t('authorize_follow.post_follow.return'), TagManager.instance.url_for(@account), class: 'button button--block' - %div= t('authorize_follow.post_follow.close') diff --git a/app/views/authorize_follows/error.html.haml b/app/views/authorize_follows/error.html.haml deleted file mode 100644 index 88d33b68d..000000000 --- a/app/views/authorize_follows/error.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -.form-container - .flash-message#error_explanation - = t('authorize_follow.error') diff --git a/app/views/authorize_follows/show.html.haml b/app/views/authorize_follows/show.html.haml deleted file mode 100644 index 90e65b34f..000000000 --- a/app/views/authorize_follows/show.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -- content_for :page_title do - = t('authorize_follow.title', acct: @account.acct) - -.form-container - .follow-prompt - = render 'application/card', account: @account - - - if current_account.following?(@account) - .flash-message - %strong - = t('authorize_follow.already_following') - = render 'post_follow_actions' - - - else - = form_tag authorize_follow_path, method: :post, class: 'simple_form' do - = hidden_field_tag :acct, @account.acct - = button_tag t('authorize_follow.follow'), type: :submit diff --git a/app/views/authorize_follows/success.html.haml b/app/views/authorize_follows/success.html.haml deleted file mode 100644 index cf9cb50ea..000000000 --- a/app/views/authorize_follows/success.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -- content_for :page_title do - = t('authorize_follow.title', acct: @account.acct) - -.form-container - .follow-prompt - - if @account.locked? - %h2= t('authorize_follow.follow_request') - - else - %h2= t('authorize_follow.following') - - = render 'application/card', account: @account - - = render 'post_follow_actions' diff --git a/app/views/authorize_interactions/_post_follow_actions.html.haml b/app/views/authorize_interactions/_post_follow_actions.html.haml new file mode 100644 index 000000000..561c60137 --- /dev/null +++ b/app/views/authorize_interactions/_post_follow_actions.html.haml @@ -0,0 +1,4 @@ +.post-follow-actions + %div= link_to t('authorize_follow.post_follow.web'), web_url("accounts/#{@resource.id}"), class: 'button button--block' + %div= link_to t('authorize_follow.post_follow.return'), TagManager.instance.url_for(@resource), class: 'button button--block' + %div= t('authorize_follow.post_follow.close') diff --git a/app/views/authorize_interactions/error.html.haml b/app/views/authorize_interactions/error.html.haml new file mode 100644 index 000000000..88d33b68d --- /dev/null +++ b/app/views/authorize_interactions/error.html.haml @@ -0,0 +1,3 @@ +.form-container + .flash-message#error_explanation + = t('authorize_follow.error') diff --git a/app/views/authorize_interactions/show.html.haml b/app/views/authorize_interactions/show.html.haml new file mode 100644 index 000000000..7ca9b98c1 --- /dev/null +++ b/app/views/authorize_interactions/show.html.haml @@ -0,0 +1,18 @@ +- content_for :page_title do + = t('authorize_follow.title', acct: @resource.acct) + +.form-container + .follow-prompt + = render 'application/card', account: @resource + + - if current_account.following?(@resource) + .flash-message + %strong + = t('authorize_follow.already_following') + + = render 'post_follow_actions' + - else + = form_tag authorize_interaction_path, method: :post, class: 'simple_form' do + = hidden_field_tag :action, :follow + = hidden_field_tag :acct, @resource.acct + = button_tag t('authorize_follow.follow'), type: :submit diff --git a/app/views/authorize_interactions/success.html.haml b/app/views/authorize_interactions/success.html.haml new file mode 100644 index 000000000..47fd09767 --- /dev/null +++ b/app/views/authorize_interactions/success.html.haml @@ -0,0 +1,13 @@ +- content_for :page_title do + = t('authorize_follow.title', acct: @resource.acct) + +.form-container + .follow-prompt + - if @resource.locked? + %h2= t('authorize_follow.follow_request') + - else + %h2= t('authorize_follow.following') + + = render 'application/card', account: @resource + + = render 'post_follow_actions' diff --git a/app/views/layouts/modal.html.haml b/app/views/layouts/modal.html.haml index 325b4ec72..b73068459 100644 --- a/app/views/layouts/modal.html.haml +++ b/app/views/layouts/modal.html.haml @@ -2,7 +2,7 @@ = javascript_pack_tag 'public', integrity: true, crossorigin: 'anonymous' - content_for :content do - - if user_signed_in? + - if user_signed_in? && !@hide_header .account-header .avatar= image_tag current_account.avatar.url(:original) .name diff --git a/app/views/remote_interaction/new.html.haml b/app/views/remote_interaction/new.html.haml new file mode 100644 index 000000000..7357546b6 --- /dev/null +++ b/app/views/remote_interaction/new.html.haml @@ -0,0 +1,17 @@ +.form-container + .follow-prompt + %h2= t('remote_interaction.prompt') + + .public-layout + .activity-stream.activity-stream--highlighted + = render 'stream_entries/status', status: @status + + = simple_form_for @remote_follow, as: :remote_follow, url: remote_interaction_path(@status) do |f| + = render 'shared/error_messages', object: @remote_follow + + = f.input :acct, placeholder: t('remote_follow.acct'), input_html: { autocapitalize: 'none', autocorrect: 'off' } + + .actions + = f.button :button, t('remote_interaction.proceed'), type: :submit + + %p.hint.subtle-hint= t('remote_follow.no_account_html', sign_up_path: open_registrations? ? new_user_registration_path : 'https://joinmastodon.org/#getting-started') diff --git a/app/views/stream_entries/_detailed_status.html.haml b/app/views/stream_entries/_detailed_status.html.haml index aa160b979..a7c767816 100644 --- a/app/views/stream_entries/_detailed_status.html.haml +++ b/app/views/stream_entries/_detailed_status.html.haml @@ -39,6 +39,11 @@ - else = link_to status.application.name, status.application.website, class: 'detailed-status__application', target: '_blank', rel: 'noopener' · + = link_to remote_interaction_path(status), class: 'modal-button detailed-status__link' do + = fa_icon('reply') + %span.detailed-status__reblogs>= number_to_human status.replies_count, strip_insignificant_zeros: true + = " " + · - if status.direct_visibility? %span.detailed-status__link< = fa_icon('envelope') @@ -46,13 +51,15 @@ %span.detailed-status__link< = fa_icon('lock') - else - %span.detailed-status__link< + = link_to remote_interaction_path(status), class: 'modal-button detailed-status__link' do = fa_icon('retweet') - %span.detailed-status__reblogs= number_to_human status.reblogs_count, strip_insignificant_zeros: true + %span.detailed-status__reblogs>= number_to_human status.reblogs_count, strip_insignificant_zeros: true + = " " · - %span.detailed-status__link< + = link_to remote_interaction_path(status), class: 'modal-button detailed-status__link' do = fa_icon('star') - %span.detailed-status__favorites= number_to_human status.favourites_count, strip_insignificant_zeros: true + %span.detailed-status__favorites>= number_to_human status.favourites_count, strip_insignificant_zeros: true + = " " - if user_signed_in? · diff --git a/app/views/stream_entries/_simple_status.html.haml b/app/views/stream_entries/_simple_status.html.haml index 676d367ca..ec8b69bb6 100644 --- a/app/views/stream_entries/_simple_status.html.haml +++ b/app/views/stream_entries/_simple_status.html.haml @@ -29,14 +29,16 @@ = react_component :media_gallery, height: 343, sensitive: status.sensitive? && !current_account&.user&.setting_display_sensitive_media, 'autoPlayGif': current_account&.user&.setting_auto_play_gif, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json } .status__action-bar - .status__action-bar-button.static-icon-button< + .status__action-bar__counter + = link_to remote_interaction_path(status), class: 'status__action-bar-button icon-button modal-button', style: 'font-size: 18px; width: 23.1429px; height: 23.1429px; line-height: 23.15px;' do + = fa_icon 'reply fw' + .status__action-bar__counter__label= obscured_counter status.replies_count + = link_to remote_interaction_path(status), class: 'status__action-bar-button icon-button modal-button', style: 'font-size: 18px; width: 23.1429px; height: 23.1429px; line-height: 23.15px;' do - if status.public_visibility? || status.unlisted_visibility? = fa_icon 'retweet fw' - %span.detailed-status__reblogs= number_to_human status.reblogs_count, strip_insignificant_zeros: true - elsif status.private_visibility? = fa_icon 'lock fw' - else = fa_icon 'envelope fw' - .status__action-bar-button.static-icon-button< + = link_to remote_interaction_path(status), class: 'status__action-bar-button icon-button modal-button', style: 'font-size: 18px; width: 23.1429px; height: 23.1429px; line-height: 23.15px;' do = fa_icon 'star fw' - %span.detailed-status__favorites= number_to_human status.favourites_count, strip_insignificant_zeros: true diff --git a/app/views/stream_entries/show.html.haml b/app/views/stream_entries/show.html.haml index 9da6245dc..2edc155bf 100644 --- a/app/views/stream_entries/show.html.haml +++ b/app/views/stream_entries/show.html.haml @@ -19,7 +19,7 @@ .grid .column-0 - .activity-stream.activity-stream-headless.h-entry + .activity-stream.h-entry = render partial: "stream_entries/#{@type}", locals: { @type.to_sym => @stream_entry.activity, include_threads: true } .column-1 = render 'application/sidebar' diff --git a/app/views/well_known/webfinger/show.xml.ruby b/app/views/well_known/webfinger/show.xml.ruby index 4352a24e9..968c8c138 100644 --- a/app/views/well_known/webfinger/show.xml.ruby +++ b/app/views/well_known/webfinger/show.xml.ruby @@ -37,7 +37,7 @@ doc << Ox::Element.new('XRD').tap do |xrd| xrd << Ox::Element.new('Link').tap do |link| link['rel'] = 'http://ostatus.org/schema/1.0/subscribe' - link['template'] = "#{authorize_follow_url}?acct={uri}" + link['template'] = "#{authorize_interaction_url}?acct={uri}" end end diff --git a/config/brakeman.ignore b/config/brakeman.ignore index e8956639c..40fef7283 100644 --- a/config/brakeman.ignore +++ b/config/brakeman.ignore @@ -1,5 +1,25 @@ { "ignored_warnings": [ + { + "warning_type": "SQL Injection", + "warning_code": 0, + "fingerprint": "04dbbc249b989db2e0119bbb0f59c9818e12889d2b97c529cdc0b1526002ba4b", + "check_name": "SQL", + "message": "Possible SQL injection", + "file": "app/models/report.rb", + "line": 86, + "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/", + "code": "Admin::ActionLog.from(\"(#{[Admin::ActionLog.where(:target_type => \"Report\", :target_id => id, :created_at => ((created_at..updated_at))).unscope(:order), Admin::ActionLog.where(:target_type => \"Account\", :target_id => target_account_id, :created_at => ((created_at..updated_at))).unscope(:order), Admin::ActionLog.where(:target_type => \"Status\", :target_id => status_ids, :created_at => ((created_at..updated_at))).unscope(:order)].map do\n \"(#{query.to_sql})\"\n end.join(\" UNION ALL \")}) AS admin_action_logs\")", + "render_path": null, + "location": { + "type": "method", + "class": "Report", + "method": "history" + }, + "user_input": "Admin::ActionLog.where(:target_type => \"Status\", :target_id => status_ids, :created_at => ((created_at..updated_at))).unscope(:order)", + "confidence": "High", + "note": "" + }, { "warning_type": "Cross-Site Scripting", "warning_code": 4, @@ -7,8 +27,8 @@ "check_name": "LinkToHref", "message": "Potentially unsafe model attribute in link_to href", "file": "app/views/admin/accounts/show.html.haml", - "line": 147, - "link": "http://brakemanscanner.org/docs/warning_types/link_to_href", + "line": 167, + "link": "https://brakemanscanner.org/docs/warning_types/link_to_href", "code": "link_to(Account.find(params[:id]).inbox_url, Account.find(params[:id]).inbox_url)", "render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}], "location": { @@ -26,8 +46,8 @@ "check_name": "LinkToHref", "message": "Potentially unsafe model attribute in link_to href", "file": "app/views/admin/accounts/show.html.haml", - "line": 153, - "link": "http://brakemanscanner.org/docs/warning_types/link_to_href", + "line": 173, + "link": "https://brakemanscanner.org/docs/warning_types/link_to_href", "code": "link_to(Account.find(params[:id]).shared_inbox_url, Account.find(params[:id]).shared_inbox_url)", "render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}], "location": { @@ -45,8 +65,8 @@ "check_name": "LinkToHref", "message": "Potentially unsafe model attribute in link_to href", "file": "app/views/admin/accounts/show.html.haml", - "line": 57, - "link": "http://brakemanscanner.org/docs/warning_types/link_to_href", + "line": 75, + "link": "https://brakemanscanner.org/docs/warning_types/link_to_href", "code": "link_to(Account.find(params[:id]).url, Account.find(params[:id]).url)", "render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}], "location": { @@ -57,6 +77,26 @@ "confidence": "Weak", "note": "" }, + { + "warning_type": "Mass Assignment", + "warning_code": 105, + "fingerprint": "28d81cc22580ef76e912b077b245f353499aa27b3826476667224c00227af2a9", + "check_name": "PermitAttributes", + "message": "Potentially dangerous key allowed for mass assignment", + "file": "app/controllers/admin/reports_controller.rb", + "line": 86, + "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/", + "code": "params.permit(:account_id, :resolved, :target_account_id)", + "render_path": null, + "location": { + "type": "method", + "class": "Admin::ReportsController", + "method": "filter_params" + }, + "user_input": ":account_id", + "confidence": "High", + "note": "" + }, { "warning_type": "Dynamic Render Path", "warning_code": 15, @@ -65,9 +105,9 @@ "message": "Render path contains parameter value", "file": "app/views/stream_entries/embed.html.haml", "line": 3, - "link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/", + "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/", "code": "render(action => \"stream_entries/#{Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity_type.downcase}\", { Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity_type.downcase.to_sym => Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity, :centered => true })", - "render_path": [{"type":"controller","class":"StatusesController","method":"embed","line":45,"file":"app/controllers/statuses_controller.rb"}], + "render_path": [{"type":"controller","class":"StatusesController","method":"embed","line":58,"file":"app/controllers/statuses_controller.rb"}], "location": { "type": "template", "template": "stream_entries/embed" @@ -83,8 +123,8 @@ "check_name": "Render", "message": "Render path contains parameter value", "file": "app/views/admin/action_logs/index.html.haml", - "line": 5, - "link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/", + "line": 4, + "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/", "code": "render(action => Admin::ActionLog.page(params[:page]), {})", "render_path": [{"type":"controller","class":"Admin::ActionLogsController","method":"index","line":7,"file":"app/controllers/admin/action_logs_controller.rb"}], "location": { @@ -95,6 +135,26 @@ "confidence": "Weak", "note": "" }, + { + "warning_type": "Redirect", + "warning_code": 18, + "fingerprint": "5fad11cd67f905fab9b1d5739d01384a1748ebe78c5af5ac31518201925265a7", + "check_name": "Redirect", + "message": "Possible unprotected redirect", + "file": "app/controllers/remote_interaction_controller.rb", + "line": 20, + "link": "https://brakemanscanner.org/docs/warning_types/redirect/", + "code": "redirect_to(RemoteFollow.new(resource_params).interact_address_for(Status.find(params[:id])))", + "render_path": null, + "location": { + "type": "method", + "class": "RemoteInteractionController", + "method": "create" + }, + "user_input": "RemoteFollow.new(resource_params).interact_address_for(Status.find(params[:id]))", + "confidence": "High", + "note": "" + }, { "warning_type": "Cross-Site Scripting", "warning_code": 4, @@ -102,8 +162,8 @@ "check_name": "LinkToHref", "message": "Potentially unsafe model attribute in link_to href", "file": "app/views/admin/accounts/show.html.haml", - "line": 156, - "link": "http://brakemanscanner.org/docs/warning_types/link_to_href", + "line": 176, + "link": "https://brakemanscanner.org/docs/warning_types/link_to_href", "code": "link_to(Account.find(params[:id]).followers_url, Account.find(params[:id]).followers_url)", "render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}], "location": { @@ -121,8 +181,8 @@ "check_name": "LinkToHref", "message": "Potentially unsafe model attribute in link_to href", "file": "app/views/admin/accounts/show.html.haml", - "line": 130, - "link": "http://brakemanscanner.org/docs/warning_types/link_to_href", + "line": 149, + "link": "https://brakemanscanner.org/docs/warning_types/link_to_href", "code": "link_to(Account.find(params[:id]).salmon_url, Account.find(params[:id]).salmon_url)", "render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}], "location": { @@ -141,7 +201,7 @@ "message": "Render path contains parameter value", "file": "app/views/admin/custom_emojis/index.html.haml", "line": 45, - "link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/", + "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/", "code": "render(action => filtered_custom_emojis.eager_load(:local_counterpart).page(params[:page]), {})", "render_path": [{"type":"controller","class":"Admin::CustomEmojisController","method":"index","line":11,"file":"app/controllers/admin/custom_emojis_controller.rb"}], "location": { @@ -160,7 +220,7 @@ "message": "Possible SQL injection", "file": "lib/mastodon/snowflake.rb", "line": 87, - "link": "http://brakemanscanner.org/docs/warning_types/sql_injection/", + "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/", "code": "connection.execute(\" CREATE OR REPLACE FUNCTION timestamp_id(table_name text)\\n RETURNS bigint AS\\n $$\\n DECLARE\\n time_part bigint;\\n sequence_base bigint;\\n tail bigint;\\n BEGIN\\n time_part := (\\n -- Get the time in milliseconds\\n ((date_part('epoch', now()) * 1000))::bigint\\n -- And shift it over two bytes\\n << 16);\\n\\n sequence_base := (\\n 'x' ||\\n -- Take the first two bytes (four hex characters)\\n substr(\\n -- Of the MD5 hash of the data we documented\\n md5(table_name ||\\n '#{SecureRandom.hex(16)}' ||\\n time_part::text\\n ),\\n 1, 4\\n )\\n -- And turn it into a bigint\\n )::bit(16)::bigint;\\n\\n -- Finally, add our sequence number to our base, and chop\\n -- it to the last two bytes\\n tail := (\\n (sequence_base + nextval(table_name || '_id_seq'))\\n & 65535);\\n\\n -- Return the time part and the sequence part. OR appears\\n -- faster here than addition, but they're equivalent:\\n -- time_part has no trailing two bytes, and tail is only\\n -- the last two bytes.\\n RETURN time_part | tail;\\n END\\n $$ LANGUAGE plpgsql VOLATILE;\\n\")", "render_path": null, "location": { @@ -180,7 +240,7 @@ "message": "Render path contains parameter value", "file": "app/views/admin/accounts/index.html.haml", "line": 67, - "link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/", + "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/", "code": "render(action => filtered_accounts.page(params[:page]), {})", "render_path": [{"type":"controller","class":"Admin::AccountsController","method":"index","line":12,"file":"app/controllers/admin/accounts_controller.rb"}], "location": { @@ -191,25 +251,6 @@ "confidence": "Weak", "note": "" }, - { - "warning_type": "Cross-Site Request Forgery", - "warning_code": 7, - "fingerprint": "ab491f72606337a348482d006eb67a3b1616685fd48644d5ac909bbcd62a5000", - "check_name": "ForgerySetting", - "message": "'protect_from_forgery' should be called in WellKnown::HostMetaController", - "file": "app/controllers/well_known/host_meta_controller.rb", - "line": 4, - "link": "http://brakemanscanner.org/docs/warning_types/cross-site_request_forgery/", - "code": null, - "render_path": null, - "location": { - "type": "controller", - "controller": "WellKnown::HostMetaController" - }, - "user_input": null, - "confidence": "High", - "note": "" - }, { "warning_type": "Redirect", "warning_code": 18, @@ -218,7 +259,7 @@ "message": "Possible unprotected redirect", "file": "app/controllers/media_controller.rb", "line": 10, - "link": "http://brakemanscanner.org/docs/warning_types/redirect/", + "link": "https://brakemanscanner.org/docs/warning_types/redirect/", "code": "redirect_to(MediaAttachment.attached.find_by!(:shortcode => ((params[:id] or params[:medium_id]))).file.url(:original))", "render_path": null, "location": { @@ -237,8 +278,8 @@ "check_name": "LinkToHref", "message": "Potentially unsafe model attribute in link_to href", "file": "app/views/admin/accounts/show.html.haml", - "line": 119, - "link": "http://brakemanscanner.org/docs/warning_types/link_to_href", + "line": 138, + "link": "https://brakemanscanner.org/docs/warning_types/link_to_href", "code": "link_to(Account.find(params[:id]).remote_url, Account.find(params[:id]).remote_url)", "render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}], "location": { @@ -256,8 +297,8 @@ "check_name": "Redirect", "message": "Possible unprotected redirect", "file": "app/controllers/remote_follow_controller.rb", - "line": 18, - "link": "http://brakemanscanner.org/docs/warning_types/redirect/", + "line": 19, + "link": "https://brakemanscanner.org/docs/warning_types/redirect/", "code": "redirect_to(RemoteFollow.new(resource_params).subscribe_address_for(Account.find_local!(params[:account_username])))", "render_path": null, "location": { @@ -276,8 +317,8 @@ "check_name": "Render", "message": "Render path contains parameter value", "file": "app/views/admin/reports/index.html.haml", - "line": 25, - "link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/", + "line": 22, + "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/", "code": "render(action => filtered_reports.page(params[:page]), {})", "render_path": [{"type":"controller","class":"Admin::ReportsController","method":"index","line":10,"file":"app/controllers/admin/reports_controller.rb"}], "location": { @@ -288,25 +329,6 @@ "confidence": "Weak", "note": "" }, - { - "warning_type": "Cross-Site Request Forgery", - "warning_code": 7, - "fingerprint": "d4278f04e807ec58a23925f8ab31fad5e84692f2fb9f2f57e7931aff05d57cf8", - "check_name": "ForgerySetting", - "message": "'protect_from_forgery' should be called in WellKnown::WebfingerController", - "file": "app/controllers/well_known/webfinger_controller.rb", - "line": 4, - "link": "http://brakemanscanner.org/docs/warning_types/cross-site_request_forgery/", - "code": null, - "render_path": null, - "location": { - "type": "controller", - "controller": "WellKnown::WebfingerController" - }, - "user_input": null, - "confidence": "High", - "note": "" - }, { "warning_type": "Cross-Site Scripting", "warning_code": 4, @@ -314,8 +336,8 @@ "check_name": "LinkToHref", "message": "Potentially unsafe model attribute in link_to href", "file": "app/views/admin/accounts/show.html.haml", - "line": 150, - "link": "http://brakemanscanner.org/docs/warning_types/link_to_href", + "line": 170, + "link": "https://brakemanscanner.org/docs/warning_types/link_to_href", "code": "link_to(Account.find(params[:id]).outbox_url, Account.find(params[:id]).outbox_url)", "render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}], "location": { @@ -326,6 +348,26 @@ "confidence": "Weak", "note": "" }, + { + "warning_type": "Mass Assignment", + "warning_code": 105, + "fingerprint": "e867661b2c9812bc8b75a5df12b28e2a53ab97015de0638b4e732fe442561b28", + "check_name": "PermitAttributes", + "message": "Potentially dangerous key allowed for mass assignment", + "file": "app/controllers/api/v1/reports_controller.rb", + "line": 42, + "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/", + "code": "params.permit(:account_id, :comment, :forward, :status_ids => ([]))", + "render_path": null, + "location": { + "type": "method", + "class": "Api::V1::ReportsController", + "method": "report_params" + }, + "user_input": ":account_id", + "confidence": "High", + "note": "" + }, { "warning_type": "Dynamic Render Path", "warning_code": 15, @@ -333,10 +375,10 @@ "check_name": "Render", "message": "Render path contains parameter value", "file": "app/views/stream_entries/show.html.haml", - "line": 24, - "link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/", + "line": 23, + "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/", "code": "render(partial => \"stream_entries/#{Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity_type.downcase}\", { :locals => ({ Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity_type.downcase.to_sym => Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity, :include_threads => true }) })", - "render_path": [{"type":"controller","class":"StatusesController","method":"show","line":22,"file":"app/controllers/statuses_controller.rb"}], + "render_path": [{"type":"controller","class":"StatusesController","method":"show","line":30,"file":"app/controllers/statuses_controller.rb"}], "location": { "type": "template", "template": "stream_entries/show" @@ -346,6 +388,6 @@ "note": "" } ], - "updated": "2018-02-16 06:42:53 +0100", - "brakeman_version": "4.0.1" + "updated": "2018-08-18 00:49:25 +0200", + "brakeman_version": "4.2.1" } diff --git a/config/locales/en.yml b/config/locales/en.yml index cc24a02cf..90086103c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -655,11 +655,14 @@ en: publishing: Publishing web: Web remote_follow: - acct: Enter your username@domain you want to follow from + acct: Enter your username@domain you want to act from missing_resource: Could not find the required redirect URL for your account no_account_html: Don't have an account? You can sign up here proceed: Proceed to follow prompt: 'You are going to follow:' + remote_interaction: + proceed: Proceed to interact + prompt: 'You want to interact with this toot:' remote_unfollow: error: Error title: Title diff --git a/config/routes.rb b/config/routes.rb index 2983011d2..fd3b5fe4b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,6 +74,9 @@ Rails.application.routes.draw do get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status + get '/interact/:id', to: 'remote_interaction#new', as: :remote_interaction + post '/interact/:id', to: 'remote_interaction#create' + namespace :settings do resource :profile, only: [:show, :update] resource :preferences, only: [:show, :update] @@ -120,7 +123,7 @@ Rails.application.routes.draw do # Remote follow resource :remote_unfollow, only: [:create] - resource :authorize_follow, only: [:show, :create] + resource :authorize_interaction, only: [:show, :create] resource :share, only: [:show, :create] namespace :admin do diff --git a/spec/controllers/authorize_follows_controller_spec.rb b/spec/controllers/authorize_follows_controller_spec.rb deleted file mode 100644 index 52971c724..000000000 --- a/spec/controllers/authorize_follows_controller_spec.rb +++ /dev/null @@ -1,110 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -describe AuthorizeFollowsController do - render_views - - describe 'GET #show' do - describe 'when signed out' do - it 'redirects to sign in page' do - get :show - - expect(response).to redirect_to(new_user_session_path) - end - end - - describe 'when signed in' do - let(:user) { Fabricate(:user) } - let(:account) { Fabricate(:account, user: user) } - - before do - sign_in(user) - end - - it 'renders error without acct param' do - get :show - - expect(response).to render_template(:error) - end - - it 'renders error when account cant be found' do - service = double - allow(ResolveAccountService).to receive(:new).and_return(service) - allow(service).to receive(:call).with('missing@hostname').and_return(nil) - - get :show, params: { acct: 'acct:missing@hostname' } - - expect(response).to render_template(:error) - expect(service).to have_received(:call).with('missing@hostname') - end - - it 'sets account from url' do - account = Account.new - service = double - allow(FetchRemoteAccountService).to receive(:new).and_return(service) - allow(service).to receive(:call).with('http://example.com').and_return(account) - - get :show, params: { acct: 'http://example.com' } - - expect(response).to have_http_status(200) - expect(assigns(:account)).to eq account - end - - it 'sets account from acct uri' do - account = Account.new - service = double - allow(ResolveAccountService).to receive(:new).and_return(service) - allow(service).to receive(:call).with('found@hostname').and_return(account) - - get :show, params: { acct: 'acct:found@hostname' } - - expect(response).to have_http_status(200) - expect(assigns(:account)).to eq account - end - end - end - - describe 'POST #create' do - describe 'when signed out' do - it 'redirects to sign in page' do - post :create - - expect(response).to redirect_to(new_user_session_path) - end - end - - describe 'when signed in' do - let(:user) { Fabricate(:user) } - let(:account) { Fabricate(:account, user: user) } - - before do - sign_in(user) - end - - it 'shows error when account not found' do - service = double - allow(FollowService).to receive(:new).and_return(service) - allow(service).to receive(:call).with(account, 'user@hostname').and_return(nil) - - post :create, params: { acct: 'acct:user@hostname' } - - expect(service).to have_received(:call).with(account, 'user@hostname') - expect(response).to render_template(:error) - end - - it 'follows account when found' do - target_account = Fabricate(:account) - result_account = double(target_account: target_account) - service = double - allow(FollowService).to receive(:new).and_return(service) - allow(service).to receive(:call).with(account, 'user@hostname').and_return(result_account) - - post :create, params: { acct: 'acct:user@hostname' } - - expect(service).to have_received(:call).with(account, 'user@hostname') - expect(response).to render_template(:success) - end - end - end -end diff --git a/spec/controllers/authorize_interactions_controller_spec.rb b/spec/controllers/authorize_interactions_controller_spec.rb new file mode 100644 index 000000000..81fd9ceb7 --- /dev/null +++ b/spec/controllers/authorize_interactions_controller_spec.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe AuthorizeInteractionsController do + render_views + + describe 'GET #show' do + describe 'when signed out' do + it 'redirects to sign in page' do + get :show + + expect(response).to redirect_to(new_user_session_path) + end + end + + describe 'when signed in' do + let(:user) { Fabricate(:user) } + let(:account) { Fabricate(:account, user: user) } + + before do + sign_in(user) + end + + it 'renders error without acct param' do + get :show + + expect(response).to render_template(:error) + end + + it 'renders error when account cant be found' do + service = double + allow(ResolveAccountService).to receive(:new).and_return(service) + allow(service).to receive(:call).with('missing@hostname').and_return(nil) + + get :show, params: { acct: 'acct:missing@hostname' } + + expect(response).to render_template(:error) + expect(service).to have_received(:call).with('missing@hostname') + end + + it 'sets resource from url' do + account = Account.new + service = double + allow(ResolveURLService).to receive(:new).and_return(service) + allow(service).to receive(:call).with('http://example.com').and_return(account) + + get :show, params: { acct: 'http://example.com' } + + expect(response).to have_http_status(200) + expect(assigns(:resource)).to eq account + end + + it 'sets resource from acct uri' do + account = Account.new + service = double + allow(ResolveAccountService).to receive(:new).and_return(service) + allow(service).to receive(:call).with('found@hostname').and_return(account) + + get :show, params: { acct: 'acct:found@hostname' } + + expect(response).to have_http_status(200) + expect(assigns(:resource)).to eq account + end + end + end + + describe 'POST #create' do + describe 'when signed out' do + it 'redirects to sign in page' do + post :create + + expect(response).to redirect_to(new_user_session_path) + end + end + + describe 'when signed in' do + let!(:user) { Fabricate(:user) } + let!(:account) { user.account } + + before do + sign_in(user) + end + + it 'shows error when account not found' do + service = double + + allow(ResolveAccountService).to receive(:new).and_return(service) + allow(service).to receive(:call).with('user@hostname').and_return(nil) + + post :create, params: { acct: 'acct:user@hostname' } + + expect(response).to render_template(:error) + end + + it 'follows account when found' do + target_account = Fabricate(:account) + service = double + + allow(ResolveAccountService).to receive(:new).and_return(service) + allow(service).to receive(:call).with('user@hostname').and_return(target_account) + + post :create, params: { acct: 'acct:user@hostname' } + + expect(service).to have_received(:call).with('user@hostname') + expect(account.following?(target_account)).to be true + expect(response).to render_template(:success) + end + end + end +end diff --git a/spec/controllers/intents_controller_spec.rb b/spec/controllers/intents_controller_spec.rb index 3dde7f835..ddfd5ea36 100644 --- a/spec/controllers/intents_controller_spec.rb +++ b/spec/controllers/intents_controller_spec.rb @@ -13,7 +13,7 @@ RSpec.describe IntentsController, type: :controller do context 'when host is follow' do let(:uri) { 'web+mastodon://follow?uri=test' } - it { is_expected.to redirect_to authorize_follow_path(acct: 'test') } + it { is_expected.to redirect_to authorize_interaction_path(uri: 'test') } end context 'when host is share' do -- cgit From d010816ba876bf4f749749e9d7432a843e8a1ff9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 18 Aug 2018 03:03:23 +0200 Subject: Fix error when trying to update counters for statuses that are gone (#8251) --- app/models/favourite.rb | 4 ++-- app/models/status.rb | 10 ++++++---- spec/models/status_spec.rb | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/models/favourite.rb b/app/models/favourite.rb index ce7a6a336..17f8c9fa6 100644 --- a/app/models/favourite.rb +++ b/app/models/favourite.rb @@ -32,11 +32,11 @@ class Favourite < ApplicationRecord private def increment_cache_counters - status.increment_count!(:favourites_count) + status&.increment_count!(:favourites_count) end def decrement_cache_counters return if association(:status).loaded? && (status.marked_for_destruction? || status.marked_for_mass_destruction?) - status.decrement_count!(:favourites_count) + status&.decrement_count!(:favourites_count) end end diff --git a/app/models/status.rb b/app/models/status.rb index 2eed33659..533d12354 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -396,6 +396,8 @@ class Status < ApplicationRecord private def update_status_stat!(attrs) + return if marked_for_destruction? || destroyed? + record = status_stat || build_status_stat record.update(attrs) end @@ -456,8 +458,8 @@ class Status < ApplicationRecord Account.where(id: account_id).update_all('statuses_count = COALESCE(statuses_count, 0) + 1') end - reblog.increment_count!(:reblogs_count) if reblog? - thread.increment_count!(:replies_count) if in_reply_to_id.present? && (public_visibility? || unlisted_visibility?) + reblog&.increment_count!(:reblogs_count) if reblog? + thread&.increment_count!(:replies_count) if in_reply_to_id.present? && (public_visibility? || unlisted_visibility?) end def decrement_counter_caches @@ -469,7 +471,7 @@ class Status < ApplicationRecord Account.where(id: account_id).update_all('statuses_count = GREATEST(COALESCE(statuses_count, 0) - 1, 0)') end - reblog.decrement_count!(:reblogs_count) if reblog? - thread.decrement_count!(:replies_count) if in_reply_to_id.present? && (public_visibility? || unlisted_visibility?) + reblog&.decrement_count!(:reblogs_count) if reblog? + thread&.decrement_count!(:replies_count) if in_reply_to_id.present? && (public_visibility? || unlisted_visibility?) end end diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index b3e475d99..d03005107 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -182,6 +182,27 @@ RSpec.describe Status, type: :model do reblog.destroy expect(subject.reblogs_count).to eq 0 end + + it 'does not fail when original is deleted before reblog' do + reblog = Fabricate(:status, account: bob, reblog: subject) + expect(subject.reblogs_count).to eq 1 + expect { subject.destroy }.to_not raise_error + expect(Status.find_by(id: reblog.id)).to be_nil + end + end + + describe '#replies_count' do + it 'is the number of replies' do + reply = Fabricate(:status, account: bob, thread: subject) + expect(subject.replies_count).to eq 1 + end + + it 'is decremented when reply is removed' do + reply = Fabricate(:status, account: bob, thread: subject) + expect(subject.replies_count).to eq 1 + reply.destroy + expect(subject.replies_count).to eq 0 + end end describe '#favourites_count' do -- cgit From 85bb32c410a975bf6154a78a82797f82713e2428 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 18 Aug 2018 12:48:27 +0200 Subject: Add "sign in to participate" message to public toot page (#8200) --- app/javascript/styles/mastodon/stream_entries.scss | 12 ++++++++---- app/views/stream_entries/_status.html.haml | 6 ++++++ config/locales/en.yml | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/javascript/styles/mastodon/stream_entries.scss b/app/javascript/styles/mastodon/stream_entries.scss index 03bbd84db..5aa809f76 100644 --- a/app/javascript/styles/mastodon/stream_entries.scss +++ b/app/javascript/styles/mastodon/stream_entries.scss @@ -37,7 +37,8 @@ &:last-child { .detailed-status, - .status { + .status, + .load-more { border-bottom: 0; border-radius: 0 0 4px 4px; } @@ -45,13 +46,15 @@ &:first-child { .detailed-status, - .status { + .status, + .load-more { border-radius: 4px 4px 0 0; } &:last-child { .detailed-status, - .status { + .status, + .load-more { border-radius: 4px; } } @@ -59,7 +62,8 @@ @media screen and (max-width: 740px) { .detailed-status, - .status { + .status, + .load-more { border-radius: 0 !important; } } diff --git a/app/views/stream_entries/_status.html.haml b/app/views/stream_entries/_status.html.haml index 320c9bc4f..92003a48f 100644 --- a/app/views/stream_entries/_status.html.haml +++ b/app/views/stream_entries/_status.html.haml @@ -53,3 +53,9 @@ - if @next_descendant_thread .entry{ class: entry_classes } = link_to_more short_account_status_url(status.account.username, status, since_descendant_thread_id: @max_descendant_thread_id - 1) + +- if include_threads && !embedded_view? && !user_signed_in? + .entry{ class: entry_classes } + = link_to new_user_session_path, class: 'load-more load-gap' do + = fa_icon 'comments' + = t('statuses.sign_in_to_participate') diff --git a/config/locales/en.yml b/config/locales/en.yml index 90086103c..66ab8f10a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -746,6 +746,7 @@ en: private: Non-public toot cannot be pinned reblog: A boost cannot be pinned show_more: Show more + sign_in_to_participate: Sign in to participate in the conversation title: '%{name}: "%{quote}"' visibilities: private: Followers-only -- cgit From 298ee84488758fc08a0ae9233e04c9637aa2fe02 Mon Sep 17 00:00:00 2001 From: M Somerville Date: Sat, 18 Aug 2018 11:50:32 +0100 Subject: Fix #8264 - Do not override ctrl/cmd+click. (#8265) This includes clicks on hashtags, mentions, display names and media in the timeline; and usernames in reply-indicator, detailed status, and the boost modal. --- app/javascript/mastodon/components/media_gallery.js | 2 +- app/javascript/mastodon/components/status.js | 2 +- app/javascript/mastodon/components/status_content.js | 4 ++-- .../mastodon/features/compose/components/reply_indicator.js | 2 +- app/javascript/mastodon/features/status/components/detailed_status.js | 2 +- app/javascript/mastodon/features/ui/components/boost_modal.js | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/components/media_gallery.js b/app/javascript/mastodon/components/media_gallery.js index 1d351279f..63bc4a59b 100644 --- a/app/javascript/mastodon/components/media_gallery.js +++ b/app/javascript/mastodon/components/media_gallery.js @@ -50,7 +50,7 @@ class Item extends React.PureComponent { handleClick = (e) => { const { index, onClick } = this.props; - if (e.button === 0) { + if (e.button === 0 && !(e.ctrlKey || e.metaKey)) { e.preventDefault(); onClick(index); } diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 922b609ec..e653906f1 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -65,7 +65,7 @@ export default class Status extends ImmutablePureComponent { } handleAccountClick = (e) => { - if (this.context.router && e.button === 0) { + if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) { const id = e.currentTarget.getAttribute('data-id'); e.preventDefault(); this.context.router.history.push(`/accounts/${id}`); diff --git a/app/javascript/mastodon/components/status_content.js b/app/javascript/mastodon/components/status_content.js index 9b86592f6..81013747e 100644 --- a/app/javascript/mastodon/components/status_content.js +++ b/app/javascript/mastodon/components/status_content.js @@ -64,7 +64,7 @@ export default class StatusContent extends React.PureComponent { } onMentionClick = (mention, e) => { - if (this.context.router && e.button === 0) { + if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) { e.preventDefault(); this.context.router.history.push(`/accounts/${mention.get('id')}`); } @@ -73,7 +73,7 @@ export default class StatusContent extends React.PureComponent { onHashtagClick = (hashtag, e) => { hashtag = hashtag.replace(/^#/, '').toLowerCase(); - if (this.context.router && e.button === 0) { + if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) { e.preventDefault(); this.context.router.history.push(`/timelines/tag/${hashtag}`); } diff --git a/app/javascript/mastodon/features/compose/components/reply_indicator.js b/app/javascript/mastodon/features/compose/components/reply_indicator.js index 5b4b81eac..6f358a98b 100644 --- a/app/javascript/mastodon/features/compose/components/reply_indicator.js +++ b/app/javascript/mastodon/features/compose/components/reply_indicator.js @@ -30,7 +30,7 @@ export default class ReplyIndicator extends ImmutablePureComponent { } handleAccountClick = (e) => { - if (e.button === 0) { + if (e.button === 0 && !(e.ctrlKey || e.metaKey)) { e.preventDefault(); this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`); } diff --git a/app/javascript/mastodon/features/status/components/detailed_status.js b/app/javascript/mastodon/features/status/components/detailed_status.js index 417719004..12ffb7579 100644 --- a/app/javascript/mastodon/features/status/components/detailed_status.js +++ b/app/javascript/mastodon/features/status/components/detailed_status.js @@ -26,7 +26,7 @@ export default class DetailedStatus extends ImmutablePureComponent { }; handleAccountClick = (e) => { - if (e.button === 0) { + if (e.button === 0 && !(e.ctrlKey || e.metaKey)) { e.preventDefault(); this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`); } diff --git a/app/javascript/mastodon/features/ui/components/boost_modal.js b/app/javascript/mastodon/features/ui/components/boost_modal.js index 0e9592c97..1c90d10dd 100644 --- a/app/javascript/mastodon/features/ui/components/boost_modal.js +++ b/app/javascript/mastodon/features/ui/components/boost_modal.js @@ -37,7 +37,7 @@ export default class BoostModal extends ImmutablePureComponent { } handleAccountClick = (e) => { - if (e.button === 0) { + if (e.button === 0 && !(e.ctrlKey || e.metaKey)) { e.preventDefault(); this.props.onClose(); this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`); -- cgit