Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Twitter/X workflow task to match updated view names #15930

Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
66864b5
Rename workflow task to match updated view names to resolve missing s…
davidpuplava Apr 30, 2024
62af19b
Add data migration to update existing workflows to use updated Twiite…
davidpuplava May 2, 2024
ae4d618
Refactor content item migrations to match how it's done in Lucene Sea…
davidpuplava May 3, 2024
b3dd976
Refactor unnecessary method call inline to calling method to remove w…
davidpuplava May 8, 2024
c55b807
Merge branch 'main' into davidpuplava/update-x-status-task-shape-not-…
MikeAlhayek May 16, 2024
5ba3d09
Merge branch 'main' into davidpuplava/update-x-status-task-shape-not-…
Piedone Jun 20, 2024
41e5642
Merge tag 'before-formatting
davidpuplava Aug 15, 2024
b95fec7
Format code
davidpuplava Aug 16, 2024
7941494
Merge tag 'formatting'
davidpuplava Aug 16, 2024
17160a6
Refactor Twitter to X migration to simplify database logic; edited na…
davidpuplava Aug 16, 2024
7133943
Merge remote-tracking branch 'upstream/main' into davidpuplava/update…
davidpuplava Aug 16, 2024
2916586
Simplify using expressions for database operations
davidpuplava Aug 16, 2024
43419a9
Merge remote-tracking branch 'upstream/main' into davidpuplava/update…
davidpuplava Aug 17, 2024
ba89043
Rename types/classes/ids back to before X/Twitter rebrand; removed mi…
davidpuplava Aug 17, 2024
e1679a4
Update X/Twitter documentation links in Admin UI
davidpuplava Aug 19, 2024
9a1d3d4
Merge remote-tracking branch 'upstream/main' into davidpuplava/update…
davidpuplava Aug 19, 2024
14e60dc
Remove reference to YesSql project previously added when Migration ex…
davidpuplava Aug 20, 2024
c9cecb0
Remove unused using statement
davidpuplava Aug 20, 2024
84542b9
Fix typo in documentation link to X/Twitter integration docs
davidpuplava Aug 20, 2024
31100c5
Merge remote-tracking branch 'upstream/main' into davidpuplava/update…
davidpuplava Aug 20, 2024
a4504f3
Remove another unused using statement
davidpuplava Aug 20, 2024
8d16b9d
Merge branch 'main' into davidpuplava/update-x-status-task-shape-not-…
hishamco Aug 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Threading.Tasks;
using Dapper;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OrchardCore.Data;
using OrchardCore.Data.Migration;
using OrchardCore.Environment.Shell;
using OrchardCore.Environment.Shell.Descriptor.Models;
using OrchardCore.Environment.Shell.Scope;
using YesSql;

namespace OrchardCore.Twitter.Migrations;

public sealed class TwitterToXMigrations : DataMigration
{
private readonly IDbConnectionAccessor _dbAccessor;
private readonly IStore _store;
private readonly ILogger<TwitterToXMigrations> _logger;
private readonly string _tablePrefix;

public TwitterToXMigrations(IDbConnectionAccessor dbAccessor, IStore store, ILogger<TwitterToXMigrations> logger, ShellSettings settings)
{
_dbAccessor = dbAccessor;
_store = store;
_logger = logger;
_tablePrefix = settings["TablePrefix"];
}

public async Task<int> CreateAsync()
{
await using var connection = _dbAccessor.CreateConnection();
await connection.OpenAsync();

using var transaction = await connection.BeginTransactionAsync();

_logger.LogDebug("Updating X (Twitter) Workflow Items");

try
{
var dialect = _store.Configuration.SqlDialect;
var documentTableName = _store.Configuration.TableNameConvention.GetDocumentTable();

var table = dialect.QuoteForTableName($"{_tablePrefix}{documentTableName}", _store.Configuration.Schema);
var contentColumn = dialect.QuoteForColumnName("Content");
var typeColumn = dialect.QuoteForColumnName("Type");

var updateCmd = $"UPDATE {table} SET {contentColumn} = REPLACE({contentColumn}, 'UpdateTwitterStatusTask', 'UpdateXTwitterStatusTask') WHERE {typeColumn} = 'OrchardCore.Workflows.Models.WorkflowType, OrchardCore.Workflows.Abstractions'";

await connection.ExecuteAsync(updateCmd, null, transaction);

await transaction.CommitAsync();

_logger.LogDebug("Updated X (Twitter) Workflow Items");
}
catch (Exception e)
{
await transaction.RollbackAsync();
_logger.LogError(e, "An error occurred while updating X (Twitter) Workflow Items");

throw;
}

return 1;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Admin.Abstractions\OrchardCore.Admin.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ContentManagement.Abstractions\OrchardCore.ContentManagement.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Data.Abstractions\OrchardCore.Data.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Data.YesSql\OrchardCore.Data.YesSql.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.DisplayManagement\OrchardCore.DisplayManagement.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Module.Targets\OrchardCore.Module.Targets.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private async Task<TwitterSettings> GetTwitterSettingsAsync()
{
if (_shellSettings.IsRunning())
{
_logger.LogWarning("Twitter is not correctly configured.");
_logger.LogWarning("X (Twitter) is not correctly configured.");
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ public void Configure(AuthenticationOptions options)
if (string.IsNullOrWhiteSpace(settings.Item1.ConsumerKey) ||
string.IsNullOrWhiteSpace(settings.Item1.ConsumerSecret))
{
_logger.LogWarning("The Twitter login provider is enabled but not configured.");
_logger.LogWarning("The X (Twitter) login provider is enabled but not configured.");

return;
}

options.AddScheme(TwitterDefaults.AuthenticationScheme, builder =>
{
builder.DisplayName = "Twitter";
builder.DisplayName = "X (Twitter)";
builder.HandlerType = typeof(TwitterHandler);
});
}
Expand All @@ -91,7 +91,7 @@ public void Configure(string name, TwitterOptions options)
}
catch
{
_logger.LogError("The Twitter Consumer Secret could not be decrypted. It may have been encrypted using a different key.");
_logger.LogError("The X (Twitter) Consumer Secret could not be decrypted. It may have been encrypted using a different key.");
}

if (settings.Item2.CallbackPath.HasValue)
Expand All @@ -114,7 +114,7 @@ private async Task<Tuple<TwitterSettings, TwitterSigninSettings>> GetSettingsAsy
{
if (_shellSettings.IsRunning())
{
_logger.LogWarning("Integration with Twitter is not correctly configured.");
_logger.LogWarning("Integration with X (Twitter) is not correctly configured.");
}

return null;
Expand Down
3 changes: 3 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Http.Resilience;
using Microsoft.Extensions.Options;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.Recipes;
using OrchardCore.Security.Permissions;
using OrchardCore.Settings;
using OrchardCore.Twitter.Drivers;
using OrchardCore.Twitter.Migrations;
using OrchardCore.Twitter.Recipes;
using OrchardCore.Twitter.Services;
using OrchardCore.Twitter.Settings;
Expand Down Expand Up @@ -58,6 +60,7 @@ public override void ConfigureServices(IServiceCollection services)
}
})
);
services.AddDataMigration<TwitterToXMigrations>();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
@using OrchardCore.Workflows.ViewModels
@using OrchardCore.Twitter.Workflows.Activities

@model ActivityViewModel<UpdateTwitterStatusTask>
@model ActivityViewModel<UpdateXTwitterStatusTask>

<header>
<h4><i class="fa-brands fa-x-twitter" aria-hidden="true"></i>@Model.Activity.GetTitleOrDefault(() => T["Update X Status"])</h4>
<h4><i class="fa-brands fa-x-twitter" aria-hidden="true"></i>@Model.Activity.GetTitleOrDefault(() => T["Update X (Twitter) Status"])</h4>
</header>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@model UpdateTwitterStatusTaskViewModel

<div class="mb-3" asp-validation-class-for="StatusTemplate">
<label asp-for="StatusTemplate" class="form-label">@T["Template for updating twitter status"]</label>
<label asp-for="StatusTemplate" class="form-label">@T["Template for updating X (Twitter) status"]</label>
<input type="text" asp-for="StatusTemplate" class="form-control code" />
<span asp-validation-for="StatusTemplate"></span>
<span class="hint">@T["The status text of the post."]</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<h4 class="card-title"><i class="fa-brands fa-x-twitter" aria-hidden="true"></i>@T["Update X Status"]</h4>
<h4 class="card-title"><i class="fa-brands fa-x-twitter" aria-hidden="true"></i>@T["Update X (Twitter) Status"]</h4>
<p>@T["Create a post"]</p>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<span class="icon"><i class="fa-brands fa-x-twitter" aria-hidden="true"></i></span><span class="title">@T["X"]</span>
<span class="icon"><i class="fa-brands fa-x-twitter" aria-hidden="true"></i></span><span class="title">@T["X (Twitter)"]</span>
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<p class="alert alert-danger">@T["An error occurred while decrypting a setting. Please apply and save."]</p>
}

<h3>@T["X Integration Settings"]</h3>
<h3>@T["X (Twitter) Integration Settings"]</h3>

<div class="mb-3 row" asp-validation-class-for="APIKey">
<div class="col-large col-12 col-sm-12 col-md-12 col-lg-12 col-xl-9">
<label asp-for="APIKey" class="form-label">@T["API key"]</label>
<input asp-for="APIKey" class="form-control" autocomplete="off" />
<span asp-validation-for="APIKey"></span>
<span class="hint">@T["The API key defined in the Keys and tokens tab of twitter app dashboard."]</span>
<span class="hint">@T["The API key defined in the Keys and tokens tab of X (Twitter) app dashboard."]</span>
</div>
</div>

Expand All @@ -27,7 +27,7 @@
<label asp-for="APISecretKey" class="form-label">@T["API secret key"]</label>
<input asp-for="APISecretKey" class="form-control" type="password" value="@Model.APISecretKey" autocomplete="off" />
<span asp-validation-for="APISecretKey"></span>
<span class="hint">@T["The API secret defined in the Keys and tokens tab of twitter app dashboard."]</span>
<span class="hint">@T["The API secret defined in the Keys and tokens tab of X (Twitter) app dashboard."]</span>
</div>
</div>

Expand All @@ -36,7 +36,7 @@
<label asp-for="AccessToken" class="form-label">@T["Access Token"]</label>
<input asp-for="AccessToken" class="form-control" autocomplete="off" />
<span asp-validation-for="AccessToken"></span>
<span class="hint">@T["The Access Token defined in the Keys and tokens tab of twitter app dashboard."]</span>
<span class="hint">@T["The Access Token defined in the Keys and tokens tab of X (Twitter) app dashboard."]</span>
</div>
</div>

Expand All @@ -45,6 +45,6 @@
<label asp-for="AccessTokenSecret" class="form-label">@T["Access Token Secret"]</label>
<input asp-for="AccessTokenSecret" class="form-control" type="password" value="@Model.AccessTokenSecret" autocomplete="off" />
<span asp-validation-for="AccessTokenSecret"></span>
<span class="hint">@T["The Access Token Secret in the Keys and tokens tab of twitter app dashboard."]</span>
<span class="hint">@T["The Access Token Secret in the Keys and tokens tab of X (Twitter) app dashboard."]</span>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a class="seedoc" href="@(OrchardCore.Admin.Constants.DocsUrl)reference/modules/Twitter/#sign-in-with-x" target="_blank">@T["See documentation"]</a>
</p>

<h3>@T["Sign in with X Settings"]</h3>
<h3>@T["Sign in with X (Twitter) Settings"]</h3>

<div class="mb-3 row" asp-validation-class-for="CallbackPath">
<div class="col-large col-12 col-sm-12 col-md-12 col-lg-12 col-xl-9">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@

namespace OrchardCore.Twitter.Workflows.Activities;

public class UpdateTwitterStatusTask : TaskActivity<UpdateTwitterStatusTask>
public class UpdateXTwitterStatusTask : TaskActivity<UpdateXTwitterStatusTask>
{
private readonly TwitterClient _twitterClient;
private readonly IWorkflowExpressionEvaluator _expressionEvaluator;
protected readonly IStringLocalizer S;

public UpdateTwitterStatusTask(
public UpdateXTwitterStatusTask(
TwitterClient twitterClient,
IWorkflowExpressionEvaluator expressionEvaluator,
IStringLocalizer<UpdateTwitterStatusTask> localizer
IStringLocalizer<UpdateXTwitterStatusTask> localizer
)
{
_twitterClient = twitterClient;
_expressionEvaluator = expressionEvaluator;
S = localizer;
}

public override LocalizedString DisplayText => S["Update X Status Task"];
public override LocalizedString DisplayText => S["Update X (Twitter) Status Task"];

// The category to which this activity belongs. The activity picker groups activities by this category.
public override LocalizedString Category => S["Social"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

namespace OrchardCore.Twitter.Workflows.Drivers;

public sealed class UpdateTwitterStatusTaskDisplayDriver : ActivityDisplayDriver<UpdateTwitterStatusTask, UpdateTwitterStatusTaskViewModel>
public sealed class UpdateTwitterStatusTaskDisplayDriver : ActivityDisplayDriver<UpdateXTwitterStatusTask, UpdateTwitterStatusTaskViewModel>
{
protected override void EditActivity(UpdateTwitterStatusTask activity, UpdateTwitterStatusTaskViewModel model)
protected override void EditActivity(UpdateXTwitterStatusTask activity, UpdateTwitterStatusTaskViewModel model)
{
model.StatusTemplate = activity.StatusTemplate.Expression;
}

protected override void UpdateActivity(UpdateTwitterStatusTaskViewModel model, UpdateTwitterStatusTask activity)
protected override void UpdateActivity(UpdateTwitterStatusTaskViewModel model, UpdateXTwitterStatusTask activity)
{
activity.StatusTemplate = new WorkflowExpression<string>(model.StatusTemplate);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Data.Migration;
davidpuplava marked this conversation as resolved.
Show resolved Hide resolved
using OrchardCore.Modules;
using OrchardCore.Twitter.Migrations;
using OrchardCore.Twitter.Workflows.Activities;
using OrchardCore.Twitter.Workflows.Drivers;
using OrchardCore.Workflows.Helpers;
Expand All @@ -11,6 +13,6 @@ public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddActivity<UpdateTwitterStatusTask, UpdateTwitterStatusTaskDisplayDriver>();
services.AddActivity<UpdateXTwitterStatusTask, UpdateTwitterStatusTaskDisplayDriver>();
}
}