trying to fix initial messages loading

This commit is contained in:
bakatrouble 2019-01-30 20:26:20 +03:00
parent 2fa592273d
commit d059b12e5e

View File

@ -17,14 +17,16 @@ class AggregationSourceForm(ModelForm):
cleaned_data = super(AggregationSourceForm, self).clean() cleaned_data = super(AggregationSourceForm, self).clean()
invite_link = cleaned_data.pop('invite_link') invite_link = cleaned_data.pop('invite_link')
if invite_link: if invite_link:
with get_client() as app: app = get_client()
app.start()
try: try:
upd = app.join_chat(invite_link) upd = app.join_chat(invite_link)
except ChannelPrivate:
raise ValidationError('I was banned in this chat')
app.stop()
chat = parse_mtproto_chat(app, upd.chats[0]) chat = parse_mtproto_chat(app, upd.chats[0])
cleaned_data['chat_id'] = chat.id cleaned_data['chat_id'] = chat.id
Chat.from_obj(chat, app) Chat.from_obj(chat, app)
except ChannelPrivate:
raise ValidationError('I was banned in this chat')
return cleaned_data return cleaned_data
class Meta: class Meta: