Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 8 additions & 4 deletions src/SIL.XForge.Scripture/Services/MachineApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class MachineApiService(
ISFProjectService projectService,
IRealtimeService realtimeService,
IOptions<ServalOptions> servalOptions,
IOptions<SiteOptions> siteOptions,
ISyncService syncService,
ITranslationEnginesClient translationEnginesClient,
ITranslationEngineTypesClient translationEngineTypesClient,
Expand Down Expand Up @@ -373,7 +374,8 @@ await draftHubContext.NotifyDraftApplyProgress(
BookNum = 0,
ChapterNum = 0,
Status = DraftApplyStatus.Failed,
Message = result.Log,
Message =
$"An error occurred applying your draft. Please email {siteOptions.Value.IssuesEmail} for help.",
}
);

Expand Down Expand Up @@ -599,7 +601,7 @@ await draftHubContext.NotifyDraftApplyProgress(
BookNum = bookNum,
ChapterNum = chapterDelta.Number,
Status = DraftApplyStatus.Failed,
Message = $"You do not have permission to write to this chapter.",
Message = "You do not have permission to write to this chapter.",
}
);
continue;
Expand Down Expand Up @@ -632,7 +634,7 @@ await draftHubContext.NotifyDraftApplyProgress(
BookNum = bookNum,
ChapterNum = chapterDelta.Number,
Status = DraftApplyStatus.Failed,
Message = $"You do not have permission to write to this chapter.",
Message = "You do not have permission to write to this chapter.",
}
);
continue;
Expand Down Expand Up @@ -714,7 +716,9 @@ await draftHubContext.NotifyDraftApplyProgress(
BookNum = 0,
ChapterNum = 0,
Status = successful ? DraftApplyStatus.Successful : DraftApplyStatus.Failed,
Message = result.Log,
Message = successful
? result.Log
: $"An error occurred applying your draft. Please email {siteOptions.Value.IssuesEmail} for help.",
}
);

Expand Down
3 changes: 2 additions & 1 deletion src/SIL.XForge.Scripture/Services/ParatextService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,8 @@ .. JArray
Dictionary<string, string> userMapping = _realtimeService
.QuerySnapshots<User>()
.Where(u => paratextIds.Contains(u.ParatextId))
.ToDictionary(u => u.ParatextId, u => u.Id);
.GroupBy(u => u.ParatextId)
.ToDictionary(p => p.Key, p => p.OrderByDescending(u => u.AuthId.Contains("paratext")).First().Id);
foreach (ParatextProjectUser user in users)
{
if (userMapping.TryGetValue(user.ParatextId, out string id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Serval.Client;
using SIL.Converters.Usj;
using SIL.Scripture;
using SIL.XForge.Configuration;
using SIL.XForge.DataAccess;
using SIL.XForge.EventMetrics;
using SIL.XForge.Models;
Expand Down Expand Up @@ -4979,6 +4980,7 @@ public TestEnvironment()
RealtimeService.AddRepository("text_documents", OTType.Json0, TextDocuments);
RealtimeService.AddRepository("texts", OTType.RichText, Texts);
ServalOptions = Options.Create(new ServalOptions { WebhookSecret = "this_is_a_secret" });
var siteOptions = Options.Create(new SiteOptions { IssuesEmail = "help@scriptureforge.org" });
SyncService = Substitute.For<ISyncService>();
SyncService.SyncAsync(Arg.Any<SyncConfig>()).Returns(Task.FromResult(HangfireJobId));
TranslationEnginesClient = Substitute.For<ITranslationEnginesClient>();
Expand Down Expand Up @@ -5019,6 +5021,7 @@ public TestEnvironment()
ProjectService,
RealtimeService,
ServalOptions,
siteOptions,
SyncService,
TranslationEnginesClient,
TranslationEngineTypesClient,
Expand Down
16 changes: 15 additions & 1 deletion test/SIL.XForge.Scripture.Tests/Services/ParatextServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6647,6 +6647,7 @@ private class TestEnvironment : IDisposable
// User04 and User05 are SF users and is not a PT users.
public readonly string User04 = "user04";
public readonly string User05 = "user05";
public readonly string User06 = "user06";
public readonly string Username01 = "User 01";
public readonly string Username02 = "User 02";
public readonly string Username03 = "User 03";
Expand Down Expand Up @@ -7275,18 +7276,31 @@ public void AddUserRepository(User[]? users = null)
new User
{
Id = User01,
AuthId = $"oauth2|paratext|{ParatextUserId01}",
ParatextId = ParatextUserId01,
Sites = sites,
},
new User
{
Id = User02,
AuthId = $"oauth2|paratext|{ParatextUserId02}",
ParatextId = ParatextUserId02,
Sites = sites,
},
new User { Id = User03, ParatextId = ParatextUserId03 },
new User
{
Id = User03,
ParatextId = ParatextUserId03,
AuthId = $"oauth2|paratext|{ParatextUserId03}",
},
new User { Id = User04 },
new User { Id = User05, Sites = sites },
new User
{
Id = User06,
AuthId = "google-oauth2|123456",
ParatextId = ParatextUserId02,
},
]
)
);
Expand Down
Loading