Skip to content

Commit 0ac0b65

Browse files
committed
Updating the variable that tracks previous comments in Disqus,
only when a comment is successfully created/udpated. Keeping track of comments made in Disqus is essential to avoid errors that the same comment was made twice. A failure on creating/updating a comment could make the variable to go out of sync in previous implementation.
1 parent e16441e commit 0ac0b65

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

codebender_testing/disqus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ def create_post(self, thread_id, message):
176176
self.last_post = message
177177
elif re.match(r'^.+\.$', self.last_post):
178178
message = message[:-1]
179-
self.last_post = message
180179

181180
comment_status = False
182181

@@ -189,6 +188,7 @@ def create_post(self, thread_id, message):
189188
thread=response[0]['id'],
190189
message=message, method='POST')
191190
if response['raw_message'] == message:
191+
self.last_post = message
192192
comment_status = True
193193
except Exception as error:
194194
print 'Error:', error
@@ -200,7 +200,6 @@ def update_post(self, post_id, message):
200200
self.last_post = message
201201
elif re.match(r'^.+\.$', self.last_post):
202202
message = message[:-1]
203-
self.last_post = message
204203

205204
comment_status = False
206205

@@ -211,6 +210,7 @@ def update_post(self, post_id, message):
211210
post=post_id,
212211
message=message, method='POST')
213212
if response['raw_message'] == message:
213+
self.last_post = message
214214
comment_status = True
215215
except Exception as error:
216216
print 'Error:', error

0 commit comments

Comments
 (0)