|
@@ -1070,7 +1070,7 @@ export function init() {
|
|
|
}
|
|
|
|
|
|
export const getTweetUserFollowStatus = (params) => {
|
|
|
- let { tweetId, userList } = params.data;
|
|
|
+ let { tweetId, userList, iframeGUId, type } = JSON.parse(params.data);
|
|
|
let promiseList = [];
|
|
|
for (let i = 0; i < userList.length; i++) {
|
|
|
promiseList[i] = TwitterApiUserByScreenNameReq({ screen_name: userList[i]['name'] });
|
|
@@ -1087,10 +1087,16 @@ export const getTweetUserFollowStatus = (params) => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', {
|
|
|
+ list, tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
+ })
|
|
|
|
|
|
- chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: list, tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
+ // chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: list, tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
}).catch(err => {
|
|
|
- chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: [], tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
+ messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', {
|
|
|
+ list: [], tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
+ })
|
|
|
+ // chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: [], tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -1455,6 +1461,35 @@ export function doTaskTwitterAPI({ task_data, task_type, tasks, iframeId }) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+export function doTaskIframeTwitterAPI(params) {
|
|
|
+ let {tweet_Id, tweet_text, task_type, tasks, iframeGUId} = JSON.parse(params.data);
|
|
|
+ if(task_type == 'tasks') {
|
|
|
+ tasks.forEach((item) => {
|
|
|
+ switch (String(item.type)) {
|
|
|
+ // 关注指定用户
|
|
|
+ case '1':
|
|
|
+ item.relatedUsers.forEach((item) => {
|
|
|
+ if (item.name && item.twitterUserId) {
|
|
|
+ TwitterFollowAPI(item, tweet_Id);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ break
|
|
|
+ // 点赞
|
|
|
+ case '2':
|
|
|
+ TwitterLikeAPI(tweet_Id)
|
|
|
+ break
|
|
|
+ // 推文发推
|
|
|
+ case '10':
|
|
|
+ // 发推
|
|
|
+ TwitterApiCreateTweet({ text: tweet_text, tweet_Id, iframeId: params.iframeId, iframeGUId, iframeMsg: true })
|
|
|
+ break
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if(task_type == 'like') {
|
|
|
+ TwitterLikeAPI(tweet_Id)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export function showJoinDialog(data) {
|
|
|
let iframe = document.querySelector('#nftProjectId')
|
|
|
iframe.style.display = 'block'
|
|
@@ -1601,7 +1636,8 @@ const TwitterLikeAPI = (tweet_Id) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId }) => {
|
|
|
+const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId,
|
|
|
+ iframeGUId, iframeMsg }) => {
|
|
|
let data = {
|
|
|
queryId: "hC1nuE-2d1NX5LYBuuAvtQ",
|
|
|
features: {
|
|
@@ -1647,9 +1683,25 @@ const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId }) => {
|
|
|
"x-twitter-client-language": "en"
|
|
|
},
|
|
|
}).then(function (response) {
|
|
|
+ console.log(response)
|
|
|
+ let data = response.data;
|
|
|
+ if(iframeMsg) {
|
|
|
+ messageCenter.send(iframeId, 'CONTENT_CREATE_TWEET_FINISH', {
|
|
|
+ tweet_Id, iframeId, iframeGUId, response: data, done: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet1', task_data: '', task_done: '是', response, iframeId })
|
|
|
+ }
|
|
|
}).catch(function (err) {
|
|
|
+ console.log('err --1', err)
|
|
|
+ if(iframeMsg) {
|
|
|
+ messageCenter.send(iframeId, 'CONTENT_CREATE_TWEET_FINISH', {
|
|
|
+ tweet_Id, iframeId, iframeGUId, done: false
|
|
|
+ })
|
|
|
+
|
|
|
+ } else {
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet1', task_data: '', task_done: '否', iframeId })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -1677,12 +1729,25 @@ const TwitterApiUserByScreenNameReq = (params) => {
|
|
|
|
|
|
|
|
|
export const TwitterApiUserByScreenName = (params, cb) => {
|
|
|
- let { screen_name, tweetId = '', objectType = '', iframeId = '' } = params;
|
|
|
+ let { screen_name, tweetId = '', objectType = '', iframeId = '', iframeMsg = false, iframeGUId } = params;
|
|
|
|
|
|
TwitterApiUserByScreenNameReq({ screen_name }).then(function (response) {
|
|
|
+ if(iframeMsg) {
|
|
|
+ messageCenter.send(iframeId, 'CONTENT_API_GET_TWEET_USER_INFO_END', {
|
|
|
+ iframeGUId, response: response.data.data || {}, objectType
|
|
|
+ })
|
|
|
+ } else {
|
|
|
chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: response.data.data || {}, tweetId, objectType, iframeId }, () => { })
|
|
|
+ }
|
|
|
+
|
|
|
}).catch(function (err) {
|
|
|
+ if(iframeMsg) {
|
|
|
+ messageCenter.send(iframeId, 'CONTENT_API_GET_TWEET_USER_INFO_END', {
|
|
|
+ iframeGUId, response: {}, objectType
|
|
|
+ })
|
|
|
+ } else {
|
|
|
chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: {}, tweetId, objectType, iframeId }, () => { })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -2719,14 +2784,18 @@ export const showPublishDialog = () => {
|
|
|
}
|
|
|
|
|
|
// 获取推文发送回去
|
|
|
-export const sendContentByTwitterID = (tweet_Id) => {
|
|
|
+export const sendContentByTwitterID = (params) => {
|
|
|
+ let {tweet_Id, iframeGUId} = JSON.parse(params.data);
|
|
|
// 获取内容
|
|
|
- let txt = parseCard.getContentByTwitterId(tweet_Id)
|
|
|
- // 发送
|
|
|
- chrome.runtime.sendMessage({
|
|
|
- actionType: "CONTENT_GET_TWEET_TXT", data: {
|
|
|
- tweet_Id,
|
|
|
- txt
|
|
|
- }
|
|
|
+ let txt = parseCard.getContentByTwitterId(tweet_Id);
|
|
|
+ messageCenter.send(params.iframeId, 'CONTENT_GET_TWEET_TXT', {
|
|
|
+ iframeGUId, tweet_Id, txt
|
|
|
})
|
|
|
+ // 发送
|
|
|
+ // chrome.runtime.sendMessage({
|
|
|
+ // actionType: "CONTENT_GET_TWEET_TXT", data: {
|
|
|
+ // tweet_Id,
|
|
|
+ // txt
|
|
|
+ // }
|
|
|
+ // })
|
|
|
}
|