-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New message notification #533
base: main
Are you sure you want to change the base?
Conversation
@jsuchal nie je to zatial poriadne otestovane, kedze sa blbo testuje (potrebujem vyrobit na strane UPVS message na prevzatie). Fungovalo to na inom triggri, takze principialne by fungovat malo. Tak spravme tak, ze najprv kuknes koncept, ak zhruba OK, poprosim Luciu o zopar sprav, a otestujem a spravim nejake videjko z funkcnosti. Dikes |
@@ -4,3 +4,8 @@ | |||
thread_messages: @thread_messages, | |||
thread_last_message_draft_id: @thread_last_message_draft_id | |||
) %> | |||
<% if @notify %> | |||
<%= turbo_frame_tag :new_messages_frame, target: "_top" do %> | |||
<%= turbo_stream_from @message_thread %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security tu je ako riesene?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security je postavene na predpokladoch (ktore som 100% neoveroval, ale verim, ze platia)
- Ked uz vidim vlakno, tak budem moct vidiet aj spravu, ktora pride po prevzati dorucenky
- Takyto subscription sa urobi len ked vidim dane vlakno (a subscription je zavesene na ID daneho vlakna), neviem ho vyrobit nijako odboku
- Jedine, co mi vysledok danej subscription da, je info o vzniku novej spravy a jej ID/linku na nu, co by nemalo nijako pomoct cloveku, co na tu spravu/vlakno nema pristup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Myslim, ze minimalne taketo nieco bude treba https://guides.rubyonrails.org/action_cable_overview.html#server-side-components-connections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Podla dokumentacie je toto doriesene v tomto turbo_stream_from, resp. v Turbo::Streamable, ak spravne chapem nasledovne:
https://rubydoc.info/github/hotwired/turbo-rails/Turbo%2FStreamsHelper:turbo_stream_from
The stream name being generated is safe to embed in the HTML sent to a user without fear of tampering, as it is signed using Turbo.signed_stream_verifier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stage-rl problem nie je tempering obsahu ale to, ze niekto sa napichne na stream a bude citat nieco co nema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skor si myslim, ze to maju vyriesene railsaci vnutri. Ale keby aj nie, max sa utocnik dozvie linku na vlakno, na ktore nema pravo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nemaju to doriesene (nemaju preco lebo turbo stream by default funguje ako public vec), treba doriesit autentifikaciu na urovni vytvarania channel/connection. Je to ale par riadkov https://binarysolo.blog/is-your-action-cable-connection-secure-when-using-turbo/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Treba to zovseobecnit.
@stage-rl s tymto sa ako dari, nepotrebujes nic od nas? |
Tak cakal som nejaku reakciu na tie moje elaboraty, ale OK, nejako to spravim podla poziadavky a uvidime |
…sko-digital/govbox-pro into feature/new_message_alert
Gemfile
Outdated
@@ -5,6 +5,7 @@ ruby '3.3.0' | |||
gem 'rails', '~> 7.1' | |||
gem 'rails-i18n' | |||
|
|||
gem 'actioncable-enhanced-postgresql-adapter' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ak spravne pozeram, tak pod 8000 bytes sa to sprava rovnako ako default adapter, cize sem nemusime tahat zavislost na nejaky deravy mrtvy gem 2 roky stary. (partial co posielas mas < 2000 bytes)
@@ -4,3 +4,6 @@ | |||
thread_messages: @thread_messages, | |||
thread_last_message_draft_id: @thread_last_message_draft_id | |||
) %> | |||
<%= turbo_frame_tag :new_messages_frame, target: "_top" do %> | |||
<%= turbo_stream_from @message_thread %> | |||
<% end %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zaujimave, ze ordering gemov tvoj linter riesi ale newline na konci nie. :)
</div> | ||
<div class="ml-3"> | ||
<p class="text-sm font-medium text-blue-800"> | ||
<%= link_to message_thread_path(message.thread), class: "underline" do %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tu nepotrebujes block tu ti staci link_to nazov, url, zvysok
<button | ||
type="button" | ||
data-action="dismissible-alert#dismiss" | ||
class="inline-flex rounded-md bg-blue-50 text-blue-500 hover:bg-blue-100 focus:ring-blue-600 focus:ring-offset-blue-50 p-1.5 focus:outline-none focus:ring-2 focus:ring-offset-2" | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tomuto formatovaniu som nikdy neprisiel na chut.
|
||
sign_in_as(:admin) | ||
end | ||
test 'should notify user on new message' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tu dajme newline medzi testy
app/models/message.rb
Outdated
@@ -46,6 +46,9 @@ class Message < ApplicationRecord | |||
|
|||
after_update_commit ->(message) { EventBus.publish(:message_changed, message) } | |||
after_destroy_commit ->(message) { EventBus.publish(:message_destroyed, message) } | |||
after_create_commit do |message| | |||
broadcast_render_later_to message.thread, partial: "messages/new_message_alert", locals: { message: message } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do ktorej fronty sa toto zaradi? Beriem to tak, ze by to malo mat dost vysoku prioritu kedze to je userfacing.
|
||
test: | ||
adapter: test | ||
adapter: enhanced_postgresql | ||
|
||
production: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V produkcii sa odporuca to bezat standalone, ale nemyslim si ze tu bude nejaky velky traffic ze by nas to malo trapit. https://guides.rubyonrails.org/action_cable_overview.html#running-standalone-cable-servers cc @celuchmarek co myslis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mas aj video/screen ako to vyzera?
No description provided.