Remove profile custom price (#1807)

* Remove custom price from profile

* Remove profile custom price from frontend

* Update frontend build
This commit is contained in:
Jonathan Zernik 2021-11-19 00:04:07 -08:00 committed by GitHub
parent 5d6e702243
commit 0a5d0d1d10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 19782 additions and 469 deletions

19723
frontend/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,6 @@ import {
FormGroup,
FormControlLabel,
Switch,
TextField,
} from '@material-ui/core';
// styles
@ -18,8 +17,6 @@ import useStyles from './styles';
import {
setSqueakProfileFollowingRequest,
setSqueakProfileUseCustomPriceRequest,
setSqueakProfileCustomPriceRequest,
} from '../../squeakclient/requests';
export default function ConfigureProfileDialog({
@ -37,40 +34,12 @@ export default function ConfigureProfileDialog({
});
};
const setUseCustomPrice = (id, useCustomPrice) => {
setSqueakProfileUseCustomPriceRequest(id, useCustomPrice, () => {
reloadProfile();
});
};
const setCustomPriceMsat = (id, customPriceMsat) => {
setSqueakProfileCustomPriceRequest(id, customPriceMsat, () => {
reloadProfile();
});
};
const handleSettingsFollowingChange = (event) => {
console.log(`Following changed for profile id: ${squeakProfile.getProfileId()}`);
console.log(`Following changed to: ${event.target.checked}`);
setFollowing(squeakProfile.getProfileId(), event.target.checked);
};
const handleSettingsUseCustomPriceChange = (event) => {
console.log(`UseCustomPrice changed for profile id: ${squeakProfile.getProfileId()}`);
console.log(`UseCustomPrice changed to: ${event.target.checked}`);
setUseCustomPrice(squeakProfile.getProfileId(), event.target.checked);
};
const handleSettingsCustomPriceMsatChange = (event) => {
console.log(`Custom Price changed for profile id: ${squeakProfile.getProfileId()}`);
const newPriceMsat = event.target.value;
console.log(`Custom Price changed to: ${newPriceMsat}`);
if (newPriceMsat < 0) {
return;
}
setCustomPriceMsat(squeakProfile.getProfileId(), event.target.value);
};
function MakeCancelButton() {
return (
<Button
@ -92,29 +61,7 @@ export default function ConfigureProfileDialog({
control={<Switch checked={squeakProfile.getFollowing()} onChange={handleSettingsFollowingChange} />}
label="Following"
/>
<FormControlLabel
control={<Switch checked={squeakProfile.getUseCustomPrice()} onChange={handleSettingsUseCustomPriceChange} />}
label="Use Custom Price"
/>
</FormGroup>
{squeakProfile.getUseCustomPrice()
? (
<TextField
required
id="standard-required"
label="Price (msats)"
type="number"
defaultValue={squeakProfile.getCustomPriceMsat()}
onChange={handleSettingsCustomPriceMsatChange}
/>
) : (
<TextField
disabled
id="standard-disabled"
label="Disabled"
defaultValue={squeakProfile.getCustomPriceMsat()}
/>
)}
</FormControl>
);
}

View file

@ -17,7 +17,6 @@ import CardHeader from '@material-ui/core/CardHeader';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import VpnKeyIcon from '@material-ui/icons/VpnKey';
import LocalOfferIcon from '@material-ui/icons/LocalOffer';
// styles
import useStyles from './styles';
@ -226,26 +225,6 @@ export default function SqueakProfileDetailItem({
);
}
function CustomPriceContent() {
return (
<Typography variant="body2" color="textSecondary" component="p">
<LocalOfferIcon />
{' '}
{(squeakProfile.getUseCustomPrice())
? (
<>
Selling with custom price:
{' '}
{squeakProfile.getCustomPriceMsat()}
{' '}
msats
</>
)
: <>Selling with default price</>}
</Typography>
);
}
return (
<>
<Card className={classes.root}>
@ -292,7 +271,6 @@ export default function SqueakProfileDetailItem({
<SqueakProfileFollowingIndicator
squeakProfile={squeakProfile}
/>
<CustomPriceContent />
</CardContent>
<CardActions>
<Button

View file

@ -32,10 +32,6 @@ import {
GetTimelineSqueakDisplaysReply,
SetSqueakProfileFollowingRequest,
SetSqueakProfileFollowingReply,
SetSqueakProfileUseCustomPriceRequest,
SetSqueakProfileUseCustomPriceReply,
SetSqueakProfileCustomPriceRequest,
SetSqueakProfileCustomPriceReply,
GetPeersRequest,
PayOfferRequest,
GetBuyOffersRequest,
@ -417,30 +413,6 @@ export function setSqueakProfileFollowingRequest(id, following, handleResponse)
);
}
export function setSqueakProfileUseCustomPriceRequest(id, useCustomPrice, handleResponse) {
const request = new SetSqueakProfileUseCustomPriceRequest();
request.setProfileId(id);
request.setUseCustomPrice(useCustomPrice);
makeRequest(
'setsqueakprofileusecustomprice',
request,
SetSqueakProfileUseCustomPriceReply.deserializeBinary,
handleResponse,
);
}
export function setSqueakProfileCustomPriceRequest(id, customPriceMsat, handleResponse) {
const request = new SetSqueakProfileCustomPriceRequest();
request.setProfileId(id);
request.setCustomPriceMsat(customPriceMsat);
makeRequest(
'setsqueakprofilecustomprice',
request,
SetSqueakProfileCustomPriceReply.deserializeBinary,
handleResponse,
);
}
export function renameSqueakProfileRequest(id, profileName, handleResponse) {
const request = new RenameSqueakProfileRequest();
request.setProfileId(id);

View file

@ -184,24 +184,3 @@ def connected_tcp_peer_id(other_admin_stub):
18777,
):
yield
@pytest.fixture
def signing_profile_id_with_free_price(admin_stub, signing_profile_id):
# Set the profile to use_custom_price
admin_stub.SetSqueakProfileUseCustomPrice(
squeak_admin_pb2.SetSqueakProfileUseCustomPriceRequest(
profile_id=signing_profile_id,
use_custom_price=True,
)
)
try:
yield signing_profile_id
finally:
# Set the profile to use_custom_price
admin_stub.SetSqueakProfileUseCustomPrice(
squeak_admin_pb2.SetSqueakProfileUseCustomPriceRequest(
profile_id=signing_profile_id,
use_custom_price=False,
)
)

View file

@ -42,6 +42,7 @@ from tests.util import download_offers
from tests.util import download_squeak
from tests.util import download_squeaks
from tests.util import download_squeaks_for_address
from tests.util import free_price
from tests.util import get_connected_peer
from tests.util import get_connected_peers
from tests.util import get_default_peer_port
@ -372,41 +373,6 @@ def test_set_profile_following(admin_stub, contact_profile_id):
assert not squeak_profile.following
def test_set_profile_use_custom_price(admin_stub, contact_profile_id):
# Set the profile to use_custom_price
admin_stub.SetSqueakProfileUseCustomPrice(
squeak_admin_pb2.SetSqueakProfileUseCustomPriceRequest(
profile_id=contact_profile_id,
use_custom_price=True,
)
)
# Set the profile custom price in msats
admin_stub.SetSqueakProfileCustomPrice(
squeak_admin_pb2.SetSqueakProfileCustomPriceRequest(
profile_id=contact_profile_id,
custom_price_msat=5678,
)
)
# Get the squeak profile again
squeak_profile = get_squeak_profile(admin_stub, contact_profile_id)
assert squeak_profile.use_custom_price
assert squeak_profile.custom_price_msat == 5678
# Set the profile to not use custom price
admin_stub.SetSqueakProfileUseCustomPrice(
squeak_admin_pb2.SetSqueakProfileUseCustomPriceRequest(
profile_id=contact_profile_id,
use_custom_price=False,
)
)
# Get the squeak profile again
squeak_profile = get_squeak_profile(admin_stub, contact_profile_id)
assert not squeak_profile.use_custom_price
def test_rename_profile(admin_stub, contact_profile_id, random_name):
# Rename the profile to something new
admin_stub.RenameSqueakProfile(
@ -806,19 +772,19 @@ def test_download_free_squeak(
admin_stub,
other_admin_stub,
connected_tcp_peer_id,
signing_profile_id_with_free_price,
saved_squeak_hash,
):
# Download squeak
download_result = download_squeak(other_admin_stub, saved_squeak_hash)
print('download_result:')
print(download_result)
assert download_result.number_downloaded == 1
assert download_result.number_requested == 1
with free_price(admin_stub):
# Download squeak
download_result = download_squeak(other_admin_stub, saved_squeak_hash)
print('download_result:')
print(download_result)
assert download_result.number_downloaded == 1
assert download_result.number_requested == 1
# Download offer
download_offers(other_admin_stub, saved_squeak_hash)
time.sleep(5)
# Download offer
download_offers(other_admin_stub, saved_squeak_hash)
time.sleep(5)
# Get the squeak display item
get_squeak_display_entry = get_squeak_display(
@ -1080,12 +1046,12 @@ def test_get_squeak_by_lookup(
def test_subscribe_squeaks(
admin_stub,
other_admin_stub,
signing_profile_id_with_free_price,
signing_profile_id,
):
# Get the squeak profile
squeak_profile = get_squeak_profile(
admin_stub, signing_profile_id_with_free_price)
admin_stub, signing_profile_id)
squeak_profile_address = squeak_profile.address
squeak_profile_name = squeak_profile.profile_name
@ -1099,17 +1065,18 @@ def test_subscribe_squeaks(
)
)
with open_peer_connection(
other_admin_stub,
"test_peer",
"squeaknode",
18777,
with free_price(admin_stub), \
open_peer_connection(
other_admin_stub,
"test_peer",
"squeaknode",
18777,
):
# Create a new squeak using the new profile
make_squeak_content = "Hello this message should be subscribed!"
make_squeak_hash = make_squeak(
admin_stub,
signing_profile_id_with_free_price,
signing_profile_id,
make_squeak_content,
)

View file

@ -82,6 +82,18 @@ def peer_connection(node_stub, lightning_host, remote_pubkey):
time.sleep(2)
@contextmanager
def free_price(node_stub):
# Set the price to zero
set_sell_price(node_stub, 0)
try:
print("Yielding lnd peer is connected.")
yield
finally:
# Clear the price
clear_sell_price(node_stub)
@contextmanager
def channel(node_stub, remote_pubkey, amount):
# Open channel to the server lightning node

View file

@ -104,14 +104,6 @@ service SqueakAdmin {
*/
rpc SetSqueakProfileFollowing (SetSqueakProfileFollowingRequest) returns (SetSqueakProfileFollowingReply) {}
/** sqkadmin: `setsqueakprofileusecustomprice`
*/
rpc SetSqueakProfileUseCustomPrice (SetSqueakProfileUseCustomPriceRequest) returns (SetSqueakProfileUseCustomPriceReply) {}
/** sqkadmin: `setsqueakprofilecustomprice`
*/
rpc SetSqueakProfileCustomPrice (SetSqueakProfileCustomPriceRequest) returns (SetSqueakProfileCustomPriceReply) {}
/** sqkadmin: `renamesqueakprofile`
*/
rpc RenameSqueakProfile (RenameSqueakProfileRequest) returns (RenameSqueakProfileReply) {}
@ -471,28 +463,6 @@ message SetSqueakProfileFollowingRequest {
message SetSqueakProfileFollowingReply {
}
message SetSqueakProfileUseCustomPriceRequest {
/// The profile id
int32 profile_id = 1;
/// Use custom price
bool use_custom_price = 2;
}
message SetSqueakProfileUseCustomPriceReply {
}
message SetSqueakProfileCustomPriceRequest {
/// The profile id
int32 profile_id = 1;
/// The price in msats
int64 custom_price_msat = 2;
}
message SetSqueakProfileCustomPriceReply {
}
message RenameSqueakProfileRequest {
/// The profile id
int32 profile_id = 1;
@ -557,17 +527,11 @@ message SqueakProfile {
/// Following
bool following = 5;
/// Following
bool use_custom_price = 6;
/// The price in msats
int64 custom_price_msat = 7;
/// The profile image
string profile_image = 8;
string profile_image = 6;
/// Has custom profile image
bool has_custom_profile_image = 9;
bool has_custom_profile_image = 7;
}
message MakeSqueakRequest {

View file

@ -86,8 +86,6 @@ def squeak_profile_to_message(squeak_profile: SqueakProfile) -> squeak_admin_pb2
has_private_key=has_private_key,
address=squeak_profile.address,
following=squeak_profile.following,
use_custom_price=squeak_profile.use_custom_price,
custom_price_msat=squeak_profile.custom_price_msat,
profile_image=image_base64_str,
has_custom_profile_image=has_custom_profile_image,
)

View file

@ -223,32 +223,6 @@ class SqueakAdminServerHandler(object):
profile_id, following)
return squeak_admin_pb2.SetSqueakProfileFollowingReply()
def handle_set_squeak_profile_use_custom_price(self, request):
profile_id = request.profile_id
use_custom_price = request.use_custom_price
logger.info(
"Handle set squeak profile use_custom_price with profile id: {}, use_custom_price: {}".format(
profile_id,
use_custom_price,
)
)
self.squeak_controller.set_squeak_profile_use_custom_price(
profile_id, use_custom_price)
return squeak_admin_pb2.SetSqueakProfileUseCustomPriceReply()
def handle_set_squeak_profile_custom_price(self, request):
profile_id = request.profile_id
custom_price_msat = request.custom_price_msat
logger.info(
"Handle set squeak profile custom price with profile id: {}, custom_price_msat: {}".format(
profile_id,
custom_price_msat,
)
)
self.squeak_controller.set_squeak_profile_custom_price(
profile_id, custom_price_msat)
return squeak_admin_pb2.SetSqueakProfileCustomPriceReply()
def handle_rename_squeak_profile(self, request):
profile_id = request.profile_id
profile_name = request.profile_name

View file

@ -122,12 +122,6 @@ class SqueakAdminServerServicer(squeak_admin_pb2_grpc.SqueakAdminServicer):
def SetSqueakProfileFollowing(self, request, context):
return self.handler.handle_set_squeak_profile_following(request)
def SetSqueakProfileUseCustomPrice(self, request, context):
return self.handler.handle_set_squeak_profile_use_custom_price(request)
def SetSqueakProfileCustomPrice(self, request, context):
return self.handler.handle_set_squeak_profile_custom_price(request)
def RenameSqueakProfile(self, request, context):
return self.handler.handle_rename_squeak_profile(request)

View file

@ -217,18 +217,6 @@ def create_app(handler, username, password):
def setsqueakprofilefollowing(msg):
return handler.handle_set_squeak_profile_following(msg)
@app.route("/setsqueakprofileusecustomprice", methods=["POST"])
@login_required
@protobuf_serialized(squeak_admin_pb2.SetSqueakProfileUseCustomPriceRequest())
def setsqueakprofileusecustomprice(msg):
return handler.handle_set_squeak_profile_use_custom_price(msg)
@app.route("/setsqueakprofilecustomprice", methods=["POST"])
@login_required
@protobuf_serialized(squeak_admin_pb2.SetSqueakProfileCustomPriceRequest())
def setsqueakprofilecustomprice(msg):
return handler.handle_set_squeak_profile_custom_price(msg)
@app.route("/renamesqueakprofile", methods=["POST"])
@login_required
@protobuf_serialized(squeak_admin_pb2.RenameSqueakProfileRequest())

View file

@ -1,25 +1,25 @@
{
"files": {
"main.js": "/static/js/main.f1638282.chunk.js",
"main.js.map": "/static/js/main.f1638282.chunk.js.map",
"main.js": "/static/js/main.58b579a8.chunk.js",
"main.js.map": "/static/js/main.58b579a8.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.9f0ba400.js",
"runtime-main.js.map": "/static/js/runtime-main.9f0ba400.js.map",
"static/css/2.ea4ba2f0.chunk.css": "/static/css/2.ea4ba2f0.chunk.css",
"static/js/2.180244ea.chunk.js": "/static/js/2.180244ea.chunk.js",
"static/js/2.180244ea.chunk.js.map": "/static/js/2.180244ea.chunk.js.map",
"static/css/2.15110fae.chunk.css": "/static/css/2.15110fae.chunk.css",
"static/js/2.d5cfad25.chunk.js": "/static/js/2.d5cfad25.chunk.js",
"static/js/2.d5cfad25.chunk.js.map": "/static/js/2.d5cfad25.chunk.js.map",
"index.html": "/index.html",
"precache-manifest.efd0fcd74ab4721847dd78849d87248a.js": "/precache-manifest.efd0fcd74ab4721847dd78849d87248a.js",
"precache-manifest.db8d49d0d3c44d0eec7ba541a646ae0f.js": "/precache-manifest.db8d49d0d3c44d0eec7ba541a646ae0f.js",
"service-worker.js": "/service-worker.js",
"static/css/2.ea4ba2f0.chunk.css.map": "/static/css/2.ea4ba2f0.chunk.css.map",
"static/js/2.180244ea.chunk.js.LICENSE.txt": "/static/js/2.180244ea.chunk.js.LICENSE.txt",
"static/css/2.15110fae.chunk.css.map": "/static/css/2.15110fae.chunk.css.map",
"static/js/2.d5cfad25.chunk.js.LICENSE.txt": "/static/js/2.d5cfad25.chunk.js.LICENSE.txt",
"static/media/font-awesome.min.css": "/static/media/fontawesome-webfont.fee66e71.woff",
"static/media/google.svg": "/static/media/google.695a3160.svg",
"static/media/logo.svg": "/static/media/logo.a0185b04.svg"
},
"entrypoints": [
"static/js/runtime-main.9f0ba400.js",
"static/css/2.ea4ba2f0.chunk.css",
"static/js/2.180244ea.chunk.js",
"static/js/main.f1638282.chunk.js"
"static/css/2.15110fae.chunk.css",
"static/js/2.d5cfad25.chunk.js",
"static/js/main.58b579a8.chunk.js"
]
}

View file

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeaknode</title><meta name="description" content="Squeaknode is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.ea4ba2f0.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.180244ea.chunk.js"></script><script src="/static/js/main.f1638282.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeaknode</title><meta name="description" content="Squeaknode is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.d5cfad25.chunk.js"></script><script src="/static/js/main.58b579a8.chunk.js"></script></body></html>

View file

@ -1,23 +1,23 @@
self.__precacheManifest = (self.__precacheManifest || []).concat([
{
"revision": "7497e8b5a321c991992d396b70ca51c5",
"revision": "2e5b9592a947213bbc846f4448561787",
"url": "/index.html"
},
{
"revision": "36d7b205176816f91b11",
"url": "/static/css/2.ea4ba2f0.chunk.css"
"revision": "1f10c9cd9c7c6271d2e5",
"url": "/static/css/2.15110fae.chunk.css"
},
{
"revision": "36d7b205176816f91b11",
"url": "/static/js/2.180244ea.chunk.js"
"revision": "1f10c9cd9c7c6271d2e5",
"url": "/static/js/2.d5cfad25.chunk.js"
},
{
"revision": "ce334ad48c4dc2f747f813c26790dfba",
"url": "/static/js/2.180244ea.chunk.js.LICENSE.txt"
"url": "/static/js/2.d5cfad25.chunk.js.LICENSE.txt"
},
{
"revision": "7e6ffb412d6a829d93de",
"url": "/static/js/main.f1638282.chunk.js"
"revision": "27b368561db6ca77e404",
"url": "/static/js/main.58b579a8.chunk.js"
},
{
"revision": "cc9816de5a8639d377ea",

View file

@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
importScripts(
"/precache-manifest.efd0fcd74ab4721847dd78849d87248a.js"
"/precache-manifest.db8d49d0d3c44d0eec7ba541a646ae0f.js"
);
self.addEventListener('message', (event) => {
@ -35,5 +35,5 @@ workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("/index.html"), {
blacklist: [/^\/_/,/\/[^\/?]+\.[^\/]+$/],
blacklist: [/^\/_/,/\/[^/?]+\.[^/]+$/],
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -30,6 +30,4 @@ class SqueakProfile(NamedTuple):
profile_id: Optional[int] = None
private_key: Optional[bytes] = None
following: bool = True
use_custom_price: bool = False
custom_price_msat: int = 0
profile_image: Optional[bytes] = None

View file

@ -0,0 +1,51 @@
# MIT License
#
# Copyright (c) 2020 Jonathan Zernik
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Remove custom price per profile
Revision ID: 7d807dd8d456
Revises: 5bd8f4075339
Create Date: 2021-11-18 22:11:56.264683
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '7d807dd8d456'
down_revision = '5bd8f4075339'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('profile', schema=None) as batch_op:
batch_op.drop_column('custom_price_msat')
batch_op.drop_column('use_custom_price')
def downgrade():
with op.batch_alter_table('profile', schema=None) as batch_op:
batch_op.add_column(sa.Column('use_custom_price',
sa.BOOLEAN(), nullable=False, server_default=sa.sql.expression.false()))
batch_op.add_column(sa.Column('custom_price_msat',
sa.INTEGER(), nullable=False, server_default=sa.text("0")))

View file

@ -81,8 +81,6 @@ class Models:
Column("private_key", LargeBinary, nullable=True),
Column("address", String(35), unique=True, nullable=False),
Column("following", Boolean, nullable=False),
Column("use_custom_price", Boolean, nullable=False, default=False),
Column("custom_price_msat", Integer, nullable=False, default=0),
Column("profile_image", LargeBinary, nullable=True),
sqlite_autoincrement=True,
)

View file

@ -801,26 +801,6 @@ class SqueakDb:
with self.get_connection() as connection:
connection.execute(stmt)
def set_profile_use_custom_price(self, profile_id: int, use_custom_price: bool) -> None:
""" Set a profile use custom price. """
stmt = (
self.profiles.update()
.where(self.profiles.c.profile_id == profile_id)
.values(use_custom_price=use_custom_price)
)
with self.get_connection() as connection:
connection.execute(stmt)
def set_profile_custom_price_msat(self, profile_id: int, custom_price_msat: int) -> None:
""" Set a profile custom price in msats. """
stmt = (
self.profiles.update()
.where(self.profiles.c.profile_id == profile_id)
.values(custom_price_msat=custom_price_msat)
)
with self.get_connection() as connection:
connection.execute(stmt)
def set_profile_name(self, profile_id: int, profile_name: str) -> None:
""" Set a profile name. """
stmt = (
@ -1502,8 +1482,6 @@ class SqueakDb:
private_key=private_key,
address=row["address"],
following=row["following"],
use_custom_price=row["use_custom_price"],
custom_price_msat=row["custom_price_msat"],
profile_image=row["profile_image"],
)

View file

@ -27,7 +27,6 @@ from squeak.core import CSqueak
from squeaknode.config.config import SqueaknodeConfig
from squeaknode.core.peer_address import PeerAddress
from squeaknode.core.squeak_peer import SqueakPeer
from squeaknode.core.squeak_profile import SqueakProfile
from squeaknode.core.user_config import UserConfig
from squeaknode.db.squeak_db import SqueakDb
@ -49,11 +48,6 @@ class PricePolicy:
peer = self.get_peer(peer_address)
if peer is not None and peer.share_for_free:
return 0
# Return custom price if address is configured with custom price.
squeak_address = str(squeak.GetAddress())
squeak_profile = self.get_profile(squeak_address)
if squeak_profile is not None and squeak_profile.use_custom_price:
return squeak_profile.custom_price_msat
# Return sell price from settings if configured
sell_price = self.get_sell_price_msat()
if sell_price is not None:
@ -63,9 +57,6 @@ class PricePolicy:
def get_peer(self, peer_address: PeerAddress) -> Optional[SqueakPeer]:
return self.squeak_db.get_peer_by_address(peer_address)
def get_profile(self, address: str) -> Optional[SqueakProfile]:
return self.squeak_db.get_profile_by_address(address)
def get_default_price(self) -> int:
return self.config.node.price_msat

View file

@ -288,14 +288,6 @@ class SqueakController:
self.squeak_db.set_profile_following(profile_id, following)
self.create_update_subscriptions_event()
def set_squeak_profile_use_custom_price(self, profile_id: int, use_custom_price: bool) -> None:
self.squeak_db.set_profile_use_custom_price(
profile_id, use_custom_price)
def set_squeak_profile_custom_price(self, profile_id: int, custom_price_msat: int) -> None:
self.squeak_db.set_profile_custom_price_msat(
profile_id, custom_price_msat)
def rename_squeak_profile(self, profile_id: int, profile_name: str) -> None:
self.squeak_db.set_profile_name(profile_id, profile_name)

View file

@ -52,8 +52,6 @@ def signing_profile_msg(
has_private_key=True,
address=address_str,
following=True,
use_custom_price=False,
custom_price_msat=0,
profile_image=img_base64_str,
has_custom_profile_image=False,
)

View file

@ -109,20 +109,6 @@ def unfollowed_contact_profile_id(squeak_db, followed_contact_profile_id):
yield followed_contact_profile_id
@pytest.fixture
def profile_with_use_custom_price_id(squeak_db, inserted_contact_profile_id):
squeak_db.set_profile_use_custom_price(
inserted_contact_profile_id,
True,
)
yield inserted_contact_profile_id
@pytest.fixture
def custom_price_msat():
yield 502379
@pytest.fixture
def new_profile_name():
yield "new_fake_profile_name"
@ -133,15 +119,6 @@ def profile_image_bytes():
yield bytes.fromhex("deadbeef")
@pytest.fixture
def profile_with_custom_price_id(squeak_db, inserted_contact_profile_id, custom_price_msat):
squeak_db.set_profile_custom_price_msat(
inserted_contact_profile_id,
custom_price_msat,
)
yield inserted_contact_profile_id
@pytest.fixture
def profile_with_new_name_id(squeak_db, inserted_contact_profile_id, new_profile_name):
squeak_db.set_profile_name(
@ -609,18 +586,6 @@ def test_set_profile_unfollowing(squeak_db, unfollowed_contact_profile_id):
assert not profile.following
def test_set_profile_use_custom_price(squeak_db, profile_with_use_custom_price_id):
profile = squeak_db.get_profile(profile_with_use_custom_price_id)
assert profile.use_custom_price
def test_set_profile_custom_price(squeak_db, profile_with_custom_price_id, custom_price_msat):
profile = squeak_db.get_profile(profile_with_custom_price_id)
assert profile.custom_price_msat == custom_price_msat
def test_set_profile_name(squeak_db, profile_with_new_name_id, new_profile_name):
profile = squeak_db.get_profile(profile_with_new_name_id)

View file

@ -32,43 +32,9 @@ def price_policy():
def test_get_price(price_policy, squeak, peer_address, user_config):
with mock.patch.object(price_policy, 'get_peer', autospec=True) as mock_get_peer, \
mock.patch.object(price_policy, 'get_profile', autospec=True) as mock_get_profile, \
mock.patch.object(price_policy, 'get_user_config', autospec=True) as mock_get_user_config, \
mock.patch.object(price_policy, 'get_default_price', autospec=True) as mock_get_default_price:
mock_get_peer.return_value = None
mock_get_profile.return_value = None
mock_get_user_config.return_value = user_config
mock_get_default_price.return_value = 555
assert price_policy.get_price(squeak, peer_address) == 555
def test_get_price_profile_custom_price(price_policy, squeak, peer_address, signing_profile, user_config):
with mock.patch.object(price_policy, 'get_peer', autospec=True) as mock_get_peer, \
mock.patch.object(price_policy, 'get_profile', autospec=True) as mock_get_profile, \
mock.patch.object(price_policy, 'get_user_config', autospec=True) as mock_get_user_config, \
mock.patch.object(price_policy, 'get_default_price', autospec=True) as mock_get_default_price:
mock_get_peer.return_value = None
mock_get_profile.return_value = signing_profile._replace(
use_custom_price=True,
custom_price_msat=54321,
)
mock_get_user_config.return_value = user_config
mock_get_default_price.return_value = 555
assert price_policy.get_price(squeak, peer_address) == 54321
def test_get_price_profile_no_custom_price(price_policy, squeak, peer_address, signing_profile, user_config):
with mock.patch.object(price_policy, 'get_peer', autospec=True) as mock_get_peer, \
mock.patch.object(price_policy, 'get_profile', autospec=True) as mock_get_profile, \
mock.patch.object(price_policy, 'get_user_config', autospec=True) as mock_get_user_config, \
mock.patch.object(price_policy, 'get_default_price', autospec=True) as mock_get_default_price:
mock_get_peer.return_value = None
mock_get_profile.return_value = signing_profile._replace(
use_custom_price=False,
custom_price_msat=54321,
)
mock_get_user_config.return_value = user_config
mock_get_default_price.return_value = 555
@ -77,13 +43,11 @@ def test_get_price_profile_no_custom_price(price_policy, squeak, peer_address, s
def test_get_price_profile_share_free_peer(price_policy, squeak, peer_address, peer, user_config):
with mock.patch.object(price_policy, 'get_peer', autospec=True) as mock_get_peer, \
mock.patch.object(price_policy, 'get_profile', autospec=True) as mock_get_profile, \
mock.patch.object(price_policy, 'get_user_config', autospec=True) as mock_get_user_config, \
mock.patch.object(price_policy, 'get_default_price', autospec=True) as mock_get_default_price:
mock_get_peer.return_value = peer._replace(
share_for_free=True,
)
mock_get_profile.return_value = None
mock_get_user_config.return_value = user_config
mock_get_default_price.return_value = 555
@ -92,13 +56,11 @@ def test_get_price_profile_share_free_peer(price_policy, squeak, peer_address, p
def test_get_price_profile_no_share_free_peer(price_policy, squeak, peer_address, peer, user_config):
with mock.patch.object(price_policy, 'get_peer', autospec=True) as mock_get_peer, \
mock.patch.object(price_policy, 'get_profile', autospec=True) as mock_get_profile, \
mock.patch.object(price_policy, 'get_user_config', autospec=True) as mock_get_user_config, \
mock.patch.object(price_policy, 'get_default_price', autospec=True) as mock_get_default_price:
mock_get_peer.return_value = peer._replace(
share_for_free=False,
)
mock_get_profile.return_value = None
mock_get_user_config.return_value = user_config
mock_get_default_price.return_value = 555
@ -107,11 +69,9 @@ def test_get_price_profile_no_share_free_peer(price_policy, squeak, peer_address
def test_get_price_sell_price_set(price_policy, squeak, peer_address, user_config):
with mock.patch.object(price_policy, 'get_peer', autospec=True) as mock_get_peer, \
mock.patch.object(price_policy, 'get_profile', autospec=True) as mock_get_profile, \
mock.patch.object(price_policy, 'get_user_config', autospec=True) as mock_get_user_config, \
mock.patch.object(price_policy, 'get_default_price', autospec=True) as mock_get_default_price:
mock_get_peer.return_value = None
mock_get_profile.return_value = None
mock_get_user_config.return_value = user_config._replace(
sell_price_msat=7777,
)