-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
Major
- MAC isn't swapped after swapping bed owners.
YunNet-Backend/api/management/bed_change.py
Lines 50 to 70 in 56c9ec3
@bp_bed_change.route("/bed-change", methods=["PUT"]) @permission("api.bed.exchange") async def exchange_bed(request): source_bed = request.json["source_bed"] dest_bed = request.json["dest_bed"] # for validate uid # source_username = request.json["source_username"] # dest_username = request.json["dest_username"] source_ip = await Ip.get_ip_by_bed(source_bed) dest_ip = await Ip.get_ip_by_bed(dest_bed) if source_ip is None or dest_ip is None: return messages.BAD_REQUEST source_uid = source_ip[0]["uid"] dest_uid = dest_ip[0]["uid"] await Ip.assign_user(dest_ip[0]["ip"], source_uid) await Ip.assign_user(source_ip[0]["ip"], dest_uid) return messages.OPERATION_SUCCESS - UNIQUE exception is not handled.
YunNet-Backend/api/user/mac.py
Line 77 in 56c9ec3
if await MAC.set_mac(target_ip["ip"], mac):
Lines 37 to 56 in 56c9ec3
async def set_mac(ip: str, mac: str) -> bool: """Set mac by account_id Args: ip: ip mac:mac address Returns: bool, If set success return True, if catch error return False. """ async with SQLPool.acquire() as conn: async with conn.cursor() as cur: sql = ( "UPDATE `iptable` SET `mac` = %s,`is_updated` = 0 WHERE `ip` = %s " ) para_input = (mac, ip) await cur.execute(sql, para_input) await conn.commit() return True
Minor & To-do
- Remove legacy
aiohttpinstance underappinbackend.pyand move toBase.aiohttpSession.
Line 51 in 56c9ec3
app.aiohttp_session = aiohttp.ClientSession(loop=loop) -
BackgroundJobs/bulk_import.pyis untested. - Add
limitparameter inapi.management.user.query. (Queryingadminaccounts returns all IP)
Missing API endpoints
- User creation/deletion
- Role(refered as group in source code) assignment/revocation
Possible Improvements
- Move bed change log and action log to MySQL and use MongoDB entirely just for API access details.
- Merge
/api/management/route to/api/.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request