refactor: Redesign twitter trigger and actions

This commit is contained in:
Faruk AYDIN
2022-10-06 10:46:22 +03:00
parent 63ffd1f720
commit 77624acc01
18 changed files with 332 additions and 50 deletions

View File

@@ -1,6 +1,4 @@
import { IGlobalVariable } from '@automatisch/types';
import getCurrentUser from '../../common/get-current-user';
import getUserByUsername from '../../common/get-user-by-username';
import getUserTweets from '../../common/get-user-tweets';
export default {
@@ -20,18 +18,13 @@ export default {
],
async run($: IGlobalVariable) {
return this.getTweets($, await $.db.flow.lastInternalId());
return await getUserTweets($, {
currentUser: true,
lastInternalId: $.db.flow.lastInternalId,
});
},
async testRun($: IGlobalVariable) {
return this.getTweets($);
},
async getTweets($: IGlobalVariable, lastInternalId?: string) {
const { username } = await getCurrentUser($);
const user = await getUserByUsername($, username);
const tweets = await getUserTweets($, user.id, lastInternalId);
return tweets;
return await getUserTweets($, { currentUser: true });
},
};