@@ 477-509 (lines=33) @@ | ||
474 | ||
475 | resp.status = falcon.HTTP_200 |
|
476 | ||
477 | @staticmethod |
|
478 | @user_logger |
|
479 | def on_delete(req, resp, id_): |
|
480 | admin_control(req) |
|
481 | if not id_.isdigit() or int(id_) <= 0: |
|
482 | raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
|
483 | description='API.INVALID_WECHAT_MESSAGE_ID') |
|
484 | ||
485 | cnx = mysql.connector.connect(**config.myems_fdd_db) |
|
486 | cursor = cnx.cursor() |
|
487 | ||
488 | cursor.execute(" SELECT id " |
|
489 | " FROM tbl_wechat_messages_outbox " |
|
490 | " WHERE id = %s ", (id_,)) |
|
491 | row = cursor.fetchone() |
|
492 | ||
493 | if row is None: |
|
494 | if cursor: |
|
495 | cursor.close() |
|
496 | if cnx: |
|
497 | cnx.close() |
|
498 | raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
|
499 | description='API.WECHAT_MESSAGE_NOT_FOUND') |
|
500 | ||
501 | cursor.execute(" DELETE FROM tbl_wechat_messages_outbox WHERE id = %s ", (id_,)) |
|
502 | cnx.commit() |
|
503 | ||
504 | if cursor: |
|
505 | cursor.close() |
|
506 | if cnx: |
|
507 | cnx.close() |
|
508 | ||
509 | resp.status = falcon.HTTP_204 |
|
510 |
@@ 459-491 (lines=33) @@ | ||
456 | ||
457 | resp.status = falcon.HTTP_200 |
|
458 | ||
459 | @staticmethod |
|
460 | @user_logger |
|
461 | def on_delete(req, resp, id_): |
|
462 | admin_control(req) |
|
463 | if not id_.isdigit() or int(id_) <= 0: |
|
464 | raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
|
465 | description='API.INVALID_EMAIL_MESSAGE_ID') |
|
466 | ||
467 | cnx = mysql.connector.connect(**config.myems_fdd_db) |
|
468 | cursor = cnx.cursor() |
|
469 | ||
470 | cursor.execute(" SELECT id " |
|
471 | " FROM tbl_email_messages " |
|
472 | " WHERE id = %s ", (id_,)) |
|
473 | row = cursor.fetchone() |
|
474 | ||
475 | if row is None: |
|
476 | if cursor: |
|
477 | cursor.close() |
|
478 | if cnx: |
|
479 | cnx.close() |
|
480 | raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
|
481 | description='API.EMAIL_MESSAGE_NOT_FOUND') |
|
482 | ||
483 | cursor.execute(" DELETE FROM tbl_email_messages WHERE id = %s ", (id_,)) |
|
484 | cnx.commit() |
|
485 | ||
486 | if cursor: |
|
487 | cursor.close() |
|
488 | if cnx: |
|
489 | cnx.close() |
|
490 | ||
491 | resp.status = falcon.HTTP_204 |
|
492 |
@@ 428-458 (lines=31) @@ | ||
425 | ||
426 | resp.status = falcon.HTTP_200 |
|
427 | ||
428 | @staticmethod |
|
429 | @user_logger |
|
430 | def on_delete(req, resp, id_): |
|
431 | admin_control(req) |
|
432 | if not id_.isdigit() or int(id_) <= 0: |
|
433 | raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
|
434 | description='API.INVALID_TEXT_MESSAGE_ID') |
|
435 | ||
436 | cnx = mysql.connector.connect(**config.myems_fdd_db) |
|
437 | cursor = cnx.cursor() |
|
438 | ||
439 | cursor.execute(" SELECT id FROM tbl_text_messages_outbox WHERE id = %s ", (id_,)) |
|
440 | row = cursor.fetchone() |
|
441 | ||
442 | if row is None: |
|
443 | if cursor: |
|
444 | cursor.close() |
|
445 | if cnx: |
|
446 | cnx.close() |
|
447 | raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
|
448 | description='API.TEXT_MESSAGE_NOT_FOUND') |
|
449 | ||
450 | cursor.execute(" DELETE FROM tbl_text_messages_outbox WHERE id = %s ", (id_,)) |
|
451 | cnx.commit() |
|
452 | ||
453 | if cursor: |
|
454 | cursor.close() |
|
455 | if cnx: |
|
456 | cnx.close() |
|
457 | ||
458 | resp.status = falcon.HTTP_204 |
|
459 |
@@ 1514-1546 (lines=33) @@ | ||
1511 | ||
1512 | resp.status = falcon.HTTP_200 |
|
1513 | ||
1514 | @staticmethod |
|
1515 | @user_logger |
|
1516 | def on_delete(req, resp, id_): |
|
1517 | admin_control(req) |
|
1518 | if not id_.isdigit() or int(id_) <= 0: |
|
1519 | raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
|
1520 | description='API.INVALID_EMAIL_MESSAGE_ID') |
|
1521 | ||
1522 | cnx = mysql.connector.connect(**config.myems_user_db) |
|
1523 | cursor = cnx.cursor() |
|
1524 | ||
1525 | cursor.execute(" SELECT id " |
|
1526 | " FROM tbl_email_messages " |
|
1527 | " WHERE id = %s ", (id_,)) |
|
1528 | row = cursor.fetchone() |
|
1529 | ||
1530 | if row is None: |
|
1531 | if cursor: |
|
1532 | cursor.close() |
|
1533 | if cnx: |
|
1534 | cnx.close() |
|
1535 | raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
|
1536 | description='API.EMAIL_MESSAGE_NOT_FOUND') |
|
1537 | ||
1538 | cursor.execute(" DELETE FROM tbl_email_messages WHERE id = %s ", (id_,)) |
|
1539 | cnx.commit() |
|
1540 | ||
1541 | if cursor: |
|
1542 | cursor.close() |
|
1543 | if cnx: |
|
1544 | cnx.close() |
|
1545 | ||
1546 | resp.status = falcon.HTTP_204 |
|
1547 | ||
1548 | ||
1549 | class NewUserCollection: |