Skip to content

Commit

Permalink
Merge pull request #69 from Lost-MSth/dev
Browse files Browse the repository at this point in the history
Update to v2.10.0
  • Loading branch information
Lost-MSth authored Oct 4, 2022
2 parents cbd2198 + a04df8b commit 2a3ee0f
Show file tree
Hide file tree
Showing 50 changed files with 1,323 additions and 1,113 deletions.
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,39 @@ It is just so interesting. What it can do is under exploration.
> Tips: When updating, please keep the original database in case of data loss.

### Version 2.9.1
- 适用于Arcaea 4.0.255版本 For Arcaea 4.0.255
- 新搭档 **光&对立(Reunion)** 已解锁 Unlock the character **Hikari & Tairitsu(Reunion)**.
- 修复角色数值问题 Fix a bug that the characters have wrong values.
- 修复用户物品相关问题 Fix a bug about users' items.

### Version 2.10.0
- 适用于Arcaea 4.1.0版本 For Arcaea 4.1.0
- 新搭档 **咲姬** 已解锁 Unlock the character **Saki**.
- 新搭档 **刹那** 已解锁 Unlock the character **Setsuna**.
- 完善了日志系统 Improve the log system.
- 现在可以利用`songlist`确保`3.aff`以外文件不被下载 Now you can use `songlist` to ensure that files other than `3.aff` should not be downloaded. [#60](https://github.com/Lost-MSth/Arcaea-server/issues/60)
- 适配v4.0.0以下版本的客户端云存档 Ensure that the clients under v4.0.0 can upload the cloud save.
- 优化数据库索引 Optimize database indices.
- 尝试确保LinkPlay服务器的线程安全,现在此功能将作为独立服务端 Try to ensure thread safety in LinkPlay server. Now this function will be served as an independent server.
- 对API接口的分数列表添加歌曲名 Add song names for getting the score list in API.
- 为下载错误增添HTTP状态码 Add HTTP status code when meeting download error.

- 修复iOS客户端因世界模式地图数据闪退的问题 Fix a bug when world maps' data don't have some unnecessary parts the client of iOS may break down.
- 修复API接口无数据`GET`请求导致报错的问题 Fix a bug that `GET` requests without data will report an error in API. [#50](https://github.com/Lost-MSth/Arcaea-server/issues/50)
- 修复`aggregate`请求无法捕获内部错误的问题 Fix a bug that `aggregate` requests will get an error when the inner function raises an error.
- 修复因错误设置主键导致课程模式谱面无法相同的问题 Fix a bug that the charts of a course cannot be the same because of the incorrect primary keys.
- 修复无谱面数据时世界排名分计算出错的问题 Fix a bug that global ranking scores cannot be calculated if there are no chart in the database. [#61](https://github.com/Lost-MSth/Arcaea-server/issues/61)
- 修复条件满足但隐藏段位依然无法解锁的问题 Fix a bug that the hidden courses cannot appear even if their requirements are satisfied.
- 修复Finale挑战中某些无法解锁的问题 Fix a bug that something of the finale challenge cannot be unlocked.
- 修复用户物品数量无法为0的问题,此问题导致了一些购买操作异常 Fix a bug that the users' items will not be zero, which will disturb some purchase operations.
- 修复角色等级能超过最大等级的问题 Fix a bug that the level of the character can exceed the max level.
- 修复使用`以太之滴`升级角色时应答不正确的问题 Fix a bug that the response is incorrect when upgrading the characters by `generic core`.
- 修复`源韵强化`数值显示不正确的问题 Fix a bug that the `prog boost` shows the incorrect value.
- 修复世界模式奖励可能被重复发放的问题 Fix a bug that the rewards can be get repeatedly in World Mode.
- 修复世界Boss的第二管血量无法削减的问题 Fix a bug that second tube of blood of the world boss won't change.
- 修复我的排名显示不正确的问题 Fix a bug that `my rank` doesn't work correctly.
- 修复在歌曲结束后无法及时轮换房主的问题 Fix a bug that the room host will be changed late when finishing a song.


## 运行环境与依赖 Running environment and requirements
- Windows/Linux/Mac OS/Android...
- Python 3
- Flask module >= 2.0, Cryptography module
- Flask module >= 2.0, Cryptography module >= 35.0.0
- Charles, IDA, proxy app... (optional)

<!--
Expand Down
32 changes: 28 additions & 4 deletions latest version/api/api_auth.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import functools
from functools import wraps
from traceback import format_exc

from core.api_user import APIUser
from core.error import ArcError, NoAccess, PostError
from core.sql import Connect
from flask import current_app
from setting import Config

from .api_code import error_return
Expand All @@ -11,10 +13,11 @@
def role_required(request, powers=[]):
'''api token验证,写成了修饰器'''
def decorator(view):
@functools.wraps(view)
@wraps(view)
def wrapped_view(*args, **kwargs):
try:
request.json # 检查请求json格式
if request.data:
request.json # 检查请求json格式
except:
return error_return(PostError('Payload must be a valid json', api_error_code=-1), 400)

Expand Down Expand Up @@ -56,10 +59,13 @@ def request_json_handle(request, required_keys=[], optional_keys=[]):
'''

def decorator(view):
@functools.wraps(view)
@wraps(view)
def wrapped_view(*args, **kwargs):

data = {}
if not request.data:
return view(data, *args, **kwargs)

for key in required_keys:
if key not in request.json:
return error_return(PostError('Missing parameter: ' + key, api_error_code=-100))
Expand All @@ -73,3 +79,21 @@ def wrapped_view(*args, **kwargs):

return wrapped_view
return decorator


def api_try(view):
'''替代try/except,记录`ArcError`为warning'''
@wraps(view)
def wrapped_view(*args, **kwargs):
try:
data = view(*args, **kwargs)
if data is None:
return error_return()
else:
return data
except ArcError as e:
if Config.ALLOW_WARNING_LOG:
current_app.logger.warning(format_exc())
return error_return(e, e.status)

return wrapped_view
40 changes: 17 additions & 23 deletions latest version/api/songs.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,42 @@
from core.error import ArcError, NoData
from core.error import NoData
from core.song import Song
from core.sql import Connect, Query, Sql
from flask import Blueprint, request

from .api_auth import request_json_handle, role_required
from .api_code import error_return, success_return
from .api_auth import api_try, request_json_handle, role_required
from .api_code import success_return
from .constant import Constant

bp = Blueprint('songs', __name__, url_prefix='/songs')


@bp.route('/<string:song_id>', methods=['GET'])
@role_required(request, ['select', 'select_song_info'])
@api_try
def songs_song_get(user, song_id):
'''查询歌曲信息'''
with Connect() as c:
try:
s = Song(c, song_id).select()
return success_return(s.to_dict())
except ArcError as e:
return error_return(e)
return error_return()
s = Song(c, song_id).select()
return success_return(s.to_dict())


@bp.route('', methods=['GET'])
@role_required(request, ['select', 'select_song_info'])
@request_json_handle(request, optional_keys=Constant.QUERY_KEYS)
@api_try
def songs_get(data, user):
'''查询全歌曲信息'''
A = ['song_id', 'name']
B = ['song_id', 'name', 'rating_pst',
'rating_prs', 'rating_ftr', 'rating_byn']
with Connect() as c:
try:
query = Query(A, A, B).from_data(data)
x = Sql(c).select('chart', query=query)
r = []
for i in x:
r.append(Song(c).from_list(i))

if not r:
raise NoData(api_error_code=-2)

return success_return([x.to_dict() for x in r])
except ArcError as e:
return error_return(e)
return error_return()
query = Query(A, A, B).from_data(data)
x = Sql(c).select('chart', query=query)
r = []
for i in x:
r.append(Song(c).from_list(i))

if not r:
raise NoData(api_error_code=-2)

return success_return([x.to_dict() for x in r])
33 changes: 14 additions & 19 deletions latest version/api/token.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
from base64 import b64decode

from core.api_user import APIUser
from core.error import ArcError, PostError
from core.error import PostError
from core.sql import Connect
from flask import Blueprint, request

from .api_auth import request_json_handle, role_required
from .api_code import error_return, success_return
from .api_auth import api_try, request_json_handle, role_required
from .api_code import success_return

bp = Blueprint('token', __name__, url_prefix='/token')


@bp.route('', methods=['POST'])
@request_json_handle(request, required_keys=['auth'])
@api_try
def token_post(data):
'''
登录,获取token\
Expand All @@ -21,37 +22,31 @@ def token_post(data):
try:
auth_decode = bytes.decode(b64decode(data['auth']))
except:
return error_return(PostError(api_error_code=-100))
raise PostError(api_error_code=-100)
if not ':' in auth_decode:
return error_return(PostError(api_error_code=-100))
raise PostError(api_error_code=-100)
name, password = auth_decode.split(':', 1)

with Connect() as c:
try:
user = APIUser(c)
user.login(name, password, request.remote_addr)
return success_return({'token': user.token, 'user_id': user.user_id})
except ArcError as e:
return error_return(e)
return error_return()
user = APIUser(c)
user.login(name, password, request.remote_addr)
return success_return({'token': user.token, 'user_id': user.user_id})


@bp.route('', methods=['GET'])
@role_required(request, ['select_me', 'select'])
@api_try
def token_get(user):
'''判断登录有效性'''
return success_return()


@bp.route('', methods=['DELETE'])
@role_required(request, ['change_me', 'select_me', 'select'])
@api_try
def token_delete(user):
'''登出'''
with Connect() as c:
try:
user.c = c
user.logout()
return success_return()
except ArcError as e:
return error_return(e)
return error_return()
user.c = c
user.logout()
return success_return()
Loading

0 comments on commit 2a3ee0f

Please sign in to comment.