public ProcessAccountSynchronisation(SyncAccount syncAccount, ITwitterService twitterService, IMastodonService mastodonService, ISyncAccountsRepository syncAccountsRepository)
 {
     this._syncAccount       = syncAccount;
     _twitterService         = twitterService;
     _mastodonService        = mastodonService;
     _syncAccountsRepository = syncAccountsRepository;
 }
Exemplo n.º 2
0
        public async Task RegisterNewAccountAsync(string twitterName, string mastodonName, string mastodonInstance)
        {
            //Ensure Twitter client is properly set
            _twitterService.EnsureTwitterIsReady();

            //Create mastodon profile
            var appInfo = await _mastodonService.GetAppInfoAsync(mastodonInstance);

            var userToken = await _mastodonService.GetAccessTokenAsync(appInfo, mastodonName, mastodonInstance);

            var newSyncProfile = new SyncAccount
            {
                Id                  = Guid.NewGuid(),
                TwitterName         = twitterName,
                MastodonName        = mastodonName,
                MastodonInstance    = mastodonInstance,
                MastodonAccessToken = userToken,
                LastSyncTweetId     = -1
            };

            //Save new profil
            var allAccounts = _syncAccountsRepository.GetAllAccounts().ToList();

            allAccounts.Add(newSyncProfile);
            _syncAccountsRepository.SaveAccounts(allAccounts.ToArray());
        }
Exemplo n.º 3
0
 private SyncTarget GetSyncTarget(SyncAccount account)
 {
     return(new SyncTarget
     {
         Id = account.Id,
         Name = account.Name
     });
 }
Exemplo n.º 4
0
        public void UpdateAccount(SyncAccount account)
        {
            var allAccounts = GetAllAccounts().ToList();

            allAccounts.Remove(allAccounts.Find(x => x.Id == account.Id));
            allAccounts.Add(account);
            SaveAccounts(allAccounts.ToArray());
        }
 public ProcessAccountSynchronisation GetAccountSync(SyncAccount account)
 {
     return(new ProcessAccountSynchronisation(account, _twitterService, _mastodonService, _syncAccountsRepository));
 }