コード例 #1
0
 public ProcessAccountSynchronisation(SyncAccount syncAccount, ITwitterService twitterService, IMastodonService mastodonService, ISyncAccountsRepository syncAccountsRepository)
 {
     this._syncAccount       = syncAccount;
     _twitterService         = twitterService;
     _mastodonService        = mastodonService;
     _syncAccountsRepository = syncAccountsRepository;
 }
コード例 #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());
        }
コード例 #3
0
 private SyncTarget GetSyncTarget(SyncAccount account)
 {
     return(new SyncTarget
     {
         Id = account.Id,
         Name = account.Name
     });
 }
コード例 #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());
        }
コード例 #5
0
 public ProcessAccountSynchronisation GetAccountSync(SyncAccount account)
 {
     return(new ProcessAccountSynchronisation(account, _twitterService, _mastodonService, _syncAccountsRepository));
 }