Skip to content

Commit

Permalink
prevent ingestion of own DLV and ACK msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
tschudin committed Aug 6, 2024
1 parent 126d1b6 commit cd4fd7d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions android/tinySSB/app/src/main/assets/web/tremola.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,9 @@ function b2f_new_event(e) { // incoming SSB log event: we get map with three ent

if (e.public) {
if (e.public[0] == 'TAV') { // text and voice
console.log("new post 0 ", tremola)
// console.log("new post 0 ", tremola)
var conv_name = "ALL";
if (!(conv_name in tremola.chats)) { // create new conversation if needed
console.log("xx")
tremola.chats[conv_name] = {
"alias": "Public channel X", "posts": {},
"members": ["ALL"], "touched": Date.now(), "lastRead": 0,
Expand Down Expand Up @@ -646,14 +645,14 @@ function b2f_new_event(e) { // incoming SSB log event: we get map with three ent
if (a[0] == 'TAV')
rcpts = a[5];
else if (a[0] == 'DLV' || a[0] == 'ACK')
rcpts = [e.header.fid, myId]
if (e.header.fid != myId) // ignore our own confirmation msgs
rcpts = [e.header.fid, myId]
if (rcpts != null) {
var conv_name = recps2nm(rcpts)
console.log("conv_name " + JSON.stringify(conv_name))
// console.log("conv_name " + JSON.stringify(conv_name))
if (!(conv_name in tremola.chats)) { // create new conversation if needed
console.log("xx")
tremola.chats[conv_name] = {
"alias": recps2display(rctps), "posts": {},
"alias": recps2display(rcpts), "posts": {},
"members": rcpts, "touched": Date.now(), "lastRead": 0,
"timeline": new Timeline()
};
Expand All @@ -663,7 +662,6 @@ function b2f_new_event(e) { // incoming SSB log event: we get map with three ent
let ch = tremola.chats[conv_name];

if (a[0] == 'DLV' || a[0] == 'ACK') { // remote delivery notification
console.log(JSON.stringify(ch.posts))
if (e.header.fid != myId && ch.members.length == 2 && a[1] in ch.posts) { // only for person-to-person
var p = ch.posts[a[1]];
if (p.status != 'ACC') // prevent downgrading to DLV
Expand All @@ -680,7 +678,7 @@ function b2f_new_event(e) { // incoming SSB log event: we get map with three ent
// console.log(`chat add tips ${a[1]}`)
ch.timeline.add(e.header.ref, a[1])

console.log("new priv post 1 ", tremola)
// console.log("new priv post 1 ", tremola)
// console.log("new priv post 1 ", ch)
if (!(e.header.ref in ch.posts)) { // new post
var p = {
Expand Down

0 comments on commit cd4fd7d

Please sign in to comment.