|
@@ -13,7 +13,7 @@
|
|
|
#
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
-from typing import Any, Optional, Union
|
|
|
+from typing import Any, Optional, Union, Dict
|
|
|
from enum import Enum
|
|
|
from uuid import uuid4
|
|
|
import json
|
|
@@ -30,35 +30,35 @@ class SkywalkerSubscription:
|
|
|
|
|
|
|
|
|
class GraphQLQueryID(Enum):
|
|
|
- appPresence = '17846944882223835'
|
|
|
- asyncAdSub = '17911191835112000'
|
|
|
- clientConfigUpdate = '17849856529644700'
|
|
|
- directStatus = '17854499065530643'
|
|
|
- directTyping = '17867973967082385'
|
|
|
- liveWave = '17882305414154951'
|
|
|
- interactivityActivateQuestion = '18005526940184517'
|
|
|
- interactivityRealtimeQuestionSubmissionsStatus = '18027779584026952'
|
|
|
- interactivitySub = '17907616480241689'
|
|
|
- liveRealtimeComments = '17855344750227125'
|
|
|
- liveTypingIndicator = '17926314067024917'
|
|
|
- mediaFeedback = '17877917527113814'
|
|
|
- reactNativeOTA = '17861494672288167'
|
|
|
- videoCallCoWatchControl = '17878679623388956'
|
|
|
- videoCallInAlert = '17878679623388956'
|
|
|
- videoCallPrototypePublish = '18031704190010162'
|
|
|
- videoCallParticipantDelivery = '17977239895057311'
|
|
|
- zeroProvision = '17913953740109069'
|
|
|
- inappNotification = '17899377895239777'
|
|
|
- businessDelivery = '17940467278199720'
|
|
|
+ APP_PRESENCE = "17846944882223835"
|
|
|
+ ASYNC_AD_SUB = "17911191835112000"
|
|
|
+ CLIENT_CONFIG_UPDATE = "17849856529644700"
|
|
|
+ DIRECT_STATUS = "17854499065530643"
|
|
|
+ DIRECT_TYPING = "17867973967082385"
|
|
|
+ LIVE_WAVE = "17882305414154951"
|
|
|
+ INTERACTIVITY_ACTIVATE_QUESTION = "18005526940184517"
|
|
|
+ INTERACTIVITY_REALTIME_QUESTION_SUBMISSION_STATUS = "18027779584026952"
|
|
|
+ INTERACTIVITY_SUB = "17907616480241689"
|
|
|
+ LIVE_REALTIME_COMMENTS = "17855344750227125"
|
|
|
+ LIVE_TYPING_INDICATOR = "17926314067024917"
|
|
|
+ MEDIA_FEEDBACK = "17877917527113814"
|
|
|
+ REACT_NATIVE_OTA = "17861494672288167"
|
|
|
+ VIDEO_CALL_CO_WATCH_CONTROL = "17878679623388956"
|
|
|
+ VIDEO_CALL_IN_ALERT = "17878679623388956"
|
|
|
+ VIDEO_CALL_PROTOTYPE_PUBLISH = "18031704190010162"
|
|
|
+ VIDEO_CALL_PARTICIPANT_DELIVERY = "17977239895057311"
|
|
|
+ ZERO_PROVISION = "17913953740109069"
|
|
|
+ INAPP_NOTIFICATION = "17899377895239777"
|
|
|
+ BUSINESS_DELIVERY = "17940467278199720"
|
|
|
|
|
|
|
|
|
everclear_subscriptions = {
|
|
|
- "async_ads_subscribe": GraphQLQueryID.asyncAdSub.value,
|
|
|
- "inapp_notification_subscribe_default": GraphQLQueryID.inappNotification.value,
|
|
|
- "inapp_notification_subscribe_comment": GraphQLQueryID.inappNotification.value,
|
|
|
- "inapp_notification_subscribe_comment_mention_and_reply": GraphQLQueryID.inappNotification.value,
|
|
|
- "business_import_page_media_delivery_subscribe": GraphQLQueryID.businessDelivery.value,
|
|
|
- "video_call_participant_state_delivery": GraphQLQueryID.videoCallParticipantDelivery.value,
|
|
|
+ "async_ads_subscribe": GraphQLQueryID.ASYNC_AD_SUB.value,
|
|
|
+ "inapp_notification_subscribe_default": GraphQLQueryID.INAPP_NOTIFICATION.value,
|
|
|
+ "inapp_notification_subscribe_comment": GraphQLQueryID.INAPP_NOTIFICATION.value,
|
|
|
+ "inapp_notification_subscribe_comment_mention_and_reply": GraphQLQueryID.INAPP_NOTIFICATION.value,
|
|
|
+ "business_import_page_media_delivery_subscribe": GraphQLQueryID.BUSINESS_DELIVERY.value,
|
|
|
+ "video_call_participant_state_delivery": GraphQLQueryID.VIDEO_CALL_PARTICIPANT_DELIVERY.value,
|
|
|
}
|
|
|
|
|
|
|
|
@@ -76,14 +76,14 @@ class GraphQLSubscription:
|
|
|
@classmethod
|
|
|
def app_presence(cls, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.appPresence,
|
|
|
+ return cls._fmt(GraphQLQueryID.APP_PRESENCE,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4())},
|
|
|
client_logged=client_logged)
|
|
|
|
|
|
@classmethod
|
|
|
def async_ad(cls, user_id: str, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.asyncAdSub,
|
|
|
+ return cls._fmt(GraphQLQueryID.ASYNC_AD_SUB,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"user_id": user_id},
|
|
|
client_logged=client_logged)
|
|
@@ -91,20 +91,20 @@ class GraphQLSubscription:
|
|
|
@classmethod
|
|
|
def client_config_update(cls, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.clientConfigUpdate,
|
|
|
+ return cls._fmt(GraphQLQueryID.CLIENT_CONFIG_UPDATE,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4())},
|
|
|
client_logged=client_logged)
|
|
|
|
|
|
@classmethod
|
|
|
def direct_status(cls, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.directStatus,
|
|
|
+ return cls._fmt(GraphQLQueryID.DIRECT_STATUS,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4())},
|
|
|
client_logged=client_logged)
|
|
|
|
|
|
@classmethod
|
|
|
def direct_typing(cls, user_id: str, client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.directTyping,
|
|
|
+ return cls._fmt(GraphQLQueryID.DIRECT_TYPING,
|
|
|
input_params={"user_id": user_id},
|
|
|
client_logged=client_logged)
|
|
|
|
|
@@ -112,7 +112,7 @@ class GraphQLSubscription:
|
|
|
def ig_live_wave(cls, broadcast_id: str, receiver_id: str,
|
|
|
subscription_id: Optional[str] = None, client_logged: Optional[bool] = None
|
|
|
) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.liveWave,
|
|
|
+ return cls._fmt(GraphQLQueryID.LIVE_WAVE,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"broadcast_id": broadcast_id, "receiver_id": receiver_id},
|
|
|
client_logged=client_logged)
|
|
@@ -121,7 +121,7 @@ class GraphQLSubscription:
|
|
|
def interactivity_activate_question(cls, broadcast_id: str,
|
|
|
subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.interactivityActivateQuestion,
|
|
|
+ return cls._fmt(GraphQLQueryID.INTERACTIVITY_ACTIVATE_QUESTION,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"broadcast_id": broadcast_id},
|
|
|
client_logged=client_logged)
|
|
@@ -131,7 +131,7 @@ class GraphQLSubscription:
|
|
|
cls, broadcast_id: str, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None
|
|
|
) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.interactivityRealtimeQuestionSubmissionsStatus,
|
|
|
+ return cls._fmt(GraphQLQueryID.INTERACTIVITY_REALTIME_QUESTION_SUBMISSION_STATUS,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"broadcast_id": broadcast_id},
|
|
|
client_logged=client_logged)
|
|
@@ -139,7 +139,7 @@ class GraphQLSubscription:
|
|
|
@classmethod
|
|
|
def interactivity(cls, broadcast_id: str, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.interactivitySub,
|
|
|
+ return cls._fmt(GraphQLQueryID.INTERACTIVITY_SUB,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"broadcast_id": broadcast_id},
|
|
|
client_logged=client_logged)
|
|
@@ -147,7 +147,7 @@ class GraphQLSubscription:
|
|
|
@classmethod
|
|
|
def live_realtime_comments(cls, broadcast_id: str, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.liveRealtimeComments,
|
|
|
+ return cls._fmt(GraphQLQueryID.LIVE_REALTIME_COMMENTS,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"broadcast_id": broadcast_id},
|
|
|
client_logged=client_logged)
|
|
@@ -156,7 +156,7 @@ class GraphQLSubscription:
|
|
|
def live_realtime_typing_indicator(cls, broadcast_id: str,
|
|
|
subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.liveTypingIndicator,
|
|
|
+ return cls._fmt(GraphQLQueryID.LIVE_TYPING_INDICATOR,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"broadcast_id": broadcast_id},
|
|
|
client_logged=client_logged)
|
|
@@ -164,7 +164,7 @@ class GraphQLSubscription:
|
|
|
@classmethod
|
|
|
def media_feedback(cls, feedback_id: str, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.mediaFeedback,
|
|
|
+ return cls._fmt(GraphQLQueryID.MEDIA_FEEDBACK,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"feedback_id": feedback_id},
|
|
|
client_logged=client_logged)
|
|
@@ -172,7 +172,7 @@ class GraphQLSubscription:
|
|
|
@classmethod
|
|
|
def react_native_ota_update(cls, build_number: str, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.reactNativeOTA,
|
|
|
+ return cls._fmt(GraphQLQueryID.REACT_NATIVE_OTA,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"build_number": build_number},
|
|
|
client_logged=client_logged)
|
|
@@ -180,7 +180,7 @@ class GraphQLSubscription:
|
|
|
@classmethod
|
|
|
def video_call_co_watch_control(cls, video_call_id: str, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.videoCallCoWatchControl,
|
|
|
+ return cls._fmt(GraphQLQueryID.VIDEO_CALL_CO_WATCH_CONTROL,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"video_call_id": video_call_id},
|
|
|
client_logged=client_logged)
|
|
@@ -188,7 +188,7 @@ class GraphQLSubscription:
|
|
|
@classmethod
|
|
|
def video_call_in_call_alert(cls, video_call_id: str, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.videoCallInAlert,
|
|
|
+ return cls._fmt(GraphQLQueryID.VIDEO_CALL_IN_ALERT,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"video_call_id": video_call_id},
|
|
|
client_logged=client_logged)
|
|
@@ -197,7 +197,7 @@ class GraphQLSubscription:
|
|
|
def video_call_prototype_publish(cls, video_call_id: str,
|
|
|
subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.videoCallPrototypePublish,
|
|
|
+ return cls._fmt(GraphQLQueryID.VIDEO_CALL_PROTOTYPE_PUBLISH,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"video_call_id": video_call_id},
|
|
|
client_logged=client_logged)
|
|
@@ -205,7 +205,50 @@ class GraphQLSubscription:
|
|
|
@classmethod
|
|
|
def zero_provision(cls, device_id: str, subscription_id: Optional[str] = None,
|
|
|
client_logged: Optional[bool] = None) -> str:
|
|
|
- return cls._fmt(GraphQLQueryID.zeroProvision,
|
|
|
+ return cls._fmt(GraphQLQueryID.ZERO_PROVISION,
|
|
|
input_params={"client_subscription_id": subscription_id or str(uuid4()),
|
|
|
"device_id": device_id},
|
|
|
client_logged=client_logged)
|
|
|
+
|
|
|
+
|
|
|
+_topic_map: Dict[str, str] = {
|
|
|
+ "/pp": "34", # unknown
|
|
|
+ "/ig_sub_iris": "134",
|
|
|
+ "/ig_sub_iris_response": "135",
|
|
|
+ "/ig_message_sync": "146",
|
|
|
+ "/ig_send_message": "132",
|
|
|
+ "/ig_send_message_response": "133",
|
|
|
+ "/ig_realtime_sub": "149",
|
|
|
+ "/pubsub": "88",
|
|
|
+ "/t_fs": "102", # Foreground state
|
|
|
+ "/graphql": "9",
|
|
|
+ "/t_region_hint": "150",
|
|
|
+ "/mqtt_health_stats": "/mqtt_health_stats",
|
|
|
+ "179": "179", # also unknown
|
|
|
+}
|
|
|
+
|
|
|
+_reverse_topic_map: Dict[str, str] = {value: key for key, value in _topic_map.items()}
|
|
|
+
|
|
|
+
|
|
|
+class RealtimeTopic(Enum):
|
|
|
+ SUB_IRIS = "/ig_sub_iris"
|
|
|
+ SUB_IRIS_RESPONSE = "/ig_sub_iris_response"
|
|
|
+ MESSAGE_SYNC = "/ig_message_sync"
|
|
|
+ SEND_MESSAGE = "/ig_send_message"
|
|
|
+ SEND_MESSAGE_RESPONSE = "/ig_send_message_response"
|
|
|
+ REALTIME_SUB = "/ig_realtime_sub"
|
|
|
+ PUBSUB = "/pubsub"
|
|
|
+ FOREGROUND_STATE = "/t_fs"
|
|
|
+ GRAPHQL = "/graphql"
|
|
|
+ REGION_HINT = "/t_region_hint"
|
|
|
+ MQTT_HEALTH_STATS = "/mqtt_health_stats"
|
|
|
+ UNKNOWN_PP = "/pp"
|
|
|
+ UNKNOWN_179 = "179"
|
|
|
+
|
|
|
+ @property
|
|
|
+ def encoded(self) -> str:
|
|
|
+ return _topic_map[self.value]
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def decode(val: str) -> 'RealtimeTopic':
|
|
|
+ return RealtimeTopic(_reverse_topic_map[val])
|