git ssb

2+

mixmix / ticktack



Commit 7e364b888ae451b0958c48457e841041c05f086d

refactor to obey configuration settings for #117

andre alves garzia committed on 5/7/2018, 3:20:24 PM
Parent: 3b308f9cde787a78b0a7c44eb1acdc645be0a63b

Files changed

message/html/webshares.jschanged
message/html/webshares.jsView
@@ -6,9 +6,10 @@
66 'keys.sync.id': 'first',
77 'message.obs.webshares': 'first',
88 'sbot.async.publish': 'first',
99 'translations.sync.strings': 'first',
10- 'app.html.lightbox': 'first'
10+ 'app.html.lightbox': 'first',
11+ 'settings.sync.get': 'first'
1112 })
1213
1314 exports.gives = nest('message.html.webshares')
1415
@@ -47,18 +48,37 @@
4748 ])
4849 })
4950
5051 function publishShare(msg, action) {
52+ var sharingScope = api.settings.sync.get('websharingmetrics')
5153 var url = `http://share2.ticktack.im:8807/${msg.key}`
5254 var share = {
5355 type: 'share',
5456 share: { link: msg.key, content: "blog", url: url }
5557 }
58+ // if it was a private message, then share as private ...
5659 if (msg.value.content.recps) {
5760 share.recps = msg.value.content.recps.map(function (e) {
5861 return e && typeof e !== 'string' ? e.link : e
5962 })
6063 share.private = true
64+ } else {
65+ // ... else obey configuration settings.
66+ switch (sharingScope) {
67+ case "private":
68+ share.private = true
69+ break
70+ case "author":
71+ share.recps = [
72+ id,
73+ msg.value.author
74+ ]
75+ share.private = true
76+ break
77+ case "public":
78+ default:
79+ break
80+ }
6181 }
6282 api.sbot.async.publish(share)
6383
6484 if (action == "copy") {

Built with git-ssb-web