source: Klonkt/src/views/pages/messages.ejs@ 6eab7e9

main
Last change on this file since 6eab7e9 was ad6f62a, checked in by Robin <roboburr@โ€ฆ>, 7 weeks ago

Guardian 2: zwaai-badge in Berichten + snelle antwoorden (item 3 af)

De ontvangende ward ziet een zwaai nu als zodanig: in Berichten staat "X ๐Ÿ‘‹
zwaaide naar je" met snelle-antwoord-knoppen (Wat leuk! / Bel me even / ๐Ÿ‘‹ Terug).
Zo kan het kind terugreageren zonder ooit te publiceren: het antwoord is een prive
direct-note terug naar de guardian (zelfde shaer:wave-leg, cross-instance met
retry). Alleen zichtbaar op een echte zwaai (ap_mentions.wave) en alleen als je
mag schrijven (canMutate).

Changed files:
src/services/ActivityPubService.js

  • getNotifications: mention draagt nu wave + actorUri mee

src/views/partials/msg-item.ejs

  • zwaai-label + quick-reply-formulier (3 voorgebakken knoppen)

src/routes/posts.js

  • POST /messages/quick-reply: canned prive-note terug naar de zwaaier

src/views/pages/messages.ejs

  • success-melding wave_sent

src/services/i18n.js

  • msg.waved_at_you / wave_r1 / wave_r2 / wave_back / wave_sent (nl/en/de)

remarks: npm test 167/167; quick-reply auth-gated (requireSiteManager). Hiermee is
item 3 (DM/zwaai) rond: guardian zwaait, ward ziet het en antwoordt met een tik,
niemand publiceert.

-robo
Co-Authored-By: Claude Opus 4.8 <noreply@โ€ฆ>

  • Property mode set to 100644
File size: 13.3 KB
RevLineย 
[f1a23b8]1<div class="msg-wrap">
2 <%- include('../partials/fedi-tabs', { active: 'berichten' }) %>
3 <h1 class="msg-title"><%= t('msg.title') %></h1>
[ad6f62a]4 <% if (typeof success !== 'undefined' && success) { %><div class="alert alert-success"><%= success === 'guardian_accepted' ? t('msg.guard_accepted') : (success === 'guardian_rejected' ? t('msg.guard_rejected') : (success === 'wave_sent' ? t('msg.wave_sent') : success)) %></div><% } %>
[e84ce32]5 <% if (typeof error !== 'undefined' && error) { %><div class="alert alert-error"><%= error === 'guardianship' ? t('msg.guard_failed') : error %></div><% } %>
6
7 <%# FEP-633c: a pending guardianship offer is a special message: the kid
8 answers here (accept/reject travels the same C2S pipeline as the apps). %>
9 <% if (typeof guardianOffers !== 'undefined' && guardianOffers.length) { %>
10 <% guardianOffers.forEach(function(o){ %>
11 <div class="alert" style="display:flex;align-items:center;gap:12px;flex-wrap:wrap;border-left:3px solid #ff6b35;">
12 <span style="font-size:1.4em;">&#128735;</span>
13 <div style="flex:1;min-width:200px;">
[780a7c6]14 <strong><%= o['shaer:candidateHandle'] || o['shaer:candidate'] %></strong><br>
[e84ce32]15 <span><%= t('msg.guard_offer') %></span>
16 </div>
17 <form method="post" action="<%= (typeof moreBase !== 'undefined' ? moreBase : '') %>/messages/guardianship" style="display:flex;gap:8px;">
[780a7c6]18 <input type="hidden" name="offer" value="<%= o.id %>">
[e84ce32]19 <button class="btn" type="submit" name="answer" value="accept"><%= t('msg.guard_accept') %></button>
20 <button class="btn" type="submit" name="answer" value="reject" style="opacity:.7;"><%= t('msg.guard_reject') %></button>
21 </form>
22 </div>
23 <% }); %>
24 <% } %>
[f1a23b8]25
[fcd6964]26 <%# FEP-633c ยง2: the ward always sees who guards it (committed relations). %>
27 <% if (typeof myGuardians !== 'undefined' && myGuardians.length) { %>
28 <div class="alert" style="display:flex;align-items:center;gap:12px;flex-wrap:wrap;border-left:3px solid #35a2ff;">
29 <span style="font-size:1.4em;">&#128737;</span>
30 <div style="flex:1;min-width:200px;">
31 <strong><%= t('msg.guardians_label') %></strong><br>
32 <span><%= myGuardians.map(function(g){ return g.handle; }).join(', ') %></span>
33 </div>
34 </div>
35 <% } %>
36
[f1a23b8]37 <div class="msg-filters" role="tablist" aria-label="<%= t('msg.title') %>">
38 <button type="button" class="msg-chip is-on" data-show="all"><%= t('msg.filter_all') %></button>
[8ed65a6]39 <button type="button" class="msg-chip" data-show="msgs"><%= t('msg.filter_msgs') %></button>
[f1a23b8]40 <button type="button" class="msg-chip" data-show="conv"><%= t('msg.filter_conv') %></button>
41 <button type="button" class="msg-chip" data-show="act"><%= t('msg.filter_act') %></button>
[8ed65a6]42 <button type="button" class="msg-chip" data-show="mod"><%= t('msg.filter_mod') %></button>
[f1a23b8]43 <button type="button" class="msg-chip" data-show="sent"><%= t('msg.filter_sent') %></button>
44 </div>
[8ed65a6]45 <div class="msg-search">
46 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
47 <input type="search" id="msg-q" placeholder="<%= t('msg.search_ph') %>" autocomplete="off" spellcheck="false" aria-label="<%= t('msg.search_ph') %>">
48 </div>
[f1a23b8]49
50 <% var _seen = (typeof seenAt !== 'undefined' && seenAt) ? seenAt : 0; %>
51 <% if (!items || !items.length) { %>
52 <p class="msg-empty"><%= t('msg.empty') %></p>
53 <% } else { %>
[1485933]54 <ul class="msg-list" data-show="all" id="msg-list">
55 <% items.forEach(function(n){ %><%- include('../partials/msg-item', { n: n, seen: _seen }) %><% }); %>
[f1a23b8]56 </ul>
[8ed65a6]57 <p class="msg-nomatch" hidden><%= t('msg.no_match') %></p>
[1485933]58 <%- include('../partials/load-more', { hasMore: hasMore, nextOffset: nextOffset, moreBase: moreBase, moreTarget: '#msg-list', morePath: '/messages' }) %>
[f1a23b8]59 <% } %>
60
61 <%# Interact bookmarklet โ€” moved here from the old Reacties page. %>
62 <details class="msg-bm">
63 <summary><%= t('fedi.bm_label') %></summary>
64 <p class="msg-bm-help"><%= t('fedi.bm_help') %></p>
65 <a class="fedi-bm-btn" id="fedi-bm-btn" href="#" draggable="true" title="<%= t('fedi.bm_help') %>">
66 <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/></svg>
67 <%= t('fedi.bm_label') %>
68 </a>
69 </details>
70</div>
71
72<script>
73(function () {
74 if (window.__msgWired) return; window.__msgWired = true;
[8ed65a6]75
76 // Filtering: kind chip AND free-text search, combined in JS (search over the
77 // sender and the rendered message text). Empty search + "all" = show all.
78 var list = document.querySelector('.msg-list');
79 var noMatch = document.querySelector('.msg-nomatch');
80 var q = document.getElementById('msg-q');
81 var kind = 'all';
[1485933]82 var items = [];
83 function indexItem(li) {
84 // Index once: sender + message body + linked post title + poll text.
[8ed65a6]85 var body = li.querySelector('.msg-content');
86 var post = li.querySelector('.msg-post');
[544e9c2]87 var poll = li.querySelector('.msg-poll');
[8ed65a6]88 li._search = ((li.getAttribute('data-who') || '') + ' ' +
[544e9c2]89 (body ? body.textContent : '') + ' ' + (post ? post.textContent : '') + ' ' +
90 (poll ? poll.textContent : '')).toLowerCase();
[1485933]91 }
92 // Re-collect + index; called on load and after each "Load more" append so new
93 // items join the filter/search (and inherit the active chip via apply()).
94 function reindex() {
95 items = list ? Array.prototype.slice.call(list.querySelectorAll('.msg-item')) : [];
96 items.forEach(function (li) { if (!li._search) indexItem(li); });
97 }
98 reindex();
[8ed65a6]99 function apply() {
100 if (!list) return;
101 var term = (q && q.value || '').trim().toLowerCase();
102 var shown = 0;
103 items.forEach(function (li) {
104 var ok = (kind === 'all' || li.getAttribute('data-kind') === kind) &&
105 (!term || li._search.indexOf(term) !== -1);
106 li.style.display = ok ? '' : 'none';
107 if (ok) shown++;
108 });
109 if (noMatch) noMatch.hidden = shown !== 0;
110 }
[f1a23b8]111 document.addEventListener('click', function (e) {
112 var chip = e.target.closest('.msg-chip'); if (!chip) return;
[8ed65a6]113 kind = chip.getAttribute('data-show');
[f1a23b8]114 document.querySelectorAll('.msg-chip').forEach(function (c) { c.classList.toggle('is-on', c === chip); });
[8ed65a6]115 apply();
[f1a23b8]116 });
[8ed65a6]117 if (q) q.addEventListener('input', apply);
[1485933]118 // After a "Load more" append (htmx), index the new rows and re-apply the filter.
119 document.body.addEventListener('htmx:afterSettle', function (e) {
120 if (e.target && e.target.id === 'msg-list') { reindex(); apply(); }
121 });
[8ed65a6]122
[f1a23b8]123 var a = document.getElementById('fedi-bm-btn');
124 if (a) {
125 a.setAttribute('href', "javascript:void(window.open('" + location.origin + "/authorize_interaction?uri='+encodeURIComponent(window.location.href)))");
126 a.addEventListener('click', function (e) { e.preventDefault(); a.classList.add('nudge'); setTimeout(function(){ a.classList.remove('nudge'); }, 600); });
127 }
128})();
129</script>
130
131<style>
132 .msg-wrap { max-width: 640px; margin: 1rem auto; padding: 0 1rem; }
133 .msg-title { margin: 0 0 .9rem; }
134 .msg-empty { color: var(--ink-soft, #888); }
135
136 .msg-filters { display: flex; gap: .4rem; margin: 0 0 1.1rem; flex-wrap: wrap; }
137 .msg-chip { border: 1px solid color-mix(in srgb, var(--ink, #000) 16%, transparent); background: none;
138 color: var(--ink-soft, #888); font: inherit; font-size: .84rem; font-weight: 600;
139 padding: .3rem .85rem; border-radius: 999px; cursor: pointer; }
140 .msg-chip.is-on { background: var(--accent, #06c); border-color: var(--accent, #06c); color: #fff; }
141
[8ed65a6]142 .msg-search { display: flex; align-items: center; gap: .5rem; margin: 0 0 1.1rem;
143 padding: .45rem .7rem; border-radius: 10px;
144 border: 1px solid color-mix(in srgb, var(--ink, #000) 16%, transparent); }
145 .msg-search:focus-within { border-color: var(--accent, #06c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #06c) 18%, transparent); }
146 .msg-search svg { width: 16px; height: 16px; color: var(--ink-soft, #888); flex-shrink: 0; }
147 .msg-search input { flex: 1; border: none; background: none; color: inherit; font: inherit; outline: none; min-width: 0; }
148 .msg-nomatch { color: var(--ink-soft, #888); text-align: center; padding: 1.2rem 0; }
149
[f1a23b8]150 .msg-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .55rem; }
151
152 .msg-item { display: flex; gap: .8rem; padding: .85rem .95rem; border-radius: 14px; align-items: flex-start;
153 background: color-mix(in srgb, var(--ink, #000) 3.5%, transparent);
154 border: 1px solid color-mix(in srgb, var(--ink, #000) 9%, transparent);
155 transition: border-color .15s ease, box-shadow .15s ease; }
156 .msg-item:hover { border-color: color-mix(in srgb, var(--accent, #888) 30%, transparent);
157 box-shadow: 0 2px 12px color-mix(in srgb, var(--ink, #000) 6%, transparent); }
158 .msg-item.is-new { border-color: color-mix(in srgb, var(--accent, #06c) 45%, transparent);
159 background: color-mix(in srgb, var(--accent, #06c) 4%, transparent); }
160 .msg-sent { border-left: 3px solid color-mix(in srgb, var(--accent, #06c) 55%, transparent); }
161
162 .msg-av { position: relative; flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%;
163 display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
164 background: color-mix(in srgb, var(--accent, #888) 16%, transparent); color: var(--accent, #06c); overflow: visible; }
165 .msg-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: #fff; }
166 .msg-av-sent svg { width: 17px; height: 17px; }
167 .msg-dot { position: absolute; right: -3px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%;
168 display: inline-flex; align-items: center; justify-content: center;
169 border: 2px solid var(--paper, #fff); background: var(--accent, #06c); color: #fff; }
170 .msg-dot svg { width: 10px; height: 10px; }
171 .msg-dot-like { background: #e8b04b; } .msg-dot-boost { background: #2fa85a; }
172 .msg-dot-report { background: #c0392b; } .msg-dot-mention { background: #8e6cf0; }
173
174 .msg-body { flex: 1; min-width: 0; }
175 .msg-line { display: flex; align-items: baseline; gap: .4rem; }
176 .msg-who { font-weight: 700; color: var(--ink, inherit); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
177 a.msg-who:hover { text-decoration: underline; }
178 .msg-handle { color: var(--ink-soft, #888); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
179 .msg-new { width: 8px; height: 8px; border-radius: 50%; background: var(--accent, #06c); flex: 0 0 auto; align-self: center; }
180 .msg-time { color: var(--ink-soft, #999); font-size: .76rem; margin-left: auto; flex: 0 0 auto; white-space: nowrap; }
181 .msg-what { color: var(--ink-soft, #aaa); margin-top: .12rem; line-height: 1.4; }
182 .msg-what .msg-post { color: var(--accent, #06c); font-weight: 600; margin-left: .25rem; }
183 .msg-priv { display: inline-block; margin-left: .3rem; padding: .05rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700;
184 background: color-mix(in srgb, #8e6cf0 14%, transparent); color: #8e6cf0; }
185 .msg-content { margin: .45rem 0 0; padding: .55rem .75rem; border-radius: 10px; line-height: 1.5;
186 background: color-mix(in srgb, var(--ink, #000) 4%, transparent); color: var(--ink, inherit); overflow-wrap: anywhere; }
187 .msg-content p { margin: .2rem 0; } .msg-content p:first-child { margin-top: 0; } .msg-content p:last-child { margin-bottom: 0; }
188
[544e9c2]189 .msg-poll { margin: .5rem 0 0; display: flex; flex-direction: column; gap: .4rem; }
190 .msg-poll-opt { display: flex; flex-direction: column; gap: .2rem; }
191 .msg-poll-top { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; }
192 .msg-poll-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
193 .msg-poll-pct { font-variant-numeric: tabular-nums; color: var(--ink-soft, #888); flex-shrink: 0; }
194 .msg-poll-bar { height: 7px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--ink, #000) 10%, transparent); }
195 .msg-poll-bar span { display: block; height: 100%; border-radius: 999px; background: var(--accent, #06c); }
196 .msg-poll-total { font-size: .78rem; color: var(--ink-soft, #888); margin-top: .1rem; }
197
[f1a23b8]198 .msg-actions { display: flex; gap: .7rem; align-items: center; margin-top: .45rem; }
199 .msg-edit summary { cursor: pointer; font-size: .8rem; color: var(--ink-soft, #888); font-weight: 600; }
200 .msg-edit-form { margin-top: .4rem; display: flex; flex-direction: column; gap: .4rem; }
201 .msg-edit-form textarea { width: 100%; font: inherit; padding: .5rem .65rem; border-radius: 8px;
202 border: 1px solid color-mix(in srgb, var(--ink, #000) 16%, transparent); background: transparent; color: var(--ink, inherit); }
203 .msg-del { background: none; border: none; padding: 0; font: inherit; font-size: .8rem; font-weight: 600;
204 color: var(--ink-soft, #888); cursor: pointer; }
205 .msg-del:hover { color: #c0392b; }
206
207 .msg-bm { margin: 1.4rem 0 0; border-top: 1px solid color-mix(in srgb, var(--ink, #000) 10%, transparent); padding-top: .8rem; }
208 .msg-bm summary { cursor: pointer; color: var(--ink-soft, #888); font-weight: 600; font-size: .88rem; }
209 .msg-bm-help { color: var(--ink-soft, #888); font-size: .82rem; line-height: 1.5; margin: .5rem 0 .6rem; }
210</style>
Note: See TracBrowser for help on using the repository browser.