Skip to content

Commit 7bb9dd0

Browse files
committed
Fixes sub info page
1 parent 98e1975 commit 7bb9dd0

File tree

4 files changed

+53
-8
lines changed

4 files changed

+53
-8
lines changed

src/bin/api/core/http/handlers/sub.rs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ pub async fn subscription_info_handler<N, C, S>(
194194
sub_param: SubQueryParam,
195195
memory: MemSync<N, C, S>,
196196
host: String,
197+
web_host: String,
197198
) -> Result<Box<dyn warp::Reply + Send>, warp::Rejection>
198199
where
199200
N: NodeStorageOp + Sync + Send + Clone + 'static,
@@ -334,6 +335,11 @@ button {{
334335
button:hover {{
335336
background: #334155;
336337
}}
338+
button-id:hover {{
339+
background: #334155;
340+
font-size: 10px;
341+
342+
}}
337343
.qr {{
338344
margin-top: 16px;
339345
text-align: center;
@@ -342,6 +348,24 @@ button:hover {{
342348
font-size: 13px;
343349
color: #94a3b8;
344350
}}
351+
.small-id {{
352+
font-size: 11px;
353+
color: #94a3b8;
354+
text-align: right;
355+
margin-top: 0px;
356+
}}
357+
.small-viva {{
358+
font-size: 13px;
359+
color: #94a3b8;
360+
text-align: right;
361+
margin-top: 0px;
362+
}}
363+
.footer-line {{
364+
display: flex;
365+
justify-content: flex-end;
366+
align-items: center;
367+
margin-top: 8px;
368+
}}
345369
ul {{
346370
padding-left: 20px;
347371
}}
@@ -352,14 +376,16 @@ ul {{
352376
<div class="card">
353377
<h1>Подписка</h1>
354378
379+
355380
<div class="stat">Статус: <span class="{status_class}">{status_text}</span></div>
356381
<div class="stat">Дата окончания: {expires}</div>
357382
<div class="stat">Осталось дней: {days}</div>
383+
<div class="small-id">Id: <b>{subscription_id}</b></div>
384+
358385
359386
<hr>
360387
361388
<div class="stat">Трафик: ↓ {down_str} &nbsp;&nbsp; ↑ {up_str}</div>
362-
363389
<hr>
364390
365391
<h3>Ссылки для подключения</h3>
@@ -402,10 +428,18 @@ ul {{
402428
403429
<div class="small">Вы пригласили: {invited}</div>
404430
431+
<div class="small"><a href="{web_host}/ref.html"> Информация о реферальной программе</a></div>
432+
405433
</div>
406434
407435
<br><hr>
408-
<div class=small> <a href=https://t.me/frkn_support>Поддержка</a></div>
436+
437+
<div class=footer-line>
438+
<div class=small-viva>
439+
<a href=https://t.me/frkn_support>Поддержка &nbsp·</a></div>
440+
441+
<div class=small-viva > &nbsp Vive la résistance! </div>
442+
</div>
409443
410444
<script src="https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js"></script>
411445
@@ -434,7 +468,8 @@ window.onload = () => {{
434468
up_str = up_str,
435469
base_link = base_link,
436470
ref = sub.referral_code(),
437-
invited = invited
471+
invited = invited,
472+
subscription_id = id
438473
);
439474

440475
Ok(Box::new(warp::reply::with_status(

src/bin/api/core/http/routes.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use async_trait::async_trait;
22
use std::sync::Arc;
33
use warp::Filter;
44

5+
use pony::config::settings::ApiServiceConfig;
56
use pony::http::filters::auth;
67
use pony::http::requests::*;
78
use pony::Connection;
@@ -22,7 +23,7 @@ use crate::core::http::handlers::healthcheck_handler;
2223

2324
#[async_trait]
2425
pub trait Http {
25-
async fn run(&self, host: String) -> Result<()>;
26+
async fn run(&self, params: ApiServiceConfig) -> Result<()>;
2627
}
2728

2829
#[async_trait]
@@ -49,7 +50,7 @@ where
4950
+ std::cmp::PartialEq
5051
+ std::convert::From<pony::Subscription>,
5152
{
52-
async fn run(&self, host: String) -> Result<()> {
53+
async fn run(&self, params: ApiServiceConfig) -> Result<()> {
5354
let auth = auth(Arc::new(self.settings.api.token.clone()));
5455

5556
let get_healthcheck_route = warp::get()
@@ -128,7 +129,8 @@ where
128129
.and(warp::path::end())
129130
.and(warp::query::<SubQueryParam>())
130131
.and(with_state(self.sync.clone()))
131-
.and(with_param_string(host))
132+
.and(with_param_string(params.hostname))
133+
.and(with_param_string(params.web_host))
132134
.and_then(subscription_info_handler);
133135

134136
let post_subscription_route = warp::post()

src/bin/api/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ async fn main() -> Result<()> {
117117
});
118118
}
119119

120+
let token = settings.api.token.clone();
120121
if debug {
121-
let token = Arc::new(settings.api.token);
122+
let token = Arc::new(token);
122123
tokio::spawn(debug::start_ws_server(
123124
mem.clone(),
124125
settings
@@ -197,8 +198,9 @@ async fn main() -> Result<()> {
197198
});
198199

199200
let api = api.clone();
201+
let api_settings = settings.api.clone();
200202
let api_handle = tokio::spawn(async move {
201-
if let Err(e) = api.run(settings.api.hostname).await {
203+
if let Err(e) = api.run(api_settings).await {
202204
eprintln!("API server exited with error: {}", e);
203205
}
204206
});

src/config/settings.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ fn default_hostname() -> String {
131131
"http://localhost:5005".to_string()
132132
}
133133

134+
fn default_web_host() -> String {
135+
"https://frkn.org".to_string()
136+
}
137+
134138
#[derive(Clone, Debug, Deserialize, Default)]
135139
pub struct ApiServiceConfig {
136140
#[serde(default = "default_api_web_listen")]
@@ -153,6 +157,8 @@ pub struct ApiServiceConfig {
153157
pub db_sync_interval_sec: u64,
154158
#[serde(default = "default_hostname")]
155159
pub hostname: String,
160+
#[serde(default = "default_web_host")]
161+
pub web_host: String,
156162
#[serde(default = "default_subscription_restore_interval_sec")]
157163
pub subscription_restore_interval: u64,
158164
#[serde(default = "default_subscription_expire_interval_sec")]

0 commit comments

Comments
 (0)