Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

New message notification #533

wants to merge 2 commits into from

Conversation

stage-rl
Copy link
Collaborator

@stage-rl stage-rl commented Jan 5, 2025

No description provided.

@stage-rl stage-rl requested a review from jsuchal January 6, 2025 09:26
@stage-rl
Copy link
Collaborator Author

stage-rl commented Jan 6, 2025

@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

@@ -39,7 +39,7 @@ def authorize_delivery_notification

@message.transaction do
if Govbox::AuthorizeDeliveryNotificationAction.run(@message)
redirect_to message_thread_path(@message.thread), notice: 'Správa bola zaradená na prevzatie'
redirect_to message_thread_path(@message.thread, notify: true), notice: 'Správa bola zaradená na prevzatie'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je nejaky specialny dovod preco chceme notify len pre spravy, pri preberani takto cez gui? Imho by sa to malo diat uplne vzdy a dokonca bysom povedal, ze aj pre ine spravy ako dorucenky. Viazal by som to na event "new_message_created"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To je smutne nedorozumenie ;-) Aj ja som to povodne chcel takto spravit, ale sme to diskutovali na hackday, a moje chapanie bolo, ze to by sa zahlcovalo pri klientoch, co maju stovky/tisice sprav za den, a teda chceme to len pre tieto specificke druhy sprav.

Spravit to pre vsetky je na jednej strane jednoduchsie (nepotrebujeme specificke listenery na konkretnych vlaknach), na druhej strane narocnejsie prave na bezpecnost, vid aj tvoj druhy comment. V tomto pripade by som musel pri kazdej sprave vlastne pre kazdeho (prihlaseneho) pouzivatela vyhodnotit, ci ma alebo nema pravo vidiet danu spravu, a teda, ci je dana notifikacia pre neho relevantna alebo nie. A nasledne broadcastnut event pre kazdeho pouzivatela, ktory ju ma vidiet. Ak toto vidis inak, tak daj vediet.

Este si viem predstavit, ze by sa subscription robil na urovni, ze kazdy prihlaseny user sa subscribuje na vsetky tagy, ktore ma moznost vidiet. A event by sa teda vystreloval pre vsetky tagy, ktore su na vlakne, do ktoreho pribudla sprava. Tu by bolo potrebne zabezpecit, aby sa ostatne pravidla (najma na vyhodnocovanie automation rules, konkretne priradenie tagov) vyhodnotili az pred tym, ako zbehne toto pravidlo. Plus by bolo potrebne zabezpecit, ze ak vidim spravu kvoli dvom roznym tagom, tak sa mi ten event nezduplikuje (toto si aktualne neviem predstavit ako).

Tolko aktualny vystup mojho mozgu k danej teme ;-)

@@ -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 %>
Copy link
Member

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?

Copy link
Collaborator Author

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)

  1. Ked uz vidim vlakno, tak budem moct vidiet aj spravu, ktora pride po prevzati dorucenky
  2. Takyto subscription sa urobi len ked vidim dane vlakno (a subscription je zavesene na ID daneho vlakna), neviem ho vyrobit nijako odboku
  3. 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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

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

Copy link
Member

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.

Copy link
Member

@jsuchal jsuchal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Treba to zovseobecnit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants