Commit 7e364b888ae451b0958c48457e841041c05f086d
refactor to obey configuration settings for #117
andre alves garzia committed on 5/7/2018, 3:20:24 PMParent: 3b308f9cde787a78b0a7c44eb1acdc645be0a63b
Files changed
message/html/webshares.js | changed |
message/html/webshares.js | ||
---|---|---|
@@ -6,9 +6,10 @@ | ||
6 | 6 | 'keys.sync.id': 'first', |
7 | 7 | 'message.obs.webshares': 'first', |
8 | 8 | 'sbot.async.publish': 'first', |
9 | 9 | 'translations.sync.strings': 'first', |
10 | - 'app.html.lightbox': 'first' | |
10 | + 'app.html.lightbox': 'first', | |
11 | + 'settings.sync.get': 'first' | |
11 | 12 | }) |
12 | 13 | |
13 | 14 | exports.gives = nest('message.html.webshares') |
14 | 15 | |
@@ -47,18 +48,37 @@ | ||
47 | 48 | ]) |
48 | 49 | }) |
49 | 50 | |
50 | 51 | function publishShare(msg, action) { |
52 | + var sharingScope = api.settings.sync.get('websharingmetrics') | |
51 | 53 | var url = `http://share2.ticktack.im:8807/${msg.key}` |
52 | 54 | var share = { |
53 | 55 | type: 'share', |
54 | 56 | share: { link: msg.key, content: "blog", url: url } |
55 | 57 | } |
58 | + // if it was a private message, then share as private ... | |
56 | 59 | if (msg.value.content.recps) { |
57 | 60 | share.recps = msg.value.content.recps.map(function (e) { |
58 | 61 | return e && typeof e !== 'string' ? e.link : e |
59 | 62 | }) |
60 | 63 | 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 | + } | |
61 | 81 | } |
62 | 82 | api.sbot.async.publish(share) |
63 | 83 | |
64 | 84 | if (action == "copy") { |
Built with git-ssb-web