mirror of
https://github.com/simon987/parler_feed.git
synced 2025-04-04 08:23:04 +00:00
124 lines
2.5 KiB
Python
124 lines
2.5 KiB
Python
import json
|
|
|
|
|
|
class ParlerItem:
|
|
def __init__(self):
|
|
self.data = None
|
|
|
|
def serialize(self):
|
|
self.data["_v"] = self.version()
|
|
self.data["_id"] = self.item_id()
|
|
return json.dumps(self.data, separators=(',', ':'), ensure_ascii=False, sort_keys=True)
|
|
|
|
def item_type(self) -> str:
|
|
raise NotImplementedError
|
|
|
|
def item_id(self) -> str:
|
|
raise NotImplementedError
|
|
|
|
def version(self):
|
|
return "1.0"
|
|
|
|
|
|
class ParlerProfile(ParlerItem):
|
|
def __init__(self, data, int_id):
|
|
super().__init__()
|
|
self.data = data
|
|
self.data["_int_id"] = int_id
|
|
|
|
def item_type(self):
|
|
return "profile"
|
|
|
|
def item_id(self):
|
|
return self.data["id"]
|
|
|
|
|
|
class ParlerFollower(ParlerItem):
|
|
|
|
def __init__(self, user_id, follower_id, approx_date):
|
|
super().__init__()
|
|
self.data = {
|
|
"user_id": user_id,
|
|
"follower_id": follower_id,
|
|
"approx_date": approx_date,
|
|
}
|
|
|
|
def item_type(self):
|
|
return "follower"
|
|
|
|
def item_id(self):
|
|
return self.data["user_id"] + self.data["follower_id"]
|
|
|
|
|
|
class ParlerFollowee(ParlerItem):
|
|
|
|
def __init__(self, user_id, followee_id, approx_date):
|
|
super().__init__()
|
|
self.data = {
|
|
"user_id": user_id,
|
|
"followee_id": followee_id,
|
|
"approx_date": approx_date
|
|
}
|
|
|
|
def item_type(self):
|
|
return "followee"
|
|
|
|
def item_id(self):
|
|
return self.data["user_id"] + self.data["followee_id"]
|
|
|
|
|
|
class ParlerPost(ParlerItem):
|
|
|
|
def __init__(self, data):
|
|
super().__init__()
|
|
self.data = data
|
|
|
|
def item_type(self):
|
|
return "post"
|
|
|
|
def item_id(self):
|
|
return self.data["id"]
|
|
|
|
|
|
class ParlerPostRef(ParlerItem):
|
|
|
|
def __init__(self, post_id, user_id, approx_date):
|
|
super().__init__()
|
|
self.data = {
|
|
"post_id": post_id,
|
|
"user_id": user_id,
|
|
"approx_date": approx_date
|
|
}
|
|
|
|
def item_type(self):
|
|
return "postref"
|
|
|
|
def item_id(self):
|
|
return self.data["user_id"] + self.data["post_id"]
|
|
|
|
|
|
class ParlerUrl(ParlerItem):
|
|
|
|
def __init__(self, data):
|
|
super().__init__()
|
|
self.data = data
|
|
|
|
def item_type(self):
|
|
return "url"
|
|
|
|
def item_id(self):
|
|
return self.data["_id"]
|
|
|
|
|
|
class ParlerComment(ParlerItem):
|
|
|
|
def __init__(self, data):
|
|
super().__init__()
|
|
self.data = data
|
|
|
|
def item_type(self):
|
|
return "comment"
|
|
|
|
def item_id(self):
|
|
return self.data["_id"]
|