def posts(username): mongo.db.posts.remove({}) user = User.get_from_username("critique") for i in range(20): post = Post.create_post(user, [username], "This is a Critique post!", "Test post " + str(i)) print(post.send(user, notify=False)) return Reply().ok()
def notify(self, users, requester): from app.Models.User import User user_keys = [ user.get_info("notificationKey") for user in User.get_from_username(users) ] url = 'https://fcm.googleapis.com/fcm/send' key = 'AAAAxe-zm-c:APA91bFo5NK_jcUydvxbwbp1wWD3KCND2ul9xRLvZvi14aNjbAeQi6eJkbdU9wiFwawo7b6Af3rPuqoUH8q0vOfGYA40nRpIC436_SxBx2wbC1pl_CXTkA2Q_ev_yb-RUXQF66hS1YZq' body = { "registration_ids": user_keys, "priority": "high", "data": { "title": "Critique", "body": "from " + requester.username, } } headers = { "Content-Type": "application/json", "Authorization": "key=" + key } r = requests.post(url, data=json.dumps(body), headers=headers) return Reply(str(r.reason)).ok()
def get_patch(username): user = User.get_from_username(username) print(user) path = user.get_patch_path() return send_file(path, mimetype='image/png')