Added profile_info endpoint
This commit is contained in:
parent
09172d9c1e
commit
8d97d1fbf7
2 changed files with 25 additions and 2 deletions
|
|
@ -11,7 +11,7 @@
|
|||
* Added the capability to change password.
|
||||
* Corrected a bug into `pwdhash`: it accepted an argument, but pulled data from the form instead of processing it. Now it uses the argument.
|
||||
* Schema changes: added column `telegram` to `UserProfile` table. To update schema, execute the script `migrate_0_6_to_0_7.py`
|
||||
* Adding public API. Each of the API endpoints take a mandatory query string argument: the access token, generated by a separate endpoint at `/get_access_token` and stored into the client. All API routes start with `/api/V1`. Added endpoints `feed` and `create`.
|
||||
* Adding public API. Each of the API endpoints take a mandatory query string argument: the access token, generated by a separate endpoint at `/get_access_token` and stored into the client. All API routes start with `/api/V1`. Added endpoints `feed`, `create` and `profile_info`.
|
||||
|
||||
## 0.6.0
|
||||
|
||||
|
|
|
|||
25
app/api.py
25
app/api.py
|
|
@ -1,5 +1,5 @@
|
|||
from flask import Blueprint, jsonify, request
|
||||
import sys, datetime
|
||||
import sys, datetime, re
|
||||
from functools import wraps
|
||||
from .models import User, Message
|
||||
from .utils import check_access_token, Visibility
|
||||
|
|
@ -94,3 +94,26 @@ def create(self):
|
|||
push_notification('mention', mention_user, user=user.id)
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
|
||||
@bp.route('/profile_info/<userid>', methods=['GET'])
|
||||
@validate_access
|
||||
def profile_info(self, userid):
|
||||
if userid == 'self':
|
||||
user = self
|
||||
elif userid.isdigit():
|
||||
user = User[id]
|
||||
else:
|
||||
raise ValueError('userid should be an integer or "self"')
|
||||
profile = user.profile
|
||||
return {
|
||||
"user": {
|
||||
"id": user.id,
|
||||
"username": user.username,
|
||||
"full_name": profile.full_name,
|
||||
"biography": profile.biography,
|
||||
"website": profile.website,
|
||||
"generation": profile.year,
|
||||
"instagram": profile.instagram,
|
||||
"facebook": profile.facebook,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue