AnthyG / ThunderWave

A chat for ZeroNet
http://127.0.0.1:43110/1CWkZv7fQAKxTVjZVrLZ8VHcrN6YGGcdky/
15 stars 3 forks source link

Notifications system #36

Open danimesq opened 7 years ago

danimesq commented 7 years ago

Show these notifications on:

AnthyG commented 7 years ago

What's the "special tab"?

danimesq commented 7 years ago

"special tab" I mean't a tab in TW.

AnthyG commented 7 years ago

Where all notifications are listed too?

danimesq commented 7 years ago

Not, only notifications of ThunderWave, the same that will appear in ZeroHello.

AnthyG commented 7 years ago

I meant all notifications of ThunderWave 😄

danimesq commented 7 years ago

Yes, all notifications. But you can do a tab system to separate notifications.

AnthyG commented 7 years ago

Reference #40.

AnthyG commented 7 years ago

Here's some compiled code from https://github.com/HelloZeroNet/ZeroMe/blob/master/js/Head.coffee#L54

Head.prototype.saveFollows = function() {
    var out;
    out = {};
    if (this.follows["Mentions"]) {
      out["Mentions"] = ["SELECT 'mention' AS type, comment.date_added AS date_added, 'a comment' AS title, '@' || user_name || ': ' || comment.body AS body, '?Post/' || json.site || '/' || REPLACE(post_uri, '_', '/') AS url FROM comment LEFT JOIN json USING (json_id) WHERE comment.body LIKE '%@" + Page.user.row.user_name + "%' UNION SELECT 'mention' AS type, post.date_added AS date_added, 'In ' || json.user_name || \"'s post\" AS title, post.body AS body, '?Post/' || json.site || '/' || REPLACE(json.directory, 'data/users/', '') || '/' || post_id AS url FROM post LEFT JOIN json USING (json_id) WHERE post.body LIKE '%@" + Page.user.row.user_name + "%'", [""]];
    }
    if (this.follows["Comments on your posts"]) {
      out["Comments on your posts"] = ["SELECT 'comment' AS type, comment.date_added AS date_added, 'Your post' AS title, '@' || json.user_name || ': ' || comment.body AS body, '?Post/' || site || '/' || REPLACE(post_uri, '_', '/') AS url FROM comment LEFT JOIN json USING (json_id) WHERE post_uri LIKE '" + Page.user.auth_address + "%'", [""]];
    }
    if (this.follows["New followers"]) {
      out["New followers"] = ["SELECT 'follow' AS type, follow.date_added AS date_added, json.user_name || ' started following you' AS title, '' AS body, '?Profile/' || json.hub || REPLACE(json.directory, 'data/users', '') AS url FROM follow LEFT JOIN json USING(json_id) WHERE auth_address = '" + Page.user.auth_address + "' GROUP BY json.directory", [""]];
    }
    return Page.cmd("feedFollow", [out]);
};
AnthyG commented 6 years ago

What do you think? image

I believe I have to use more specific syntax', like shown in the previous comment though, but it's a start 👍 ..

PS.: Do not use the following code, because I'm not sure, how to remove stuff.. 😐🤔

page.cmd("feedFollow", [
    {
        "Messages": [
            "SELECT message_id AS event_uri, 'post' AS type, date_added AS date_added, cert_user_id AS title, body AS body, message_id AS url FROM messages LEFT JOIN json USING (json_id)",
            [
                ""
            ]
        ]
    }
])

and page.cmd("feedListFollow", [], (data) => { console.log(data); })

danimesq commented 6 years ago

Amazing. ZeroNet needs a API to show the site favicon and a notification image.

AnthyG commented 6 years ago

@Plasmmer, that's a good Idea, but I'm not sure, if it's so secure.. ZeroHello doesn't parse Markdown either, probably because of security.

danimesq commented 6 years ago

What are the risks of showing the favicon of the site, like the title is shown?

AnthyG commented 6 years ago

A virus/ malware/ whatever

I know, that it's just really paranoid of me, but just as a thought.

AnthyG commented 6 years ago

Maybe, to exclude users messages from showing up in the Feed, there could be some item in the context menu (#53), to do so.

AnthyG commented 6 years ago

Finally got this working!

page.cmd("feedFollow", [{
        "Messages": [
            "SELECT messages.message_id AS event_uri, 'comment' AS type, messages.date_added AS date_added, 'Lobby' AS title, json.cert_user_id || ': ' || messages.body AS body, '' AS url FROM messages LEFT JOIN json USING (json_id)", [
                ""
            ]
        ]
    }
])

And now I know how to remove stuff as well:

page.cmd("feedFollow", [
    {}
])
danimesq commented 6 years ago

Please reference this issue in the commit.

danimesq commented 6 years ago

You can close this issue by using "fix #36" in the commit title.

AnthyG commented 6 years ago

I didn't yet implement it in ThunderWave. I have to experiment a little bit with the possibilities on this, so I can correctly add it to the context menu #53

AnthyG commented 6 years ago

Mentions!!

image

page.cmd("feedFollow", [{
    "Mentions": [
        "SELECT messages.message_id AS event_uri, 'mention' as type, messages.date_added AS date_added, 'the Lobby' AS title, json.cert_user_id || ': ' || messages.body AS body, '' AS url FROM messages LEFT JOIN json USING (json_id) WHERE (messages.body LIKE '%" + page.site_info.cert_user_id + "%' OR messages.body LIKE '%@" + page.site_info.cert_user_id.split("@")[0] + "')", [
            ""
        ]
    ],
    "Messages": [
        "SELECT messages.message_id AS event_uri, 'comment' AS type, messages.date_added AS date_added, 'the Lobby' AS title, json.cert_user_id || ': ' || messages.body AS body, '' AS url FROM messages LEFT JOIN json USING (json_id) WHERE json.cert_user_id != '" + page.site_info.cert_user_id + "' AND NOT (messages.body LIKE '%" + page.site_info.cert_user_id + "%' OR messages.body LIKE '%@" + page.site_info.cert_user_id.split("@")[0] + "')", [
            ""
        ]
    ]
}])

And without excluding own messages (what is shown in the image above (not exactly, anymore, because I had to fix the thing, where e.g. @glightstar wouldn't add to Mentions, but to Messages):

page.cmd("feedFollow", [{
    "Mentions": [
        "SELECT messages.message_id AS event_uri, 'mention' as type, messages.date_added AS date_added, 'the Lobby' AS title, json.cert_user_id || ': ' || messages.body AS body, '' AS url FROM messages LEFT JOIN json USING (json_id) WHERE (messages.body LIKE '%" + page.site_info.cert_user_id + "%' OR messages.body LIKE '%@" + page.site_info.cert_user_id.split("@")[0] + "' OR messages.body LIKE '@" + page.site_info.cert_user_id.split("@")[0] + "%')", [
            ""
        ]
    ],
    "Messages": [
        "SELECT messages.message_id AS event_uri, 'comment' AS type, messages.date_added AS date_added, 'the Lobby' AS title, json.cert_user_id || ': ' || messages.body AS body, '' AS url FROM messages LEFT JOIN json USING (json_id)", [
            ""
        ]
    ]
}])
AnthyG commented 6 years ago

Ability to see new messages from the Lobby in the ZeroHello-Feed has been added with commit 49169e31ed6922f120d5f81d7b789dcc482eda39