Skip to content

Commit

Permalink
Upgrade James
Browse files Browse the repository at this point in the history
  • Loading branch information
chibenwa committed Jan 27, 2025
1 parent 73b2486 commit a6a9390
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 24 deletions.
4 changes: 4 additions & 0 deletions tmail-backend/apps/distributed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,10 @@
</extraDirectories>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ protected void configure() {
new CassandraConsistencyTaskSerializationModule(),
Modules.override(new CassandraMailboxModule())
.with(binder -> {
binder.bind(CassandraAttachmentMapper.AttachmentIdAssignationStrategy.class).to(TmailCleverAttachmentIdAssignationStrategy.class);
binder.bind(CassandraAttachmentMapper.AttachmentIdAssignationStrategy.class).to(TMailCleverAttachmentIdAssignationStrategy.class);
binder.bind(MessageParser.class).to(TMailCleverMessageParser.class);
}),
new MailboxModule(),
Expand Down Expand Up @@ -363,7 +363,7 @@ protected void configure() {
new TeamMailboxModule(),
new TMailMailboxSortOrderProviderModule(),
new TmailEventModule(),
new TmailEventDeadLettersModule(),
new TMailEventDeadLettersModule(),
new TMailIMAPModule());

public static void main(String[] args) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/********************************************************************
* As a subpart of Twake Mail, this file is edited by Linagora. *
* *
* https://twake-mail.com/ *
* https://linagora.com *
* *
* This file is subject to The Affero Gnu Public License *
* version 3. *
* *
* https://www.gnu.org/licenses/agpl-3.0.en.html *
* *
* This program is distributed in the hope that it will be *
* useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR *
* PURPOSE. See the GNU Affero General Public License for *
* more details. *
********************************************************************/
package com.linagora.tmail.james.app;

import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentMapper;
import org.apache.james.mailbox.model.AttachmentId;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.model.ParsedAttachment;
import org.apache.james.mailbox.model.StringBackedAttachmentId;

public class TMailCleverAttachmentIdAssignationStrategy implements CassandraAttachmentMapper.AttachmentIdAssignationStrategy {
@Override
public AttachmentId assign(ParsedAttachment parsedAttachment, MessageId messageId) {
if (parsedAttachment instanceof TMailCleverParsedAttachment TMailCleverParsedAttachment) {
return StringBackedAttachmentId.from(TMailCleverParsedAttachment.translate(messageId));
}
return StringBackedAttachmentId.random();
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/********************************************************************
* As a subpart of Twake Mail, this file is edited by Linagora. *
* *
* https://twake-mail.com/ *
* https://linagora.com *
* *
* This file is subject to The Affero Gnu Public License *
* version 3. *
* *
* https://www.gnu.org/licenses/agpl-3.0.en.html *
* *
* This program is distributed in the hope that it will be *
* useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR *
* PURPOSE. See the GNU Affero General Public License for *
* more details. *
********************************************************************/

package com.linagora.tmail.james.app;

import org.apache.james.jmap.routes.BlobResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import com.google.inject.Singleton;
import com.linagora.tmail.event.TmailEventSerializer;

public class TmailEventDeadLettersModule extends AbstractModule {
public class TMailEventDeadLettersModule extends AbstractModule {

@Provides
@Singleton
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package com.linagora.tmail.james.app
import org.apache.james.jmap.mail.BlobId
import org.apache.james.jmap.routes.{AttachmentBlobResolver, BlobResolutionResult, BlobResolver, MessagePartBlobResolver, NonApplicable}
import org.apache.james.mailbox.MailboxSession
import reactor.core.scala.publisher.SMono

class TMailCleverBlobResolver(messagePartBlobResolver: MessagePartBlobResolver, attachmentBlobResolver: AttachmentBlobResolver) extends BlobResolver {
override def resolve(blobId: BlobId, mailboxSession: MailboxSession): BlobResolutionResult =
attachmentBlobResolver.resolve(blobId, mailboxSession) match {
override def resolve(blobId: BlobId, mailboxSession: MailboxSession): SMono[BlobResolutionResult] =
attachmentBlobResolver.resolve(blobId, mailboxSession)
.flatMap[BlobResolutionResult] {
case NonApplicable => messagePartBlobResolver.resolve(blobId, mailboxSession)
case any => any
case any => SMono.just(any)
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
/** ******************************************************************
* As a subpart of Twake Mail, this file is edited by Linagora. *
* *
* https://twake-mail.com/ *
* https://linagora.com *
* *
* This file is subject to The Affero Gnu Public License *
* version 3. *
* *
* https://www.gnu.org/licenses/agpl-3.0.en.html *
* *
* This program is distributed in the hope that it will be *
* useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR *
* PURPOSE. See the GNU Affero General Public License for *
* more details. *
* ****************************************************************** */

package com.linagora.tmail.james.app

import com.google.common.io.ByteSource
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream
import org.apache.james.jmap.mail.{BlobId, Disposition, EmailBodyPart}
import org.apache.james.jmap.method.ZoneIdProvider
import org.apache.james.mailbox.model.{Cid, MessageId, ParsedAttachment}
import org.apache.james.mailbox.store.mail.model.impl.MessageParser
import org.apache.james.mailbox.store.mail.model.impl.{FileBufferedBodyFactory, MessageParser}
import org.apache.james.mime4j.codec.DecodeMonitor
import org.apache.james.mime4j.dom.{Message, SingleBody}
import org.apache.james.mime4j.message.{DefaultMessageBuilder, DefaultMessageWriter}
Expand Down

0 comments on commit a6a9390

Please sign in to comment.