Add TG messages for dispute open and collaborative cancellation

This commit is contained in:
Reckless_Satoshi 2022-06-02 15:32:01 -07:00
parent 7623d30670
commit 8663fb3423
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
6 changed files with 39 additions and 18 deletions

View File

@ -458,6 +458,7 @@ class Logics:
profile.orders_disputes_started).append(str(order.id))
profile.save()
send_message.delay(order.id,'dispute_opened')
return True, None
def dispute_statement(order, user, statement):
@ -790,6 +791,7 @@ class Logics:
cls.return_escrow(order)
order.status = Order.Status.CCA
order.save()
send_message.delay(order.id,'collaborative_cancelled')
return
@classmethod

View File

@ -177,6 +177,34 @@ class Telegram():
self.send_message(user, text)
return
def collaborative_cancelled(self, order):
user = order.maker
if not user.profile.telegram_enabled:
return
lang = user.profile.telegram_lang_code
if lang == 'es':
text = f'La orden con ID {str(order.id)} fue cancelada colaborativamente.'
else:
text = f'Your order with ID {str(order.id)} has been collaboratively cancelled.'
self.send_message(user, text)
return
def dispute_opened(self, order):
user = order.maker
if not user.profile.telegram_enabled:
return
lang = user.profile.telegram_lang_code
if lang == 'es':
text = f'La orden con ID {str(order.id)} ha entrado en disputa.'
else:
text = f'A dispute has been opened on your order with ID {str(order.id)}.'
self.send_message(user, text)
return
def order_published(self, order):
time.sleep(1) # Just so this message always arrives after the previous two

View File

@ -276,4 +276,10 @@ def send_message(order_id, message):
elif message == 'fiat_exchange_starts':
telegram.fiat_exchange_starts(order)
elif message == 'dispute_opened':
telegram.dispute_opened(order)
elif message == 'collaborative_cancelled':
telegram.collaborative_cancelled(order)
return

View File

@ -1,15 +0,0 @@
#!/bin/bash
rm db.sqlite3
rm -R api/migrations
rm -R frontend/migrations
rm -R frontend/static/assets/avatars
python3 manage.py makemigrations
python3 manage.py makemigrations api
python3 manage.py migrate
python3 manage.py createsuperuser
python3 manage.py runserver

View File

@ -72,5 +72,5 @@ The hodl invoice shows as a grey icon while waiting. Need to tap the back obviou
## <i class="fa-solid fa-code-pull-request"></i> Help keep this page updated
There are many wallets and all of them keep improving at lightning speed. You can contribute to the RoboSats Open Source Project by testing wallets, editing [the content of this page](https://github.com/Reckless-Satoshi/robosats/tree/main/docs/{page.src}}) and opening a [Pull Request](https://github.com/Reckless-Satoshi/robosats/pulls)
There are many wallets and all of them keep improving at lightning speed. You can contribute to the RoboSats Open Source Project by testing wallets, editing [the content of this page](https://github.com/Reckless-Satoshi/robosats/tree/main/docs/{{page.src}}) and opening a [Pull Request](https://github.com/Reckless-Satoshi/robosats/pulls)

View File

@ -61,7 +61,7 @@ class BottomBar extends Component {
this.setState(null)
fetch('/api/info/')
.then((response) => response.json())
.then((data) => this.setState(data) & console.log(data)
.then((data) => this.setState(data)
& this.setState({active_order_id: data.active_order_id ? data.active_order_id : null,
last_order_id: data.last_order_id ? data.last_order_id : null})
& this.props.setAppState({nickname:data.nickname, loading:false}));
@ -105,7 +105,7 @@ class BottomBar extends Component {
};
fetch('/api/reward/', requestOptions)
.then((response) => response.json())
.then((data) => console.log(data) & this.setState({
.then((data) => this.setState({
badInvoice:data.bad_invoice,
openClaimRewards: data.successful_withdrawal ? false : true,
earned_rewards: data.successful_withdrawal ? 0 : this.state.earned_rewards,